cuda内核不执行所有的blockIdx

cuda kernel not executed for all blockIdx

本文关键字:blockIdx 执行 内核 cuda      更新时间:2023-10-16

我在我的代码中隔离了一个bug,我不知道我做错了什么。当我执行以下代码时,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 executionn");
  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. 尝试打印 cudadevicesynize
  2. 给出的错误
  3. 尝试使用cuda-memcheck ./program
  4. 执行你的代码
  5. 如果点2)返回错误,使用cuda-gdb调试它。
  6. 你正在启动一个由62个线程块组成的1D内核,每个线程块有256个线程。我希望你的输出是网格(62,1,1)块(256,1,1)出价(b_x, 1,1) tid (t_x,1,1)