Mercurial > hg > Members > yuuhi > OpenCL
changeset 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 | e38bef2012bc |
children | a664602e1819 |
files | printGpuInfo/Makefile printGpuInfo/printGpuInfo.cc |
diffstat | 2 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/printGpuInfo/Makefile Mon Feb 11 20:02:23 2013 +0900 @@ -0,0 +1,11 @@ +CFLAGS = -Wall -framework opencl +CC = clang++ +OPT = -g + +TARGET=printInfo + +printInfo : printGpuInfo.o + $(CC) $(OPT) $(CFLAGS) -o $@ $? + +clean: + rm -rf *.o $(TARGET) \ No newline at end of file
--- /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; +}