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