PDA

View Full Version : external function?



anotherJohn
04-23-2010, 01:00 PM
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

Thanks!

-John

anotherJohn
04-23-2010, 03:31 PM
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 ));

Cheers,

John

affie
04-23-2010, 03:48 PM
-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.