void oskar_telescope_duplicate_first_station(oskar_Telescope* telescope, int* status) { int i = 0; /* Copy the first station to the others. */ for (i = 1; i < telescope->num_stations; ++i) { oskar_station_free(oskar_telescope_station(telescope, i), status); telescope->station[i] = oskar_station_create_copy( oskar_telescope_station_const(telescope, 0), telescope->mem_location, status); } }
int benchmark(int num_elements, int num_directions, OpType op_type, int loc, int precision, bool evaluate_2d, int niter, double& time_taken) { int status = 0; // Create the timer. oskar_Timer *tmr = oskar_timer_create(OSKAR_TIMER_CUDA); oskar_Station* station = oskar_station_create(precision, loc, num_elements, &status); if (status) return status; station->array_is_3d = (evaluate_2d) ? OSKAR_FALSE : OSKAR_TRUE; oskar_Mem *x, *y, *z, *weights = 0, *beam = 0, *signal = 0; x = oskar_mem_create(precision, loc, num_directions, &status); y = oskar_mem_create(precision, loc, num_directions, &status); z = oskar_mem_create(precision, loc, num_directions, &status); if (status) return status; if (op_type == O2C) { int type = precision | OSKAR_COMPLEX; beam = oskar_mem_create(type, loc, num_directions, &status); weights = oskar_mem_create(type, loc, num_elements, &status); if (status) return status; oskar_timer_start(tmr); for (int i = 0; i < niter; ++i) { oskar_evaluate_array_pattern(beam, 2.0 * M_PI, station, num_directions, x, y, z, weights, &status); } time_taken = oskar_timer_elapsed(tmr); } else if (op_type == C2C || op_type == M2M) { int type = precision | OSKAR_COMPLEX; int num_signals = num_directions * num_elements; weights = oskar_mem_create(type, loc, num_elements, &status); if (op_type == C2C) { beam = oskar_mem_create(type, loc, num_directions, &status); signal = oskar_mem_create(type, loc, num_signals, &status); } else { type |= OSKAR_MATRIX; beam = oskar_mem_create(type, loc, num_directions, &status); signal = oskar_mem_create(type, loc, num_signals, &status); } if (status) return status; oskar_timer_start(tmr); for (int i = 0; i < niter; ++i) { oskar_evaluate_array_pattern_hierarchical(beam, 2.0 * M_PI, station, num_directions, x, y, z, signal, weights, &status); } time_taken = oskar_timer_elapsed(tmr); } // Destroy the timer. oskar_timer_free(tmr); // Free memory. oskar_station_free(station, &status); oskar_mem_free(x, &status); oskar_mem_free(y, &status); oskar_mem_free(z, &status); oskar_mem_free(weights, &status); oskar_mem_free(beam, &status); oskar_mem_free(signal, &status); return status; }