Description
The FP_CONTRACT pragma can be used to allow (if the state is on) or
disallow (if the state is off) the implementation to contract expressions.
Each pragma can occur either outside external declarations or preceding all
explicit declarations and statements inside a compound statement.
When outside external declarations, the pragma takes effect from its
occurrence until another FP_CONTRACT pragma is encountered, or until the
end of the translation unit.
When inside a compound statement, the pragma takes effect from its
occurrence until another FP_CONTRACT 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.
If this pragma is used in any other context, the behavior is undefined.
The pragma definition to set FP_CONTRACT is:
// on-off-switch is one of ON, OFF, or DEFAULT.
// The DEFAULT value is ON.
#pragma OPENCL FP_CONTRACT on-off-switch
The FP_FAST_FMAF macro indicates whether the fma function is fast
compared with direct code for single precision floating-point.
If defined, the FP_FAST_FMAF macro shall indicate that the fma function
generally executes about as fast as, or faster than, a multiply and an add
of float operands.
The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in #if preprocessing
directives.
#define FLT_DIG 6
#define FLT_MANT_DIG 24
#define FLT_MAX_10_EXP +38
#define FLT_MAX_EXP +128
#define FLT_MIN_10_EXP -37
#define FLT_MIN_EXP -125
#define FLT_RADIX 2
#define FLT_MAX 0x1.fffffep127f
#define FLT_MIN 0x1.0p-126f
#define FLT_EPSILON 0x1.0p-23f
The following table describes the built-in macro names given above in the OpenCL C programming language and the corresponding macro names available to the application.
| Macro in OpenCL Language | Macro for application |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following macros shall expand to integer constant expressions whose
values are returned by ilogb(x) if x is zero or NaN, respectively.
The value of FP_ILOGB0 shall be either INT_MIN or -INT_MAX.
The value of FP_ILOGBNAN shall be either INT_MAX or INT_MIN.
The following constants are also available.
They are of type float and are accurate within the precision of the
float type.
| Constant | Description |
|---|---|
|
Value of e |
|
Value of log2e |
|
Value of log10e |
|
Value of loge2 |
|
Value of loge10 |
|
Value of π |
|
Value of π / 2 |
|
Value of π / 4 |
|
Value of 1 / π |
|
Value of 2 / π |
|
Value of 2 / √π |
|
Value of √2 |
|
Value of 1 / √2 |
If double-precision is supported by the device, then the following macros and constants are also available:
The FP_FAST_FMA macro indicates whether the fma() family of functions
are fast compared with direct code for double-precision floating-point.
If defined, the FP_FAST_FMA macro shall indicate that the fma() function
generally executes about as fast as, or faster than, a multiply and an add
of double operands
The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in #if preprocessing
directives.
#define DBL_DIG 15
#define DBL_MANT_DIG 53
#define DBL_MAX_10_EXP +308
#define DBL_MAX_EXP +1024
#define DBL_MIN_10_EXP -307
#define DBL_MIN_EXP -1021
#define DBL_MAX 0x1.fffffffffffffp1023
#define DBL_MIN 0x1.0p-1022
#define DBL_EPSILON 0x1.0p-52
The following table describes the built-in macro names given above in the OpenCL C programming language and the corresponding macro names available to the application.
| Macro in OpenCL Language | Macro for application |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following constants are also available.
They are of type double and are accurate within the precision of the
double type.
| Constant | Description |
|---|---|
|
Value of e |
|
Value of log2e |
|
Value of log10e |
|
Value of loge2 |
|
Value of loge10 |
|
Value of π |
|
Value of π / 2 |
|
Value of π / 4 |
|
Value of 1 / π |
|
Value of 2 / π |
|
Value of 2 / √π |
|
Value of √2 |
|
Value of 1 / √2 |
If the cl_khr_ extension macro is supported, then the following
macros and constants are also available:
The FP_FAST_FMA_HALF macro indicates whether the fma() family of
functions are fast compared with direct code for half-precision
floating-point.
If defined, the FP_FAST_FMA_HALF macro shall indicate that the fma()
function generally executes about as fast as, or faster than, a multiply and
an add of half operands.
The macro names given in the following list must use the values specified. These constant expressions are suitable for use in #if preprocessing directives.
#define HALF_DIG 3
#define HALF_MANT_DIG 11
#define HALF_MAX_10_EXP +4
#define HALF_MAX_EXP +16
#define HALF_MIN_10_EXP -4
#define HALF_MIN_EXP -13
#define HALF_RADIX 2
#define HALF_MAX 0x1.ffcp15h
#define HALF_MIN 0x1.0p-14h
#define HALF_EPSILON 0x1.0p-10h
The following table describes the built-in macro names given above in the OpenCL C programming language and the corresponding macro names available to the application.
| Macro in OpenCL Language | Macro for application |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following constants are also available.
They are of type half and are accurate within the precision of the half
type.
| Constant | Description |
|---|---|
|
Value of e |
|
Value of log2e |
|
Value of log10e |
|
Value of loge2 |
|
Value of loge10 |
|
Value of π |
|
Value of π / 2 |
|
Value of π / 4 |
|
Value of 1 / π |
|
Value of 2 / π |
|
Value of 2 / √π |
|
Value of √2 |
|
Value of 1 / √2 |
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.