Example #1
0
static void
HGPU_PRNG_RANMAR_parameters_set(void* PRNG_state,HGPU_parameter** parameters){
    if ((!parameters) || (!PRNG_state)) return;
    HGPU_PRNG_RANMAR_state_t* state = (HGPU_PRNG_RANMAR_state_t*) PRNG_state;
    HGPU_parameter* parameter = HGPU_parameters_get_by_name(parameters,(char*) HGPU_PARAMETER_PRNG_SEED1);
    if (parameter) (*state).seed1 = parameter->value_integer;

    parameter = HGPU_parameters_get_by_name(parameters,(char*) HGPU_PARAMETER_PRNG_SEED2);
    if (parameter) (*state).seed2 = parameter->value_integer;

}
Example #2
0
// automatically select OpenCL devices according to (HGPU_parameter) parameters
HGPU_GPU_devices*
HGPU_GPU_devices_select_auto(HGPU_parameter** parameters){
    HGPU_GPU_platforms* platforms = NULL;
    HGPU_GPU_devices*   devices   = NULL;
    HGPU_parameter* parameter_device      = HGPU_parameters_get_by_name(parameters,(char*) HGPU_PARAMETER_DEVICE);
    HGPU_parameter* parameter_device_type = HGPU_parameters_get_by_name(parameters,(char*) HGPU_PARAMETER_DEVICE_TYPE);
    HGPU_parameter* parameter_platform    = HGPU_parameters_get_by_name(parameters,(char*) HGPU_PARAMETER_PLATFORM);

    if (parameter_platform) {
        unsigned int platform_id = parameter_platform->value_integer;
        if ((!platform_id) && (strlen(parameter_platform->value_text)>1)){
            // get platforms by vendor
            platforms = HGPU_GPU_platforms_get();
            HGPU_GPU_vendor platform_vendor = HGPU_convert_vendor_from_str(parameter_platform->value_text);
            HGPU_GPU_platforms_select_by_vendor(&platforms,platform_vendor);
        } else {
            platforms = HGPU_GPU_platforms_new(1);
            platforms[0].platforms[0] = HGPU_GPU_platform_get_by_index(platform_id);
        }
        devices = HGPU_GPU_devices_get_on_platforms(platforms);
    }

    if (parameter_device) {
        unsigned int device_id = parameter_device->value_integer;
        if ((!device_id) && (strlen(parameter_device->value_text)>1)){
            HGPU_GPU_vendor device_vendor = HGPU_convert_vendor_from_str(parameter_device->value_text);
            // get devices by vendor
            if (parameter_platform)
                HGPU_GPU_devices_select_by_vendor(&devices,device_vendor);
            else
                devices = HGPU_GPU_devices_get_by_vendor(device_vendor);
        } else {
            devices = HGPU_GPU_devices_new(1);
            if (parameter_platform)
                devices[0].devices[0] = HGPU_GPU_device_get_by_index_on_platform(platforms[0].platforms[0],device_id);
            else
                devices[0].devices[0] = HGPU_GPU_device_get_by_index(device_id);
        }
    }

    if ((!parameter_platform) && (!parameter_device))
        devices = HGPU_GPU_devices_get();

    if (parameter_device_type) {
        if (!strcmp(parameter_device_type->value_text,"GPU")) HGPU_GPU_devices_select_by_type(&devices,CL_DEVICE_TYPE_GPU);
        if (!strcmp(parameter_device_type->value_text,"CPU")) HGPU_GPU_devices_select_by_type(&devices,CL_DEVICE_TYPE_CPU);
        if (!strcmp(parameter_device_type->value_text,"ACCELERATOR")) HGPU_GPU_devices_select_by_type(&devices,CL_DEVICE_TYPE_ACCELERATOR);
    }

    HGPU_GPU_devices_sort(&devices);

    return devices;
}