Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Cannot use math functions

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    6

    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!

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Cannot use math functions

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

    Could you post the build log you get? You can query it with clGetProgramBuildInfo.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    6

    Re: Cannot use math functions

    ok i managed to use the sqrt()
    the problem is with the
    Code :
    cos( (float) x)

    Code :
    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!

  4. #4
    Junior Member
    Join Date
    Nov 2010
    Posts
    6

    Re: Cannot use math functions

    *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.

  5. #5
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Cannot use math functions

    That is definitely a bug in the compiler. I suggest posting this in the vendor's customer support system/forum.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  6. #6
    Junior Member
    Join Date
    Nov 2010
    Posts
    6

    Re: Cannot use math functions

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

  7. #7
    Junior Member
    Join Date
    Dec 2010
    Posts
    3

    Re: Cannot use math functions

    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:
    Code :
    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

  8. #8
    Junior Member
    Join Date
    Nov 2010
    Posts
    6

    Re: Cannot use math functions

    Quote Originally Posted by deklerkmc
    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:
    Code :
    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!

  9. #9
    Junior Member
    Join Date
    Dec 2010
    Posts
    3

    Re: Cannot use math functions

    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...

  10. #10
    Junior Member
    Join Date
    Nov 2010
    Posts
    6

    Re: Cannot use math functions

    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

Page 1 of 2 12 LastLast

Similar Threads

  1. how to use math.h functions in __kernel
    By sayush in forum OpenCL
    Replies: 2
    Last Post: 12-02-2009, 05:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •