OpenCL Device Information

 

 

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 #ifdef __APPLE__
 5 #include <OpenCL/opencl.h>
 6 #else
 7 #include <CL/cl.h>
 8 #endif
 9 
10 
11 
12 #define MEM_SIZE (128)
13 #define MAX_SOURCE_SIZE (0x100000)
14 
15 int main()
16 {
17     cl_platform_id platform_id = NULL;
18     cl_device_id device_id = NULL;
19     cl_uint ret_num_devices;
20     cl_uint ret_num_platforms;
21     cl_int ret;
22     cl_uint work_item_dim;
23     size_t work_item_sizes[3];
24     size_t work_group_size;
25     cl_uint ucomput_uint = 0;
26     cl_uint uconstant_args = 0;
27     cl_ulong uconstant_buffer_size = 0;
28 
29     /* Ç÷§Æû, µð¹ÙÀÌœº Á€ºžžŠ ŸòÀœ */
30     ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
31     ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &ret_num_devices);
32 
33     clGetDeviceInfo(device_id, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(cl_uint), (void *)&work_item_dim, NULL);
34     clGetDeviceInfo(device_id, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(work_item_sizes),(void *)work_item_sizes, NULL);
35     clGetDeviceInfo(device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), (void *)&work_group_size, NULL);
36     clGetDeviceInfo(device_id, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint), (void *)&ucomput_uint, NULL);
37     clGetDeviceInfo(device_id, CL_DEVICE_MAX_CONSTANT_ARGS, sizeof(cl_uint), (void *)&uconstant_args, NULL);
38     clGetDeviceInfo(device_id, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(cl_ulong), (void *)&uconstant_buffer_size, NULL);
39 
40     printf("Max work-item dimensions   : %d\n", work_item_dim);
41     printf("Max work-item sizes        : %d %d %d\n", work_item_sizes[0],work_item_sizes[1], work_item_sizes[2]) ;
42     printf("Max work-group sizes       : %d\n", work_group_size);
43     printf("Max comput_uint            : %u\n", ucomput_uint);
44     printf("Max constant_args          : %u\n", uconstant_args);
45     printf("Max constant_buffer_size   : %u\n", uconstant_buffer_size);
46 
47 
48     return 0;
49 }
 1 #Makefile
 2 TARGETS:=$(notdir $(PWD))
 3 CFLAGS=-Wall -W -O2
 4 
 5 PATH_TO_NVIDIA_INC=/usr/local/cuda/include/\
 6                    -I/usr/local/cuda/include/CL
 7 PATH_TO_NVIDIA_LIB=/usr/local/cuda/lib64/
 8 
 9 OBJECTS=$(patsubst %.cpp,%.o, $(wildcard *.cpp))
10 
11 .SUFFIXES:.o .cpp
12 .cpp.o:
13     g++ $(CFLAGS) -I$(PATH_TO_NVIDIA_INC) -c -g -o $@ $<
14 
15 all:$(TARGETS)
16 
17 $(TARGETS):$(OBJECTS)
18     g++ $(CFLAGS) -I$(PATH_TO_NVIDIA_INC) -L$(PATH_TO_NVIDIA_LIB) -g -o $@ $^ -lOpenCL
19 
20 run:
21     ./$(TARGETS)
22 clean:
23     rm -f *.o $(TARGETS) 

./DeviceInfo
Max work-item dimensions   : 3
Max work-item sizes        : 1024 1024 64
Max work-group sizes       : 1024
Max comput_uint            : 4
Max constant_args          : 9
Max constant_buffer_size   : 65536

./DeviceQueryDemo
./DeviceQueryDemo Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 650 Ti"
  CUDA Driver Version / Runtime Version          8.0 / 7.0
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 971 MBytes (1018626048 bytes)
  ( 4) Multiprocessors, (192) CUDA Cores/MP:     768 CUDA Cores
  GPU Clock rate:                                1032 MHz (1.03 GHz)
  Memory Clock rate:                             2700 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 262144 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Bus ID / PCI location ID:           1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 7.0, NumDevs = 1, Device0 = GeForce GTX 650 Ti
Result = PASS

 

转载于:https://www.cnblogs.com/ILoveOCT/p/6596991.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值