OpenCL 查询平台和设备

▶ 查询平台和设备的代码以结果,放在这里方便以后逐渐扩充和查询(没有营养)

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cl.h> int main()
{
int i, j;
char info[]; cl_int status;
cl_uint nPlatform;
cl_platform_id *listPlatform;
cl_uint nDevice;
cl_device_id *listDevice;
clGetPlatformIDs(, NULL, &nPlatform);
listPlatform = (cl_platform_id*)malloc(nPlatform * sizeof(cl_platform_id));
clGetPlatformIDs(nPlatform, listPlatform, NULL); for (i = ; i < nPlatform; i++)
{
clGetPlatformInfo(listPlatform[i], CL_PLATFORM_NAME, , info, NULL);
printf("Platfom[%d]:\n\tName\t\t%s", i, info);
clGetPlatformInfo(listPlatform[i], CL_PLATFORM_VERSION, , info, NULL);
printf("\n\tVersion\t\t%s", info);
//clGetPlatformInfo(listPlatform[i], CL_PLATFORM_VENDOR, 1024, info, NULL);
//printf("\n\tVendor\t\t%s", info);
//clGetPlatformInfo(listPlatform[i], CL_PLATFORM_PROFILE, 1024, info, NULL);
//printf("\n\tProfile\t\t%s", info);
clGetPlatformInfo(listPlatform[i], CL_PLATFORM_EXTENSIONS, , info, NULL);
printf("\n\tExtension\t%s", info); clGetDeviceIDs(listPlatform[i], CL_DEVICE_TYPE_ALL, , NULL, &nDevice);
listDevice = (cl_device_id*)malloc(nDevice * sizeof(cl_device_id));
clGetDeviceIDs(listPlatform[i], CL_DEVICE_TYPE_ALL, nDevice, listDevice, NULL); for (j = ; j < nDevice; j++)
{
printf("\n");
clGetDeviceInfo(listDevice[j], CL_DEVICE_NAME, , info, NULL);
printf("\n\tDevice[%d]:\n\tName\t\t%s", j, info);
clGetDeviceInfo(listDevice[j], CL_DEVICE_VERSION, , info, NULL);
printf("\n\tVersion\t\t%s", info);
clGetDeviceInfo(listDevice[j], CL_DEVICE_TYPE, , info, NULL);
switch (info[])
{
case CL_DEVICE_TYPE_DEFAULT:strcpy_s(info, "DEFAULT"); break;
case CL_DEVICE_TYPE_CPU:strcpy_s(info, "CPU"); break;
case CL_DEVICE_TYPE_GPU:strcpy_s(info, "GPU"); break;
case CL_DEVICE_TYPE_ACCELERATOR:strcpy_s(info, "ACCELERATOR"); break;
case CL_DEVICE_TYPE_CUSTOM:strcpy_s(info, "CUSTOM"); break;
case CL_DEVICE_TYPE_ALL:strcpy_s(info, "ALL"); break;
}
printf("\n\tType\t\t%s", info); cl_device_svm_capabilities svm;
clGetDeviceInfo(listDevice[j], CL_DEVICE_VERSION, sizeof(cl_device_svm_capabilities), &svm, NULL);
info[] = '\0';
if (svm & CL_DEVICE_SVM_COARSE_GRAIN_BUFFER)
strcat_s(info, "COARSE_GRAIN_BUFFER ");
if (svm & CL_DEVICE_SVM_FINE_GRAIN_BUFFER)
strcat_s(info, "FINE_GRAIN_BUFFER ");
if (svm & CL_DEVICE_SVM_FINE_GRAIN_SYSTEM)
strcat_s(info, "FINE_GRAIN_SYSTEM ");
if (svm & CL_DEVICE_SVM_ATOMICS)
strcat_s(info, "ATOMICS");
printf("\n\tSVM\t\t%s", info);
}
printf("\n\n");
free(listDevice);
}
free(listPlatform);
getchar();
return ;
}

● 输出结果,我的电脑(需要毙掉 SVM 部分才能运行)

Platfom[]:
Name NVIDIA CUDA
Version OpenCL 1.2 CUDA 9.1.
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[]:
Name GeForce GTX
Version OpenCL 1.2 CUDA
Type GPU

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

Platfom[]:
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[]:
Name Caicos
Version OpenCL 1.2 AMD-APP (1800.11)
Type GPU
SVM FINE_GRAIN_SYSTEM ATOMICS Device[]:
Name Intel(R) Core(TM) i7- CPU @ .40GHz
Version OpenCL 1.2 AMD-APP (1800.11)
Type CPU
SVM FINE_GRAIN_SYSTEM ATOMICS Platfom[]:
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[]:
Name Intel(R) Core(TM) i7- CPU @ .40GHz
Version OpenCL 1.2 (Build )
Type CPU
SVM FINE_GRAIN_SYSTEM ATOMICS

● 输出结果,办公室的电脑(新),不知道为什么出了两个一模一样的平台

Platfom[]:
Name AMD Accelerated Parallel Processing
Version OpenCL 2.0 AMD-APP (2348.3)
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[]:
Name Bonaire
Version OpenCL 2.0 AMD-APP (2348.3)
Type GPU
SVM COARSE_GRAIN_BUFFER FINE_GRAIN_BUFFER FINE_GRAIN_SYSTEM ATOMICS Device[]:
Name Intel(R) Core(TM) i7- CPU @ .40GHz
Version OpenCL 1.2 AMD-APP (2348.3)
Type CPU
SVM COARSE_GRAIN_BUFFER FINE_GRAIN_BUFFER FINE_GRAIN_SYSTEM ATOMICS Platfom[]:
Name AMD Accelerated Parallel Processing
Version OpenCL 2.0 AMD-APP (2348.3)
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[]:
Name Bonaire
Version OpenCL 2.0 AMD-APP (2348.3)
Type GPU
SVM COARSE_GRAIN_BUFFER FINE_GRAIN_BUFFER FINE_GRAIN_SYSTEM ATOMICS Device[]:
Name Intel(R) Core(TM) i7- CPU @ .40GHz
Version OpenCL 1.2 AMD-APP (2348.3)
Type CPU
SVM COARSE_GRAIN_BUFFER FINE_GRAIN_BUFFER FINE_GRAIN_SYSTEM ATOMICS
上一篇:SSAS系列——【07】多维数据(查询Cube)


下一篇:wordcount在本地运行报错解决:Exception in thread "main" java.lang.UnsatisfiedLinkError:org.apache.hadoop.io.native.NativeID$Windows.access