Results 1 to 5 of 5

Thread: Selecting rounding mode CL_FP_ROUND_TO_ZERO

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    3

    Selecting rounding mode CL_FP_ROUND_TO_ZERO

    In the documentation, I can check with cl_device_fp_config that rounding to zero is supported or not (CL_FP_ROUND_TO_ZERO), but how can I set this rounding mode inside the kernel program (.cl), for the +, *, -, /, operations on floats?

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    153

    Re: Selecting rounding mode CL_FP_ROUND_TO_ZERO

    OpenCL isn't modal with rounding; you select the rounding method by what API you use.

    Investigate "6.2.3.2 Rounding Modes" in the specification.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    3

    Re: Selecting rounding mode CL_FP_ROUND_TO_ZERO

    I have seen this chapter in the specification. But it only talks about rounding mode in conversion functions, not rounding mode for arithmetic operations.
    Does it exist an equivalent of convert_int4_rte for addition / multiplication?
    Something like c = add_float_rtz(a,b);
    ?
    Or does the CL_FP_ROUND_TO_ZERO information from cl_device_fp_config applies only for the conversion functions?

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Posts
    153

    Re: Selecting rounding mode CL_FP_ROUND_TO_ZERO

    Oh, I see, you're talking about rounding in the LSB of the float value, not rounding to integer.

    Section "7.1 Rounding Modes" says that round to nearest even is the only mode required and there is no way to change it.

    It's interesting that there is a way to query device capabilities (using "CL_DEVICE_SINGLE_FP_CONFIG"), but not set them.

    However, looking at Appendix "F.1 Summary of changes from OpenCL 1.0" I see there used to be a __ROUNDING_MODE__ macro in OpenCL 1.0 that is no longer supported in OpenCL C 1.1.

    Since many of the math functions only guarantee a certain number of ULP (see "7.4 Relative Error as ULPs"), rounding of the last bit is less of a problem than outright accuracy, depending on which functions you are using.

    What is the value of something other than RTE? The only use I can think of is to run equations two times, once rounding up and once rounding down, in order to calculate error bounds. But should that be done as part of the calculation itself, or should you just keep track of the precision in your algorithm and know from that the accuracy of your answers?

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    3

    Re: Selecting rounding mode CL_FP_ROUND_TO_ZERO

    I have found https://www.khronos.org/registry/cl/sdk ... _MODE.html
    from OpenCL 1.0. I can't find it in the newest OpenCL specification.

    The log of OpenCL 1.1 made the disappearance of the __ROUNDING_MODE__ macro clear but nothing is said about the pragma (#pragma OPENCL SELECT_ROUNDING_MODE rtz) which is the most important thing in this context.

    Rounding modes like rounding to zero or to infinity are indeed useful in interval arithmetics or in the computation of the error bound itself (since you need a real upper bound, and not an approximation of the error bound), or other things.

Similar Threads

  1. The support of out-of-order mode ?
    By zhaopeng in forum OpenCL
    Replies: 4
    Last Post: 09-26-2012, 11:27 AM
  2. Rounding floats
    By Siassei in forum OpenCL
    Replies: 1
    Last Post: 05-13-2011, 03:33 PM
  3. Help in Image Multiply Mode
    By mkarthik293 in forum OpenVG and VGU
    Replies: 0
    Last Post: 07-16-2008, 11:39 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
  •