Compile exception: function acosf, sqrtf declared implicitly

Jul 27, 2015 at 1:29 PM

Whenever I try to run my application, I often get stuck with a Cudafy.CudafyCompileException, which seems to appear and dissapear at random. The Innerexception message always contains the same compilation Errors:

Cudafy.CudafyCompileException: Compilation error: "C:\TEMP\", line 244: error: function "acosf" declared implicitly
float num = acosf(nx) * 180.0f / 3.141593f;
"C:\TEMP\", line 935: error: function "sqrtf" declared implicitly
        float num11 = sqrtf((num7 - num9) * (num7 - num9) + (num8 - num10) * (num8 - num10));
There seems to be some weird issue with acosf and sqrtf, for which I haven't been able to find the cause.

I am currently using cudafy Version 1.29.

Any help would be appreciated.
Aug 2, 2015 at 8:35 AM
It's odd, since there's no sqrtf and acosf functions in the opencl 1.1 spec:

Could you show us the part of the cudafy code where you call those functions? Like:
var a = Math.Sqrt(b);
Aug 2, 2015 at 8:39 AM
Edited Aug 2, 2015 at 8:39 AM

Hi, you might want to include the following in the opencl header text:
#define sqrtf(x) sqrt(((float)x))                       
#define cosf(x) cos(((float)x))                         
#define sinf(x) sin(((float)x))                         
#define powf(x, y) pow(((float)x), ((float)y))          
#define fabsf(x) fabs(((float)x))                       
#define copysignf(x, y) copysign(((float)x), ((float)y))
#define cosf(x) cos(((float)x))                         
#define asinf(x) asin(((float)x))                       
#define acosf(x) acos(((float)x))                       
#define atanf(x) atan(((float)x))                       
#define tanf(x) tan(((float)x))                         
#define logf(x) log(((float)x))                         
#define floorf(x) floor(((float)x))                     
#define expf(x) exp(((float)x))                         
#define hypotf(x, y) hypot(((float)x), ((float)y))      
#define atan2f(x, y) atan2(((float)x), ((float)y))      
#define fmaxf(x, y) fmax(((float)x), ((float)y))        
#define fminf(x, y) fmin(((float)x), ((float)y))