CUDA:2D网格启动错误

时间:2015-09-27 21:56:18

标签: cuda

我正在尝试启动尺寸为(65535x1000)的2D网格,但cudaDeviceSynchronize返回代码错误6。我的设备应该支持最多65535块的y维度,所以我不明白发生了什么。这是我的代码

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>

cudaError_t addWithCuda();

__global__ void kernel()
{
    int i = blockIdx.x*blockIdx.y;
}

int main()

{

cudaError_t cudaStatus;

// Choose which GPU to run on, change this on a multi-GPU system.
cudaStatus = cudaSetDevice(0);
if (cudaStatus != cudaSuccess) {
    fprintf(stderr, "cudaSetDevice failed!  Do you have a CUDA-capable GPU installed?");
}


// Launch a kernel on the GPU 
dim3 grid(65535,1000) ;
kernel<<<grid, 1024>>>();

// Check for any errors launching the kernel
cudaStatus = cudaGetLastError();
if (cudaStatus != cudaSuccess) {
    fprintf(stderr, "addKernel launch failed: %s\n", cudaGetErrorString(cudaStatus));
}

// cudaDeviceSynchronize waits for the kernel to finish, and returns
// any errors encountered during the launch.
cudaStatus = cudaDeviceSynchronize();

if (cudaStatus != cudaSuccess) {
    fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching Kernel!\n", cudaStatus);
}

// cudaDeviceReset must be called before exiting in order for profiling and
// tracing tools such as Nsight and Visual Profiler to show complete traces.
cudaStatus = cudaDeviceReset();
if (cudaStatus != cudaSuccess) {
    fprintf(stderr, "cudaDeviceReset failed!");
    return 1;
}
system("pause");
return 0;

}

0 个答案:

没有答案