external function?

I am consistently getting this error while trying to build from source on NVIDIA GPUs. It built fine on CPU though, haven’t tried other devices yet:

kernel referenced an external function exp, that could not be found.

This is the line in my .cl source that uses exp

rc_n2o5 = 1./ ( 3.6e4 * exp( -pow((rh/0.28),2.8) + 300. ));

What else could have gone wrong? I’m pretty sure exp is in the spec



ok… i replaced my code with the following line and it works now. But shouldn’t it work without the casts? Sorry I’m still relatively new to OpenCL C

rc_n2o5 = 1./ ( 3.6e4 * exp( -pow((float)(rh/0.28),2.8f) + 300.f ));



-pow((rh/0.28),2.8) + 300.

These are using double precision values for 0.28, 2.8 and 300. Double precision is only enabled if the cl_khr_fp64 extension is supported by the implementation and including a #pragma cl_khr_fp64 : enable in your kernel source. The change you made to append “f” or cast to a float was the right thing to do. On HW that does support double precision, you would have called a double precision pow which may be slower than single precision pow.