我已经开始使用 JCuda。当我编译程序时,我收到“jcuda.cuda exception cuda_error_launch_failed”错误。我已按照安装指南中给出的步骤操作但不起作用。网上可用的资源很少。所以,请帮助我.这是我的代码:
extern "C"
__global__ void reduce(float *g_idata, float *g_odata, unsigned int n)
{
extern __shared__ float sdata[];
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x*blockDim.x*2 + threadIdx.x;
unsigned int gridSize = blockDim.x*2*gridDim.x;
float mySum = 0;
while (i < n)
{
mySum += g_idata[i];
if (i + blockDim.x < n)
mySum += g_idata[i+blockDim.x];
i += gridSize;
}
sdata[tid] = mySum;
__syncthreads();
if (blockDim.x >= 512) { if (tid < 256) { sdata[tid] = mySum = mySum + sdata[tid + 256]; } __syncthreads(); }
if (blockDim.x >= 256) { if (tid < 128) { sdata[tid] = mySum = mySum + sdata[tid + 128]; } __syncthreads(); }
if (blockDim.x >= 128) { if (tid < 64) { sdata[tid] = mySum = mySum + sdata[tid + 64]; } __syncthreads(); }
if (tid < 32)
{
volatile float* smem = sdata;
if (blockDim.x >= 64) { smem[tid] = mySum = mySum + smem[tid + 32]; }
if (blockDim.x >= 32) { smem[tid] = mySum = mySum + smem[tid + 16]; }
if (blockDim.x >= 16) { smem[tid] = mySum = mySum + smem[tid + 8]; }
if (blockDim.x >= 8) { smem[tid] = mySum = mySum + smem[tid + 4]; }
if (blockDim.x >= 4) { smem[tid] = mySum = mySum + smem[tid + 2]; }
if (blockDim.x >= 2) { smem[tid] = mySum = mySum + smem[tid + 1]; }
}
if (tid == 0)
g_odata[blockIdx.x] = sdata[0];
}
我安装了 nvidia 460 gtx gpu 和 cuda 驱动程序和工具包。