OpenCL:对内置函数的调用不明确
OpenCL: call to a built-in function is ambiguous
我有一段来自 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: 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
fmod() 是一个已重载的内置函数。我知道两个输入的类型应该是一样的。谁能告诉我这是怎么回事?
您正在使用两个 uint
参数调用 fmod
。此函数具有 float
和 double
参数的重载,因此编译器无法推断您希望使用哪个重载(因此出现关于函数调用不明确的错误)。
您可以通过将参数转换为您想要使用的类型来明确您的意图:
idy_p = fmod((float)(idz*size_sino.y+idy), (float)16.f);
我有一段来自 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: 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
fmod() 是一个已重载的内置函数。我知道两个输入的类型应该是一样的。谁能告诉我这是怎么回事?
您正在使用两个 uint
参数调用 fmod
。此函数具有 float
和 double
参数的重载,因此编译器无法推断您希望使用哪个重载(因此出现关于函数调用不明确的错误)。
您可以通过将参数转换为您想要使用的类型来明确您的意图:
idy_p = fmod((float)(idz*size_sino.y+idy), (float)16.f);