static void free_device_data(oskar_Simulator* h, int* status) { int i; if (!h->d) return; for (i = 0; i < h->num_devices; ++i) { DeviceData* d = &(h->d[i]); if (!d) continue; if (i < h->num_gpus) oskar_device_set(h->gpu_ids[i], status); oskar_timer_free(d->tmr_compute); oskar_timer_free(d->tmr_copy); oskar_timer_free(d->tmr_clip); oskar_timer_free(d->tmr_E); oskar_timer_free(d->tmr_K); oskar_timer_free(d->tmr_join); oskar_timer_free(d->tmr_correlate); oskar_vis_block_free(d->vis_block_cpu[0], status); oskar_vis_block_free(d->vis_block_cpu[1], status); oskar_vis_block_free(d->vis_block, status); oskar_mem_free(d->u, status); oskar_mem_free(d->v, status); oskar_mem_free(d->w, status); oskar_sky_free(d->chunk, status); oskar_sky_free(d->chunk_clip, status); oskar_telescope_free(d->tel, status); oskar_station_work_free(d->station_work, status); oskar_jones_free(d->J, status); oskar_jones_free(d->E, status); oskar_jones_free(d->K, status); oskar_jones_free(d->R, status); memset(d, 0, sizeof(DeviceData)); } }
void destroyTestData() { int status = 0; oskar_jones_free(jones, &status); oskar_mem_free(u_, &status); oskar_mem_free(v_, &status); oskar_mem_free(w_, &status); oskar_sky_free(sky, &status); oskar_telescope_free(tel, &status); ASSERT_EQ(0, status) << oskar_get_error_string(status); }
int benchmark(int num_stations, int num_sources, int type, int jones_type, int loc, int use_extended, int use_time_ave, int niter, std::vector<double>& times) { int status = 0; oskar_Timer* timer; timer = oskar_timer_create(loc == OSKAR_GPU ? OSKAR_TIMER_CUDA : OSKAR_TIMER_OMP); // Set up a test sky model, telescope model and Jones matrices. oskar_Telescope* tel = oskar_telescope_create(type, loc, num_stations, &status); oskar_Sky* sky = oskar_sky_create(type, loc, num_sources, &status); oskar_Jones* J = oskar_jones_create(jones_type, loc, num_stations, num_sources, &status); oskar_telescope_set_channel_bandwidth(tel, 1e6); oskar_telescope_set_time_average(tel, (double) use_time_ave); oskar_sky_set_use_extended(sky, use_extended); // Memory for visibility coordinates and output visibility slice. oskar_Mem *vis, *u, *v, *w; vis = oskar_mem_create(jones_type, loc, oskar_telescope_num_baselines(tel), &status); u = oskar_mem_create(type, loc, num_stations, &status); v = oskar_mem_create(type, loc, num_stations, &status); w = oskar_mem_create(type, loc, num_stations, &status); // Run benchmark. times.resize(niter); for (int i = 0; i < niter; ++i) { oskar_timer_start(timer); oskar_cross_correlate(vis, oskar_sky_num_sources(sky), J, sky, tel, u, v, w, 0.0, 100e6, &status); times[i] = oskar_timer_elapsed(timer); } // Free memory. oskar_mem_free(u, &status); oskar_mem_free(v, &status); oskar_mem_free(w, &status); oskar_mem_free(vis, &status); oskar_jones_free(J, &status); oskar_telescope_free(tel, &status); oskar_sky_free(sky, &status); oskar_timer_free(timer); return status; }