cudaMallocHost 编译错误, 请帮忙看看

zalyer 2011-09-18 12:54:46
// 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就没有问题。
请大家帮看下,谢谢。

...全文
444 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zalyer 2011-09-19
  • 打赏
  • 举报
回复
顶起来,呵呵,大家帮忙看看
zalyer 2011-09-19
  • 打赏
  • 举报
回复
找到问题,汗死了

void(**) -> (void**)

374

社区成员

发帖
与我相关
我的任务
社区描述
CUDA on Linux
社区管理员
  • CUDA on Linux社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧