Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCL: call to a built-in function is ambiguous

Tags:

c

opencl

I have a following piece of code which is from a openCL kernel.

     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);

When I compiled the kernel, some error happened:

     :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() is a built-in function which has been overloaded. I understand the type of the two inputs should be the same. Could anyone tell what's going on here?

like image 462
colddie Avatar asked Jan 29 '26 03:01

colddie


1 Answers

You are calling fmod with two uint arguments. This function has overloads for float and double arguments, and so the compiler cannot infer which overload you wish to use (hence the error about the ambiguous function call).

You can make your intentions explicit by casting the arguments to the type that you want to use:

idy_p = fmod((float)(idz*size_sino.y+idy), (float)16.f);
like image 135
jprice Avatar answered Jan 30 '26 20:01

jprice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!