Cannot use math functions

Hello I am compiling OpenCl kernel under X64 visual studio and for some reason i get an error when i have a function like sqrt() inside the kernel. Am i doing something wrong?
I thought these functions were included…
thanks!

Yes, sqrt() should work out of the box.

Could you post the build log you get? You can query it with clGetProgramBuildInfo.

ok i managed to use the sqrt()
the problem is with the

cos( (float) x)
Build Log:
ptxas application ptx input, line 519; error   : Label expected for argument 0 of instruction 'call'
ptxas application ptx input, line 519; error   : Call target not recognized
ptxas application ptx input, line 519; error   : Function '_Z3cosf' not declared in this scope
ptxas application ptx input, line 519; error   : Call target not recognized
ptxas application ptx input, line 520; error   : Unknown symbol '_Z3cosf'

any suggestions? thanks for the help!

*acos((float) x)

when it runs inside the kernel everything works fine when i put it inside a function that the kernel calls i get this log.

That is definitely a bug in the compiler. I suggest posting this in the vendor’s customer support system/forum.

Solved the whole problem was that my kernel function was before the other functions inside the .cl file.
Thanks for the help although!

Hi iassael, I’m having the exact same problem and pulling my hair out…

I’m trying to use cos inside a kernel function and getting:

ptxas application ptx input, line 712; error   : Label expected for argument 0 of instruction 'call'
ptxas application ptx input, line 712; error   : Call target not recognized
ptxas application ptx input, line 712; error   : Function '_Z3cosf' not declared in this scope
ptxas application ptx input, line 712; error   : Call target not recognized
ptxas application ptx input, line 713; error   : Unknown symbol '_Z3cosf'

Can you please tell me what you did to get the sqrt() function to work inside your kernel function?

thanks for any help;)

SOLVED!
Thank you all!

uh, I was actually hoping you’d be able to help me out with an answer? there’s absolutely nothing else about this on the net…

ok the whole problem was that i had the kernel function on top and then the others. while the right way is to have all the other functions on top and then the kernel :wink:

oh right, so the actual problem was the cos, NOT the sqrt…
Bummer for me though, I’m getting that error although the cos is used inside the kernel only…

cool, thanks for you help…