コード例 #1
0
// select OpenCL platforms by OpenCL version
void
HGPU_GPU_platforms_select_by_version(HGPU_GPU_platforms** platforms,HGPU_GPU_version version){
    unsigned int platforms_number = HGPU_GPU_platforms_get_number(*platforms);
    if (!platforms_number) HGPU_GPU_error(HGPU_ERROR_NO_PLATFORM);
    cl_uint desired_platforms = 0;
    for(unsigned int i=0; i<platforms_number; i++){
        cl_platform_id platform = (*platforms)->platforms[i];
        HGPU_GPU_version version_gpu = HGPU_GPU_platform_get_version(platform);
        if (HGPU_GPU_version_check(version_gpu,version)) desired_platforms++;
    }
    if(!desired_platforms) HGPU_GPU_error(HGPU_ERROR_NO_PLATFORM);
    HGPU_GPU_platforms* result = HGPU_GPU_platforms_new(desired_platforms);
    int j=0;
    for(unsigned int i=0; i<platforms_number; i++){
        cl_platform_id platform = (*platforms)->platforms[i];
        HGPU_GPU_version version_gpu = HGPU_GPU_platform_get_version(platform);
        if (HGPU_GPU_version_check(version_gpu,version)) result->platforms[j++] = platform;
    }
    HGPU_GPU_platforms_delete(platforms);
    (*platforms) = result;
}
コード例 #2
0
ファイル: hgpucl_devices.cpp プロジェクト: vadimdi/PRNGCL
// select OpenCL devices by OpenCL version
void
HGPU_GPU_devices_select_by_version(HGPU_GPU_devices** devices,HGPU_GPU_version version){
    unsigned int number_of_devices = HGPU_GPU_devices_get_number(*devices);
    if (!number_of_devices) HGPU_GPU_error(HGPU_ERROR_NO_DEVICE);
    cl_uint desired_devices = 0;
    for(unsigned int i=0; i<number_of_devices; i++){
        cl_device_id device = (*devices)->devices[i];
        HGPU_GPU_version version_gpu = HGPU_GPU_device_get_version(device);
        if (HGPU_GPU_version_check(version_gpu,version)) desired_devices++;
    }
    HGPU_GPU_devices* result;
    if(desired_devices){
        result = HGPU_GPU_devices_new(desired_devices);
        int device_index=0;
        for(unsigned int i=0; i<number_of_devices; i++){
            cl_device_id device = (*devices)->devices[i];
            HGPU_GPU_version version_gpu = HGPU_GPU_device_get_version(device);
            if (HGPU_GPU_version_check(version_gpu,version)) result->devices[device_index++] = device;
        }
    } else
        result = HGPU_GPU_devices_new_empty();
    HGPU_GPU_devices_delete(devices);
    (*devices) = result;
}
コード例 #3
0
// return MIN version
HGPU_GPU_version
HGPU_GPU_version_min(HGPU_GPU_version version1, HGPU_GPU_version version2){
    if (HGPU_GPU_version_check(version1,version2)) return version2;
    else return version1;
}