OpenCL:对内置函数的调用不明确
我有一段来自openCL内核的代码OpenCL:对内置函数的调用不明确,c,opencl,C,Opencl,我有一段来自openCL内核的代码 const uint idz = 100; const uint idy = 100; unit4 size_sino; uint idz_p; uint idy_p; idz_p = (idz*size_sino.y+idy)/16; idy_p = fmod((idz*size_sino.y+idy), (uint)16); 编译内核时,发生了一些错误: :192:18: e
const uint idz = 100;
const uint idy = 100;
unit4 size_sino;
uint idz_p;
uint idy_p;
idz_p = (idz*size_sino.y+idy)/16;
idy_p = fmod((idz*size_sino.y+idy), (uint)16);
编译内核时,发生了一些错误:
:192:18: error: call to 'fmod' is ambiguous
<stdin>:1078:48: note: candidate function
<stdin>:1084:49: note: candidate function
<stdin>:1079:49: note: candidate function
<stdin>:1080:49: note: candidate function
<stdin>:1081:49: note: candidate function
<stdin>:1082:49: note: candidate function
<stdin>:1083:50: note: candidate function
<stdin>:1085:50: note: candidate function
<stdin>:1086:50: note: candidate function
<stdin>:1087:50: note: candidate function
<stdin>:1088:50: note: candidate function
<stdin>:1089:51: note: candidate function
:192:18:错误:对“fmod”的调用不明确
:1078:48:注意:候选函数
:1084:49:注:候选函数
:1079:49:注意:候选函数
:1080:49:注:候选函数
:1081:49:注:候选函数
:1082:49:注:候选函数
:1083:50:注:候选函数
:1085:50:注:候选函数
:1086:50:注:候选函数
:1087:50:注:候选函数
:1088:50:注:候选函数
:1089:51:注:候选函数
fmod()是一个已重载的内置函数。我理解两个输入的类型应该是相同的。有人能告诉我这里发生了什么吗?您正在用两个
uint
参数调用fmod
。此函数具有float
和double
参数的重载,因此编译器无法推断您希望使用哪个重载(因此出现了关于不明确函数调用的错误)
通过将参数强制转换为要使用的类型,可以明确您的意图:
idy_p = fmod((float)(idz*size_sino.y+idy), (float)16.f);
您可能应该提供更多的代码,例如fmod重载是如何声明的。
unit4
的类型是什么?它是浮点值还是整数?@zenith它是内置的OpenCLfunction@chmike这是一种向量复合物,由4个单位组成,大小为4@colddie我知道,我只是觉得没那么清楚。你可以把它的原型附在你的问题上,这样人们就不必到处搜索了。