Results 1 to 5 of 5

Thread: Double precision floats and built in math functions?

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    2

    Double precision floats and built in math functions?

    Hi

    I'm trying to do computations with double precision floats. I have figured out how to enable them - but the code will not compile if I try to use any of the built in math functions on these variables :S

    See below code for an example:

    #pragma OPENCL EXTENSION cl_khr_fp64 : enable
    kernel void TestAll(global write_only double* a)
    {
    int index = get_global_id(0);
    double x, y;
    x = trunc(index / pow(4, 2));
    y = trunc(index / 4) - (x * 4);
    a[index] = hypot(x, y);
    }

    If anyone could tell me how to fix / get round this issue I would be most gratefull.

    Thank you!

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

    Re: Double precision floats and built in math functions?

    It is always useful if you tell us which OpenCL implementation are you using. Apple/AMD/NVidia?

    Also, could you post the build error log?
    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
    Jun 2010
    Posts
    2

    Re: Double precision floats and built in math functions?

    Hi,

    Sorry. I am running on an ATI HD5870.

    When I try compile this code in Stream KernelAnalyzer 1.5, I get:

    OpenCL Compile Error: clBuildProgram failed (CL_BUILD_PROGRAM_FAILURE).

    Error: Undeclared function index 1207

    In my app it compiles but as soon as the application executes the kernel it crashes.

    Thanks!

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

    Re: Double precision floats and built in math functions?

    That's pretty clearly a bug (Captain Obvious to the rescue!). I suggest contacting customer support from that vendor.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  5. #5

    Re: Double precision floats and built in math functions?

    Not a bug. You are using pow function wrongly. From the spec:

    gentype pow (gentype x, gentype y)
    gentype pown (gentype x, intn y)

    See what's wrong? You have pow(4, 2) where you should have pown(4, 2) since 2 is an integer and not a gentype.

Similar Threads

  1. Built-in Functions: Work-Item Functions
    By sean.settle in forum Suggestions for next release
    Replies: 7
    Last Post: 11-17-2011, 07:39 AM
  2. double precision math builtins on OSX
    By jhludwig in forum OpenCL
    Replies: 4
    Last Post: 05-02-2011, 03:33 PM

Posting Permissions

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