cudaMallocHost 编译错误, 请帮忙看看
// Define the # of computational elements.
#define M 5001
#define N 5001
#define SIZE M*N
// Define the # of threads in each block.
#define threadX 16
#define threadY 32
#define threadZ 0
// Define the # of block in each grid.
#define blockX (M+threadX-1)/(threadX)
#define blockY (N+threadY-1)/(threadY)
#define blockZ 0
int main() {
float *a_h = NULL, *b_h = NULL, *c_h = NULL;
unsigned int MemSize;
MemSize = SIZE * sizeof(float);
// allocate array on host
39: cudaMallocHost (void(**)&a_h, MemSize);
40: cudaMallocHost (void(**)&b_h, MemSize);
41: cudaMallocHost (void(**)&c_h, MemSize);
以下省略
}
编译:
nvcc array.cu -c
array.cu(39): error: expected an expression
array.cu(39): error: expression must have integral or enum type
array.cu(39): error: expression must have integral or enum type
array.cu(40): error: expected an expression
array.cu(40): error: expression must have integral or enum type
array.cu(40): error: expression must have integral or enum type
array.cu(41): error: expected an expression
array.cu(41): error: expression must have integral or enum type
array.cu(41): error: expression must have integral or enum type
如果把cudaMallocHost换成malloc就没有问题。
请大家帮看下,谢谢。