diff printGpuInfo/printGpuInfo.cc @ 11:53e22a570937

add gpuInfo opencl example
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Mon, 11 Feb 2013 20:02:23 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/printGpuInfo/printGpuInfo.cc	Mon Feb 11 20:02:23 2013 +0900
@@ -0,0 +1,19 @@
+#include <OpenCL/opencl.h>
+#include <stdio.h>
+int main() {
+    cl_int work_item_dim;
+    size_t work_item_sizes[3];
+    size_t work_group_size;
+    cl_platform_id platform_id;
+    cl_uint ret;
+    cl_device_id device_id;
+    clGetPlatformIDs(1, &platform_id, &ret);
+    clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret);
+    clGetDeviceInfo(device_id, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(cl_uint), &work_item_dim, NULL);
+    clGetDeviceInfo(device_id, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(work_item_sizes), work_item_sizes, NULL);
+    clGetDeviceInfo(device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &work_group_size, NULL);
+    printf("Max work-item dimensions : %d \n",work_item_dim);
+    printf("Max work-item work-item sizes : %ld %ld %ld \n",work_item_sizes[0],work_item_sizes[1],work_item_sizes[2]);
+    printf("Max work-group size: %ld \n",work_group_size);
+    return 0;
+}