コード例 #1
0
// get total number of OpenCL platforms
unsigned int
HGPU_GPU_platforms_get_total_number(void){
    HGPU_GPU_platforms* platforms = HGPU_GPU_platforms_get();
    unsigned int result = HGPU_GPU_platforms_get_number(platforms);
    HGPU_GPU_platforms_delete(&platforms);
    return result;
}
コード例 #2
0
ファイル: hgpucl_devices.cpp プロジェクト: vadimdi/PRNGCL
// get all OpenCL devices
HGPU_GPU_devices*
HGPU_GPU_devices_get(void){
    HGPU_GPU_platforms* platforms = HGPU_GPU_platforms_get();
    HGPU_GPU_devices* result = HGPU_GPU_devices_get_on_platforms(platforms);
    HGPU_GPU_platforms_delete(&platforms);
    return result;
}
コード例 #3
0
ファイル: hgpucl_devices.cpp プロジェクト: vadimdi/PRNGCL
// get OpenCL devices by vendor
HGPU_GPU_devices*
HGPU_GPU_devices_get_by_vendor(HGPU_GPU_vendor vendor){
    HGPU_GPU_platforms* platforms = HGPU_GPU_platforms_get();
    HGPU_GPU_devices* result = HGPU_GPU_devices_get_on_platforms(platforms);
    HGPU_GPU_devices_select_by_vendor(&result,vendor);
    return result;
}
コード例 #4
0
ファイル: hgpucl_devices.cpp プロジェクト: vadimdi/PRNGCL
// get total number of OpenCL devices
unsigned int
HGPU_GPU_devices_get_total_number(void){
    HGPU_GPU_platforms* platforms = HGPU_GPU_platforms_get();
    unsigned int result = 0;
    for (unsigned int i=0;i<HGPU_GPU_platforms_get_number(platforms);i++)
        result += HGPU_GPU_devices_get_number_on_platform(platforms->platforms[i]);
    HGPU_GPU_platforms_delete(&platforms);
    return result;
}
コード例 #5
0
// get OpenCL platforms by index
cl_platform_id
HGPU_GPU_platform_get_by_index(unsigned int platform_index){
    cl_platform_id result;
    HGPU_GPU_platforms* platforms = HGPU_GPU_platforms_get();
    if (HGPU_GPU_platforms_get_number(platforms)<=platform_index) {
        HGPU_GPU_platforms_delete(&platforms);
        HGPU_GPU_error_message(HGPU_ERROR_NO_PLATFORM,"there is no any desired OpenCL platform");
    }
    result = platforms->platforms[platform_index];
    HGPU_GPU_platforms_delete(&platforms);
    return result;
}
コード例 #6
0
ファイル: hgpucl_devices.cpp プロジェクト: vadimdi/PRNGCL
// 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;
}
コード例 #7
0
// get index of OpenCL platform by platform
unsigned int
HGPU_GPU_platform_get_index_of(cl_platform_id platform){
    unsigned int result = 0;
    HGPU_GPU_platforms* platforms = HGPU_GPU_platforms_get();
    bool flag = true;
    while ((result<HGPU_GPU_platforms_get_number(platforms))&&(flag)){
        if (platforms->platforms[result]==platform) flag = false;
        else result++;
    }
    HGPU_GPU_platforms_delete(&platforms);
    if (flag) HGPU_GPU_error_message(HGPU_ERROR_NO_PLATFORM,"there is no any desired OpenCL platform");
    return result;
}
コード例 #8
0
// get OpenCL platforms by vendor
HGPU_GPU_platforms*
HGPU_GPU_platforms_get_by_vendor(HGPU_GPU_vendor vendor){
    HGPU_GPU_platforms* result = HGPU_GPU_platforms_get();
    HGPU_GPU_platforms_select_by_vendor(&result,vendor);
    return result;
}