Description
If the cl_khr_ extension macro is supported, the
floating-point rounding mode may be specified using the following #pragma
in the OpenCL program source:
#pragma OPENCL SELECT_ROUNDING_MODE <rounding-mode>
The <rounding-mode> may be one of the following values:
-
rte - round to nearest even
-
rtz - round to zero
-
rtp - round to positive infinity
-
rtn - round to negative infinity
If this extensions is supported then the OpenCL implementation must support all four rounding modes for single precision floating-point.
The #pragma sets the rounding mode for all instructions that operate on floating-point types (scalar or vector types) or produce floating-point values that follow this pragma in the program source until the next #pragma. Note that the rounding mode specified for a block of code is known at compile time. When inside a compound statement, the pragma takes effect from its occurrence until another #pragma is encountered (including within a nested compound statement), or until the end of the compound statement; at the end of a compound statement the state for the pragma is restored to its condition just before the compound statement. Except where otherwise documented, the callee functions do not inherit the rounding mode of the caller function.
If the cl_khr_ extension is enabled, the
__ROUNDING_MODE__ preprocessor symbol shall be defined to be one of the
following according to the current rounding mode:
#define __ROUNDING_MODE__ rte
#define __ROUNDING_MODE__ rtz
#define __ROUNDING_MODE__ rtp
#define __ROUNDING_MODE__ rtz
This is intended to enable remapping foo() to foo_rte() by the
preprocessor by using:
#define foo foo ## __ROUNDING_MODE__
The default rounding mode is round to nearest even.
The Math Functions, Common
Functions, and Geometric Functions are
implemented with the round to nearest even rounding mode.
Various built-in conversions and the vstore_half and vstorea_half
built-in functions that do not specify a rounding mode inherit the current
rounding mode.
Conversions from floating-point to integer type always use rtz mode,
except where the user specifically asks for another rounding mode.
The cl_khr_ extension was deprecated in
OpenCL 1.1, and its use is not recommended.
|
Document Notes
For more information, see the OpenCL C Specification
This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.