码迷,mamicode.com
首页 > 其他好文 > 详细

OpenCL 查询平台和设备

时间:2018-05-12 21:00:46      阅读:541      评论:0      收藏:0      [点我收藏+]

标签:atomic   for   getchar   enc   VID   0.11   span   extension   2.0   

? 查询平台和设备的代码,以及输出结果,放在这里方便以后取用(没有营养)

 1 #include <stdio.h>  
 2 #include <stdlib.h>
 3 #include <string.h>
 4 #include <cl.h>
 5 
 6 int main()
 7 {
 8     int i, j;
 9     char info[1024];
10 
11     cl_int status;
12     cl_uint nPlatform;
13     cl_platform_id *listPlatform;
14     cl_uint nDevice;
15     cl_device_id *listDevice;
16     clGetPlatformIDs(0, NULL, &nPlatform);
17     listPlatform = (cl_platform_id*)malloc(nPlatform * sizeof(cl_platform_id));
18     clGetPlatformIDs(nPlatform, listPlatform, NULL);
19 
20     for (i = 0; i < nPlatform; i++)
21     {
22         clGetPlatformInfo(listPlatform[i], CL_PLATFORM_NAME, 1024, info, NULL);
23         printf("Platfom[%d]:\n\tName\t\t%s", i, info);
24         clGetPlatformInfo(listPlatform[i], CL_PLATFORM_VERSION, 1024, info, NULL);
25         printf("\n\tVersion\t\t%s", info);
26         //clGetPlatformInfo(listPlatform[i], CL_PLATFORM_VENDOR, 1024, info, NULL);
27         //printf("\n\tVendor\t\t%s", info);
28         //clGetPlatformInfo(listPlatform[i], CL_PLATFORM_PROFILE, 1024, info, NULL);
29         //printf("\n\tProfile\t\t%s", info);
30         clGetPlatformInfo(listPlatform[i], CL_PLATFORM_EXTENSIONS, 1024, info, NULL);
31         printf("\n\tExtension\t%s", info);
32 
33         clGetDeviceIDs(listPlatform[i], CL_DEVICE_TYPE_ALL, 0, NULL, &nDevice);
34         listDevice = (cl_device_id*)malloc(nDevice * sizeof(cl_device_id));
35         clGetDeviceIDs(listPlatform[i], CL_DEVICE_TYPE_ALL, nDevice, listDevice, NULL);
36 
37         for (j = 0; j < nDevice; j++)
38         {
39             printf("\n");
40             clGetDeviceInfo(listDevice[j], CL_DEVICE_NAME, 1024, info, NULL);
41             printf("\n\tDevice[%d]:\n\tName\t\t%s", j, info);
42             clGetDeviceInfo(listDevice[j], CL_DEVICE_VERSION, 1024, info, NULL);
43             printf("\n\tVersion\t\t%s", info);
44             clGetDeviceInfo(listDevice[j], CL_DEVICE_TYPE, 1024, info, NULL);
45             switch (info[0])
46             {
47             case CL_DEVICE_TYPE_DEFAULT:strcpy_s(info, "DEFAULT"); break;
48             case CL_DEVICE_TYPE_CPU:strcpy_s(info, "CPU"); break;
49             case CL_DEVICE_TYPE_GPU:strcpy_s(info, "GPU"); break;
50             case CL_DEVICE_TYPE_ACCELERATOR:strcpy_s(info, "ACCELERATOR"); break;
51             case CL_DEVICE_TYPE_CUSTOM:strcpy_s(info, "CUSTOM"); break;
52             case CL_DEVICE_TYPE_ALL:strcpy_s(info, "ALL"); break;
53             }
54             printf("\n\tType\t\t%s", info);            
55         }
56         printf("\n\n");
57         free(listDevice);
58     }
59     free(listPlatform);
60     getchar();
61     return 0;
62 }

● 输出结果,我的电脑

Platfom[0]:
        Name            NVIDIA CUDA
        Version         OpenCL 1.2 CUDA 9.1.83
        Extension       cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer

        Device[0]:
        Name            GeForce GTX 1070
        Version         OpenCL 1.2 CUDA
        Type            GPU

● 输出结果,办公室的电脑

Platfom[0]:
        Name            AMD Accelerated Parallel Processing
        Version         OpenCL 2.0 AMD-APP (1800.11)
        Extension       cl_khr_icd cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_dx9_media_sharing cl_amd_event_callback cl_amd_offline_devices

        Device[0]:
        Name            Caicos
        Version         OpenCL 1.2 AMD-APP (1800.11)
        Type            GPU

        Device[1]:
        Name            Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
        Version         OpenCL 1.2 AMD-APP (1800.11)
        Type            CPU

Platfom[1]:
        Name            Intel(R) OpenCL
        Version         OpenCL 1.2
        Extension       cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_dx9_media_sharing cl_intel_dx9_media_sharing cl_khr_d3d11_sharing cl_khr_gl_sharing cl_khr_fp64

        Device[0]:
        Name            Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
        Version         OpenCL 1.2 (Build 10094)
        Type            CPU

 

OpenCL 查询平台和设备

标签:atomic   for   getchar   enc   VID   0.11   span   extension   2.0   

原文地址:https://www.cnblogs.com/cuancuancuanhao/p/9029891.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!