OpenCL kernel 报错:Error in kernel: <kernel>:67:22: error: call to ‘mad24‘ is ambiguous

OpenCL Kernel代码mad24参数报错解决

        在opencl kernel 代码在编译完成后,运行的过程中报如下错误:

Error in kernel: 
<kernel>:67:22: error: call to 'mad24' is ambiguous
    int  tid = mad24(get_local_id(1), get_local_size(0), get_local_id(0));
                     ^~~~~
cl_kernel.h:3368:22: note: candidate function
int __OVERLOADABLE__ mad24(int, int, int);
                     ^
cl_kernel.h:3369:23: note: candidate function
uint __OVERLOADABLE__ mad24(uint, uint, uint);
                      ^
cl_kernel.h:3372:23: note: candidate function
int2 __OVERLOADABLE__ mad24(int2, int2, int2);
                      ^
cl_kernel.h:3374:23: note: candidate function
int3 __OVERLOADABLE__ mad24(int3, int3, int3);
                      ^
cl_kernel.h:3376:23: note: candidate function
int4 __OVERLOADABLE__ mad24(int4, int4, int4);
                      ^
cl_kernel.h:3377:23: note: candidate function
int8 __OVERLOADABLE__ mad24(int8, int8, int8);
                      ^
cl_kernel.h:3378:24: note: candidate function
int16 __OVERLOADABLE__ mad24(int16, int16, int16);
                       ^
cl_kernel.h:3380:24: note: candidate function
uint2 __OVERLOADABLE__ mad24(uint2, uint2, uint2);
                       ^
cl_kernel.h:3382:24: note: candidate function
uint3 __OVERLOADABLE__ mad24(uint3, uint3, uint3);
                       ^
cl_kernel.h:3384:24: note: candidate function
uint4 __OVERLOADABLE__ mad24(uint4, uint4, uint4);
                       ^
cl_kernel.h:3385:24: note: candidate function
uint8 __OVERLOADABLE__ mad24(uint8, uint8, uint8);
                       ^
cl_kernel.h:3386:25: note: candidate function
uint16 __OVERLOADABLE__ mad24(uint16, uint16, uint16);
                        ^

        找到kernel 代码中报错的对应行数查看代码如下:

int  tid = mad24(get_local_id(1), get_local_size(0), get_local_id(0));

        通过报错可以看到mad24的参数只接受int, unit, int2, int3, int4, int8, int16, int32, uint2, unit3, unit4, unit8,uint16。而函数get_local_id(1)、 get_local_size(0)、get_local_id(0)返回值均为size_t,在kernel 中size_t不能隐式转换为int.

cl_kernel.h:3368:22: note: candidate function
int __OVERLOADABLE__ mad24(int, int, int);
                     ^
cl_kernel.h:3369:23: note: candidate function
uint __OVERLOADABLE__ mad24(uint, uint, uint);
                      ^
cl_kernel.h:3372:23: note: candidate function
int2 __OVERLOADABLE__ mad24(int2, int2, int2);
                      ^
cl_kernel.h:3374:23: note: candidate function
int3 __OVERLOADABLE__ mad24(int3, int3, int3);
                      ^
cl_kernel.h:3376:23: note: candidate function
int4 __OVERLOADABLE__ mad24(int4, int4, int4);
                      ^
cl_kernel.h:3377:23: note: candidate function
int8 __OVERLOADABLE__ mad24(int8, int8, int8);
                      ^
cl_kernel.h:3378:24: note: candidate function
int16 __OVERLOADABLE__ mad24(int16, int16, int16);
                       ^
cl_kernel.h:3380:24: note: candidate function
uint2 __OVERLOADABLE__ mad24(uint2, uint2, uint2);
                       ^
cl_kernel.h:3382:24: note: candidate function
uint3 __OVERLOADABLE__ mad24(uint3, uint3, uint3);
                       ^
cl_kernel.h:3384:24: note: candidate function
uint4 __OVERLOADABLE__ mad24(uint4, uint4, uint4);
                       ^
cl_kernel.h:3385:24: note: candidate function
uint8 __OVERLOADABLE__ mad24(uint8, uint8, uint8);
                       ^
cl_kernel.h:3386:25: note: candidate function
uint16 __OVERLOADABLE__ mad24(uint16, uint16, uint16);

        所以将以上kernel 代码该为:


 int     tid = mad24((int)(get_local_id(1)), (int)(get_local_size(0)), (int)(get_local_id(0)));

再次编译运行后正常,大功告成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值