Results 1 to 4 of 4

Thread: pow(float4,float)

Hybrid View

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    5

    pow(float4,float)

    Hello,

    This code will compile fine on some systems but not on others:

    float4 a;
    // ...
    float4 b = pow( a, 2.0f );

    The documentation says that the arguments have to be the same type, so I assume some systems are capable of implicitly widening the float to a float4?
    http://www.khronos.org/registry/cl/s...xhtml/pow.html

    Other functions have more flexibility in their inputs, e.g.
    http://www.khronos.org/registry/cl/s...tml/clamp.html
    So pow does look a bit inconsistent. Should this change?

    Thanks,

    Tim

  2. #2
    Junior Member
    Join Date
    Jul 2011
    Location
    Bristol, UK
    Posts
    19
    Hi Tim,

    There is indeed a gap in the current specification regarding implicit conversions from scalar to vector types, which results in undefined compiler behaviour for builtin functions. This has been addressed in OpenCL 2.0.

    Best wishes,

    James

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    5
    Ah, it's good to know that this issue has been fixed in 2.0 - thankyou.

    Tim

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Posts
    170
    The work-around is to do this:

    float4 b = pow( a, (float4)2.0f );

Tags for this Thread

Posting Permissions

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