没有为所有blockIdx执行cuda内核

时间:2015-07-10 11:41:10

标签: c++ cuda

我在代码中发现了一个错误,我无法理解我做错了什么。当我执行以下代码时,不会对所有块执行CUDA内核。

#include <stdio.h>

__global__
void dummy_test_kernel()
{
  printf("grid = (%i, %i, %i), block = (%i, %i, %i),
    bid (%i,%i,%i), tid (%i, %i, %i)\n",
    gridDim.x, gridDim.y, gridDim.z,
    blockDim.x, blockDim.y, blockDim.z,
    blockIdx.x, blockIdx.y, blockIdx.z,
    threadIdx.x, threadIdx.y, threadIdx.z );
}

int main( int argc, char* argv[] )
{
  (void)argc;
  (void)argv;
  dummy_test_kernel<<<62,256>>>();
  if(cudaDeviceSynchronize())
    printf("something went wrong in the kernel execution\n");
  return 0;
}

例如,我从未看到过blockIdx.x的块&lt; 20印刷任何东西。如果这可能有助于弄清楚我的错误,这里是CUDA样本中找到的deviceQuery返回的信息:

Device 0: "GeForce GTX 675M"
  CUDA Driver Version / Runtime Version          7.5 / 7.0
  CUDA Capability Major/Minor version number:    2.1
  Total amount of global memory:                 2048 MBytes (2147155968 bytes)
  ( 8) Multiprocessors, ( 48) CUDA Cores/MP:     384 CUDA Cores
  GPU Max Clock rate:                            1240 MHz (1.24 GHz)
  Memory Clock rate:                             1500 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 524288 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65535), 3D=(2048, 2048, 2048)
  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: 32768
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1536
  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): (65535, 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:                     No
  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 Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:-1)

  1. 尝试打印 cudaDeviceSynchronize
  2. 给出的错误
  3. 尝试使用 cuda-memcheck执行您的代码./program
  4. 如果第2点)返回错误,请使用 cuda-gdb 进行调试。
  5. 您正在启动一个包含62个线程块的1D内核,每个线程包含256个线程。我希望你的输出是网格(62,1,1)块(256,1,1)bid(b_x,1,1)tid(t_x,1,1)