OpenCL编程,平台是intel
1.错误提示“clCreateCommandQueue 被声明为已否决”
解决:http://bbs.csdn.net/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来传递,即不存在多层的嵌套,但可以在显卡内创建一维数组缓存,然后将主机数据复制到缓存中,这样进行参数传递。
内核文件中除了内核函数,还可以包括宏定义与普通函数。