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

FLT_DIG

CL_FLT_DIG

FLT_MANT_DIG

CL_FLT_MANT_DIG

FLT_MAX_10_EXP

CL_FLT_MAX_10_EXP

FLT_MAX_EXP

CL_FLT_MAX_EXP

FLT_MIN_10_EXP

CL_FLT_MIN_10_EXP

FLT_MIN_EXP

CL_FLT_MIN_EXP

FLT_RADIX

CL_FLT_RADIX

FLT_MAX

CL_FLT_MAX

FLT_MIN

CL_FLT_MIN

FLT_EPSILSON

CL_FLT_EPSILON

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

M_E_F

Value of e

M_LOG2E_F

Value of log2e

M_LOG10E_F

Value of log10e

M_LN2_F

Value of loge2

M_LN10_F

Value of loge10

M_PI_F

Value of π

M_PI_2_F

Value of π / 2

M_PI_4_F

Value of π / 4

M_1_PI_F

Value of 1 / π

M_2_PI_F

Value of 2 / π

M_2_SQRTPI_F

Value of 2 / √π

M_SQRT2_F

Value of √2

M_SQRT1_2_F

Value of 1 / √2

If double precision is supported by the device, 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

DBL_DIG

CL_DBL_DIG

DBL_MANT_DIG

CL_DBL_MANT_DIG

DBL_MAX_10_EXP

CL_DBL_MAX_10_EXP

DBL_MAX_EXP

CL_DBL_MAX_EXP

DBL_MIN_10_EXP

CL_DBL_MIN_10_EXP

DBL_MIN_EXP

CL_DBL_MIN_EXP

DBL_MAX

CL_DBL_MAX

DBL_MIN

CL_DBL_MIN

DBL_EPSILSON

CL_DBL_EPSILON

The following constants are also available. They are of type double and are accurate within the precision of the double type.

Constant

Description

M_E

Value of e

M_LOG2E

Value of log2e

M_LOG10E

Value of log10e

M_LN2

Value of loge2

M_LN10

Value of loge10

M_PI

Value of π

M_PI_2

Value of π / 2

M_PI_4

Value of π / 4

M_1_PI

Value of 1 / π

M_2_PI

Value of 2 / π

M_2_SQRTPI

Value of 2 / √π

M_SQRT2

Value of √2

M_SQRT1_2

Value of 1 / √2

See Also

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.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.