void oskar_interferometer_set_num_devices(oskar_Interferometer* h, int value)
{
    int status = 0;
    free_device_data(h, &status);
    if (value < 1)
        value = (h->num_gpus == 0) ? (oskar_get_num_procs() - 1) : h->num_gpus;
    if (value < 1) value = 1;
    h->num_devices = value;
    h->d = (DeviceData*) realloc(h->d, h->num_devices * sizeof(DeviceData));
    memset(h->d, 0, h->num_devices * sizeof(DeviceData));
}
Example #2
0
void oskar_simulator_reset_cache(oskar_Simulator* h, int* status)
{
    free_device_data(h, status);
    oskar_binary_free(h->vis);
    oskar_vis_header_free(h->header, status);
#ifndef OSKAR_NO_MS
    oskar_ms_close(h->ms);
#endif
    h->vis = 0;
    h->header = 0;
    h->ms = 0;
}
Example #3
0
void oskar_simulator_set_num_devices(oskar_Simulator* h, int value)
{
    int status = 0;
    free_device_data(h, &status);
#ifdef _OPENMP
    if (value < 1)
        value = (h->num_gpus == 0) ? (omp_get_num_procs() - 1) : h->num_gpus;
#endif
    if (value < 1) value = 1;
    h->num_devices = value;
    h->d = (DeviceData*) realloc(h->d, h->num_devices * sizeof(DeviceData));
    memset(h->d, 0, h->num_devices * sizeof(DeviceData));
}
Example #4
0
void oskar_simulator_set_gpus(oskar_Simulator* h, int num,
        int* ids, int* status)
{
    int i, num_gpus_avail;
    if (*status) return;
    free_device_data(h, status);
    num_gpus_avail = oskar_device_count(status);
    if (*status) return;
    if (num < 0)
    {
        h->num_gpus = num_gpus_avail;
        h->gpu_ids = (int*) realloc(h->gpu_ids, h->num_gpus * sizeof(int));
        for (i = 0; i < h->num_gpus; ++i)
            h->gpu_ids[i] = i;
    }
    else if (num > 0)
    {
        if (num > num_gpus_avail)
        {
            oskar_log_error(h->log, "More GPUs were requested than found.");
            *status = OSKAR_ERR_COMPUTE_DEVICES;
            return;
        }
        h->num_gpus = num;
        h->gpu_ids = (int*) realloc(h->gpu_ids, h->num_gpus * sizeof(int));
        for (i = 0; i < h->num_gpus; ++i)
            h->gpu_ids[i] = ids[i];
    }
    else /* num == 0 */
    {
        free(h->gpu_ids);
        h->gpu_ids = 0;
        h->num_gpus = 0;
    }
    for (i = 0; i < h->num_gpus; ++i)
    {
        oskar_device_set(h->gpu_ids[i], status);
        if (*status) return;
    }
}