OpenCL编程bug

OpenCL编程,平台是intel

1.错误提示“clCreateCommandQueue 被声明为已否决”

解决:http://bbs.youkuaiyun.com/topics/390912116

即:在程序中加一句#pragma warning( disable : 4996 )

2.错误提示:parameter may not be qualified with an address space

内核函数:__kernel void predict_next_value(__global float* express_table,__global int t)

编译程序的代码:err = clBuildProgram(program, 1, &device,NULL, NULL, NULL);//编译程序
if (err < 0){
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
program_log = (char*)malloc(log_size + 1);//确定生成日志的大小
program_log[log_size] = '\0';
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, log_size + 1, program_log, NULL);//读取日志
printf("%s\n",program_log);
free(program_log);
//exit(0);
}

在编译程序时,提示parameter may not be qualified with an address space

问题出现在:__global int t  需要用指针来传递,将其改为__global int *t


3.错误提示:illegal implicit conversion between two pointers with different address spaces

出现此问题的例子:在同一个内核文件里有有一个普通函数和内核函数

普通函数:float environment_effect(int i, int *t,  float* tran_par_table)

内核函数:__kernel void tran_to_place_rate(__global int *t,__global float* tran_par_table

解决办法:普通函数变为:float environment_effect(int i, __global int *t,__global float* tran_par_table)  

即与内核函数相同的指针变量要类型一致,不同类型的转换时非法的。

4.内核参数传递:指针

内核函数的传递不能使用数据结构class或struct来传递,即不存在多层的嵌套,但可以在显卡内创建一维数组缓存,然后将主机数据复制到缓存中,这样进行参数传递。

内核文件中除了内核函数,还可以包括宏定义与普通函数。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值