OpenCL:GPU上的单一计算设备?

时间:2016-09-29 23:11:30

标签: opencl gpu gpgpu gpu-programming

所以我在GeForce GT 610上运行我的OpenCL程序。我知道CUDA会是一个更好的选择,我可能会稍后写一个CUDA版本的代码,但是为了知道我也是在OpenCL中写的能够在AMD显卡上运行。

在初始化期间,我选择要运行的设备。以下是我的程序在此阶段打印出来的内容:

OpenCL Platform 0: NVIDIA CUDA
 ----- OpenCL Device # 0: GeForce GT 610-----
Gflops: 1.620000
Max Compute Units: 1
Max Clock Frequency: 1620
Total Memory of Device (bytes): 1072889856
Max Size of Memory Object Allocation (bytes): 268222464
Max Work Group Size: 1024

我的问题是为什么它说最大计算单位只有1?根据GeForce网站上的规范详情it has 48 CUDA cores。我知道CUDA在Nvidia显卡上运行得更好,但它真的限制了这么多吗? Nvidia将OpenCL限制为1/48的功率?

以下是我的代码打印方式如下:

if (clGetPlatformInfo(platforms[platform], CL_PLATFORM_NAME, sizeof(name), name, NULL)) Fatal("Cannot get OpenCL platform name\n");
if (verbose) printf("OpenCL Platform %d: %s\n", platform, name);

...在forloop内...

  cl_uint compUnits, freq;
  cl_ulong memSize, maxAlloc;
  size_t maxWorkGrps;

  if (clGetDeviceInfo(id[devId], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compUnits), &compUnits, NULL)) Fatal("Cannot get OpenCL device units\n");
  if (clGetDeviceInfo(id[devId], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(freq), &freq, NULL)) Fatal("Cannot get OpenCL device frequency\n");
  if (clGetDeviceInfo(id[devId], CL_DEVICE_NAME, sizeof(name), name, NULL)) Fatal("Cannot get OpenCL device name\n");

  if (clGetDeviceInfo(id[devId], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(memSize), &memSize, NULL)) Fatal("Cannot get OpenCL memory size.\n");
  if (clGetDeviceInfo(id[devId], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(memSize), &maxAlloc, NULL)) Fatal("Cannot get OpenCL memory size.\n");

  if (clGetDeviceInfo(id[devId], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(maxWorkGrps), &maxWorkGrps, NULL)) Fatal("Cannot get OpenCL max work group size\n");

  int Gflops = compUnits * freq;

  if (verbose) printf(" ----- OpenCL Device # %d: %s-----\n"
    "Gflops: %f\n"
    "Max Compute Units: %d\n"
    "Max Clock Frequency: %d\n"
    "Total Memory of Device (bytes): %lu\n"
    "Max Size of Memory Object Allocation (bytes): %lu\n"
    "Max Work Group Size: %d\n",
    devId,
    name,
    1e-3*Gflops,
    compUnits,
    freq,
    memSize,
    maxAlloc,
    maxWorkGrps);

1 个答案:

答案 0 :(得分:4)

  

我的问题是为什么它说最大计算单位只有1?

此处引用的计算单元对应于NVIDIA GPU SM(流式多处理器)。那个GPU只有一个SM,里面有48个核心。

因此,您不仅限于单个核心,也不仅限于该GPU的1/48。访问该计算单元意味着您的程序可以访问其中包含的48个核心。