Пример #1
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;
}
Пример #2
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;
}
Пример #3
0
// 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;
}
Пример #4
0
// 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 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;
}
Пример #6
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;
}
Пример #7
0
// select OpenCL platforms by vendor
void
HGPU_GPU_platforms_select_by_vendor(HGPU_GPU_platforms** platforms,HGPU_GPU_vendor vendor){
    unsigned int platforms_number = HGPU_GPU_platforms_get_number(*platforms);
    if (!platforms_number) HGPU_GPU_error(HGPU_ERROR_NO_PLATFORM);
    char infobuf[HGPU_GPU_MAX_STR_INFO_LENGHT];
    cl_uint desired_platforms = 0;
    for(unsigned int i=0; i<platforms_number; i++){
        cl_platform_id GPU_platform = (*platforms)->platforms[i];
        HGPU_GPU_error_message(clGetPlatformInfo(GPU_platform,CL_PLATFORM_VENDOR,sizeof(infobuf),infobuf,NULL),"clGetPlatformInfo failed");
        if ((HGPU_convert_vendor_from_str(infobuf)==vendor) || (vendor==HGPU_GPU_vendor_any)) 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 GPU_platform = (*platforms)->platforms[i];
        HGPU_GPU_error_message(clGetPlatformInfo(GPU_platform,CL_PLATFORM_VENDOR,sizeof(infobuf),infobuf,NULL),"clGetPlatformInfo failed");
        if ((HGPU_convert_vendor_from_str(infobuf)==vendor) || (vendor==HGPU_GPU_vendor_any)) result->platforms[j++] = GPU_platform;
    }
    HGPU_GPU_platforms_delete(platforms);
    (*platforms) = result;
}