0
我与CUDA编程的C.我的代码行分段错误如下:CUDA分段错误
int width = 0;
int height = 0;
// load input image
unsigned char * image_input = loadFile(&width, &height, "test.bmp");
// allocate memory for output
unsigned char * image_output = (unsigned char *) malloc(width*height*sizeof(unsigned char));
// set the size of the input and out array 2D
int size = width*height*sizeof(int);
// Allocate space on the GPU for input and output
char* GPU_input = 0;
char* GPU_output = 0;
cudaMalloc(&GPU_input, size);
cudaMalloc(&GPU_output, size);
// Copy the input data to the GPU (host to device)
cudaMemcpy(GPU_input, image_input, size, cudaMemcpyHostToDevice); //segmentation fault here
任何想法?
在此先感谢。
嗨wildplasser,那么我应该改变什么?我不清楚。谢谢! – olidev
我不知道你打算做什么。你有两种数组:一种由字符组成,另一种由数字组成。我不知道你的CUDA-thingy期望什么。 (但我怀疑整数) – wildplasser
是的,这是一个错误。我将它改为(char)的大小。解决了这个问题。谢谢! – olidev