580
社区成员
发帖
与我相关
我的任务
分享
cudaMalloc((unsigned char **)&dev_bdecoded, CodeLength * sizeof(unsigned char));
cudaMalloc((int **)&dev_jc, (n + 1) * sizeof(int));
cudaMalloc((double **)&dev_LLR_extrinsic, nzmax * sizeof(double));
cudaMalloc((double **)&dev_LLR_intrinsic, CodeLength * sizeof(double));
cudaMemcpy(dev_bdecoded, bdecoded, CodeLength * sizeof(unsigned char), cudaMemcpyHostToDevice);
cudaMemcpy(dev_jc, jc, (n + 1) * sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dev_LLR_intrinsic, LLR_intrinsic, CodeLength * sizeof(double), cudaMemcpyHostToDevice);
threadsPerBlock = 256;
blocksPerGrid = (n + threadsPerBlock - 1) / threadsPerBlock;
Kernel1<<<blocksPerGrid,threadsPerBlock>>>(dev_bdecoded, dev_jc, dev_LLR_extrinsic, dev_LLR_intrinsic);
cudaStatus = cudaDeviceSynchronize();
if (cudaStatus != cudaSuccess) {
fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
}
__global__ void Kernel1(unsigned char *dev_bdecoded, int *dev_jc, double *dev_LLR_extrinsic, double *dev_LLR_intrinsic)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
int j;
dev_bdecoded[i] = 0;
for (j = dev_jc[i]; j < dev_jc[i + 1]; j++)
dev_LLR_extrinsic[j] = dev_LLR_intrinsic[i];
}
/**
* The device encountered a load or store instruction on an invalid memory address.
* The context cannot be used, so it must be destroyed (and a new one should be created).
* All existing device memory allocations from this context are invalid
* and must be reconstructed if the program is to continue using CUDA.
*/
cudaErrorIllegalAddress = 77,
cudaMalloc((void **)&dev_jc, (n + 1) * sizeof(int));
这样子改的