1
我在代码中隔离了一个错误,我无法理解我做错了什么。当我执行下面的代码时,CUDA内核不会为所有块执行。cuda内核不能执行所有blockIdx
#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块。在情况下,可能会帮助找出我的错误,这里是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) >
谁能帮我解决这个问题?
你可能只是溢出了内核printf缓冲区。运行时为缓冲区分配一个固定的空间量。你的内核可能产生太多的输出 – talonmies
是的,那是一个溢出。通过在'printf'之前添加一个测试'if(blockIdx.x <20)',我可以看到具有较小x ids的块。 –