内核可以工作,但不应该



我运行内核时每个块有一个线程,如<<<NUMBER_OF_BLOCKS, 1>>>

在我的GPU上(根据deviceQuery),我只能运行512个块。因此,只有当NUMBER_OF_BLOCKS<=512,但若我运行32768个块,程序仍然可以运行。当我运行65536个或更多块时,会显示错误的结果。

我错过了什么?

我错过了什么?

没有任何地方说你的GPU只能运行512个块。它说你的GPU每个块只能运行512个线程,即:

 CUDA Device Query (Runtime API) version (CUDART static linking)
There is 1 device supporting CUDA
Device 0: "GeForce 320M"
  CUDA Driver Version:                           5.0
  CUDA Runtime Version:                          5.0
  CUDA Capability Major/Minor version number:    1.2
  Total amount of global memory:                 265027584 bytes
  Multiprocessors x Cores/MP = Cores:            1 (MP) x 8 (Cores/MP) = 8 (Cores)
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       16384 bytes
  Total number of registers available per block: 16384
  Warp size:                                     32
  Maximum number of threads per block:           512
  Maximum sizes of each dimension of a block:    512 x 512 x 64
  Maximum sizes of each dimension of a grid:     65535 x 65535 x 1
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             256 bytes
  Clock rate:                                    0.95 GHz
  Concurrent copy and execution:                 Yes
  Run time limit on kernels:                     Yes
  Integrated:                                    Yes
  Support host page-locked memory mapping:       Yes
  Compute mode:                                  Exclusive (only one host thread at a time can use this device)
  Concurrent kernel execution:                   Yes
  Device has ECC support enabled:                No
  Device is using TCC driver mode:               Yes
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 5.0, CUDA Runtime Version = 5.0, NumDevs = 1, Device = GeForce 320M

所有支持CUDA的GPU每次内核启动都可以运行最多65535 x 65535个块的网格。较新的设备可以运行比这更大的网格。

最新更新