不确定找到GPU最大可用线程数的最佳方法是什么。 我有以下代码:
int deviceCount, device;
int gpuDeviceCount = 0;
struct cudaDeviceProp properties;
cudaError_t cudaResultCode = cudaGetDeviceCount(&deviceCount);
if (cudaResultCode != cudaSuccess)
deviceCount = 0;
/* machines with no GPUs can still report one emulation device */
for (device = 0; device < deviceCount; ++device) {
cudaGetDeviceProperties(&properties, device);
if (properties.major != 9999) /* 9999 means emulation only */
if (device==0)
{
printf("multiProcessorCount %d\n",properties.multiProcessorCount);
printf("maxThreadsPerMultiProcessor %d\n",properties.maxThreadsPerMultiProcessor);
}
}
返回:
multiProcessorCount 14
maxThreadsPerMultiProcessor 1536
事实证明总数是14 * 1536 = 21504。我觉得它太小了(我有特斯拉M2070)。
答案 0 :(得分:3)
您的检查方式是正确的。 您可以查看NVIDIA cuda SDK示例,SDK中的“设备查询”示例定义好