【发布时间】:2016-10-09 08:16:28
【问题描述】:
好的,我正在尝试在 gpu 上分配一个结构数组,但它崩溃了(给出停止工作的消息)。
这是结构:
typedef struct point_t {
int id;
float x, y;
} point;
这是 cuda 代码的一部分:
cudaError_t d_LoadPoints(point* points, int n , int chunkSize){
// Error code to check return values for CUDA calls
cudaError_t err = cudaSuccess;
int nBytes = n * sizeof(point);
// Allocate the device input points array
point* d_points;
err = cudaMalloc((void** )&d_points, nBytes);
if (err != cudaSuccess)
{
fprintf(stderr, "Failed to allocate device vector points (error code %s)!\n", cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
cudaMemcpy(d_points,points ,nBytes ,cudaMemcpyHostToDevice);
puts("memory allocated successfully");
}
我尝试打印 points 数组的第一个元素,以及 n 和 chunksize 并且结果正确。
这就是它似乎崩溃的地方(我禁用了其余部分)。 无论调试打印如何,它都会崩溃。
我唯一能想到的就是尺寸。
n 是 250,000,chunksize 是 64,000,我计划为 125 个块分配 512 个线程。
我不知道这是否是个好主意,但这是一个副话题,因为我什至无法到达内核调用。
【问题讨论】:
标签: cuda