1

我正在尝试使用以下代码获取设备的内存总线带宽:

 #include <stdio.h>

    int main() {
  int nDevices;

  cudaGetDeviceCount(&nDevices);
  for (int i = 0; i < nDevices; i++) {
    cudaDeviceProp prop;
    cudaGetDeviceProperties(&prop, i);
    printf("Device Number: %d\n", i);
    printf("  Device name: %s\n", prop.name);
    printf("  Memory Clock Rate (KHz): %d\n",
           prop.memoryClockRate);
    printf("  Memory Bus Width (bits): %d\n",
           prop.memoryBusWidth);
    printf("  Peak Memory Bandwidth (GB/s): %f\n\n",
           2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
  }
}

我收到了这个错误:

bandwidth.cu(13): error: class "cudaDeviceProp" has no member "memoryClockRate"

bandwidth.cu(15): error: class "cudaDeviceProp" has no member "memoryBusWidth"

bandwidth.cu(17): error: class "cudaDeviceProp" has no member "memoryClockRate"

bandwidth.cu(17): error: class "cudaDeviceProp" has no member "memoryBusWidth"

4 errors detected in the compilation of "/tmp/tmpxft_000003c4_00000000-4_bandwidth.cpp1.ii".
make: *** [hello.cu_o] Error 2

有人可以帮忙吗?我正在使用Tesla T10 处理器GPU 和CUDA 3.2

4

1 回答 1

1

您可以在线查看CUDA 3.2 文档,您会发现当时的设备属性有所不同。要么升级到 CUDA 5.0,要么让你的代码适应 CUDA 3.2。

如果您决定坚持使用 CUDA 3.2,请查看 SDK 示例,特别是bandwidthTest.cu它显示了它过去是如何完成的。

于 2013-04-26T08:28:31.567 回答