oskar_Imager* oskar_imager_create(int imager_precision, int* status) { oskar_Imager* h = 0; h = (oskar_Imager*) calloc(1, sizeof(oskar_Imager)); /* Create timers. */ h->tmr_grid_finalise = oskar_timer_create(OSKAR_TIMER_NATIVE); h->tmr_grid_update = oskar_timer_create(OSKAR_TIMER_NATIVE); h->tmr_init = oskar_timer_create(OSKAR_TIMER_NATIVE); h->tmr_read = oskar_timer_create(OSKAR_TIMER_NATIVE); h->tmr_write = oskar_timer_create(OSKAR_TIMER_NATIVE); h->mutex = oskar_mutex_create(); /* Create scratch arrays. */ h->imager_prec = imager_precision; h->uu_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->vv_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->ww_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->uu_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->vv_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->ww_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->vis_im = oskar_mem_create(imager_precision | OSKAR_COMPLEX, OSKAR_CPU, 0, status); h->weight_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->weight_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->time_im = oskar_mem_create(OSKAR_DOUBLE, OSKAR_CPU, 0, status); /* Check data type. */ if (imager_precision != OSKAR_SINGLE && imager_precision != OSKAR_DOUBLE) { *status = OSKAR_ERR_BAD_DATA_TYPE; return h; } /* Get number of devices available, and device location. */ oskar_device_set_require_double_precision(imager_precision == OSKAR_DOUBLE); h->num_gpus_avail = oskar_device_count(0, &h->dev_loc); /* Set sensible defaults. */ oskar_imager_set_gpus(h, -1, 0, status); oskar_imager_set_num_devices(h, -1); oskar_imager_set_algorithm(h, "FFT", status); oskar_imager_set_image_type(h, "I", status); oskar_imager_set_weighting(h, "Natural", status); oskar_imager_set_ms_column(h, "DATA", status); oskar_imager_set_default_direction(h); oskar_imager_set_generate_w_kernels_on_gpu(h, 1); oskar_imager_set_fov(h, 1.0); oskar_imager_set_size(h, 256, status); oskar_imager_set_uv_filter_max(h, DBL_MAX); return h; }
oskar_Imager* oskar_imager_create(int imager_precision, int* status) { oskar_Imager* h = 0; h = (oskar_Imager*) calloc(1, sizeof(oskar_Imager)); /* Create scratch arrays. */ h->imager_prec = imager_precision; h->uu_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->vv_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->ww_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->uu_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->vv_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->ww_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->vis_im = oskar_mem_create(imager_precision | OSKAR_COMPLEX, OSKAR_CPU, 0, status); h->weight_im = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); h->weight_tmp = oskar_mem_create(imager_precision, OSKAR_CPU, 0, status); /* Check data type. */ if (imager_precision != OSKAR_SINGLE && imager_precision != OSKAR_DOUBLE) { *status = OSKAR_ERR_BAD_DATA_TYPE; return h; } /* Set sensible defaults. */ oskar_imager_set_gpus(h, -1, 0, status); oskar_imager_set_fft_on_gpu(h, 0); oskar_imager_set_generate_w_kernels_on_gpu(h, 1); oskar_imager_set_fov(h, 1.0); oskar_imager_set_size(h, 256, status); oskar_imager_set_channel_start(h, 0); oskar_imager_set_channel_end(h, -1); oskar_imager_set_channel_snapshots(h, 1); oskar_imager_set_time_start(h, 0); oskar_imager_set_time_end(h, -1); oskar_imager_set_time_snapshots(h, 0); oskar_imager_set_uv_filter_max(h, -1.0); oskar_imager_set_image_type(h, "I", status); oskar_imager_set_algorithm(h, "FFT", status); oskar_imager_set_weighting(h, "Natural", status); oskar_imager_set_ms_column(h, "DATA", status); oskar_imager_set_default_direction(h); return h; }