Results 1 to 2 of 2

Thread: How to define a function that processes N-vectors ?

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    16

    How to define a function that processes N-vectors ?

    Is there a way to define a new OpenCL function that processes N-vectors, for various N, like the built-in math functions?

    For example, if overloading were supported:
    float square(float x) { return x * x; }
    float2 square(float2 x) { return x * x; }
    float4 square(float4 x) { return x * x; }
    but overloading doesn't seem to be allowed (?)

    It could be done via a macro:
    #define square(x) ((x)*(x))
    but in this case, x may be evaluated twice, so it is not the solution I'd like...

    Thanks for any suggestions!

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: How to define a function that processes N-vectors ?

    Not that I'm aware of. OpenCL's kernel language is based on C99 which does not support overloading.

Similar Threads

  1. Replies: 3
    Last Post: 09-16-2012, 11:17 AM
  2. Replies: 1
    Last Post: 09-17-2009, 07:27 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
  •