javaopencljocl

Call to pow is ambiguous


While working with JOCl (java version opencl), I came across this error.

Exception in thread "main" org.jocl.CLException: CL_BUILD_PROGRAM_FAILURE
Build log for device 0:
<program source>:3:255: error: **call to '__cl_pow' is ambiguous**
__kernel void sampleKernel(__global short *x,             __global short *y,           __global uint *stop,           __global uint *moment){private uint a = 1;private uint b = 2;for(uint i =0; i<= 100;i++){ for(uint j = stop[i]; j < stop[i+1]; j++){    pow(a,b)      }  }}

My kernel code :

  private static String programSource =
            "__kernel void "
            + "sampleKernel(__global short *x,"
            + "             __global short *y,"
            + "           __global uint *stop,"
            + "           __global uint *moment)"
            + "{"
            + "for(uint i =0; i<= 100;i++){"
            + " for(uint j = stop[i]; j < stop[i+1]; j++){"
            + "    moment[i] = moment[i] + (pow(x[j],0)*pow(y[j],0))  "
            + "     }"
            + "  }"
            + "}";

I thought it was because of the datatype of x and y. But when I do a simple pow(1,1), it results in the same error.

How can I fix this?


Solution

  • Just a guess :

    there is no overload of pow for integral types so the compiler will try to find the closest match amongst all the available overloads :

    But as a short is convertible to a float as well as a double it doesn't find a single overload to use, hence the error.

    To check this hypothese try to explicit the conversion you want to use with a cast :

    (pow((float)x[j],0)*pow((float)y[j],0))