logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Preprocessor_Directives_and_Macros - Preprocessor Directives and Macros.

Authors

TheKhronosGroup

Description

       The preprocessing directives defined by the C99 specification are supported.

       A #pragma directive where the preprocessing token OPENCL (used instead of STDC) does not immediately
       follow pragma in the directive (prior to any macro replacement) causes the implementation to behave in an
       implementation-defined manner. The behavior might cause translation to fail or cause the translator or
       the resulting program to behave in a non-conforming manner. Any such pragma that is not recognized by the
       implementation is ignored. If the preprocessing token OPENCL does immediately follow pragma in the
       directive (prior to any macro replacement), then no macro replacement is performed on the directive, and
       the directive shall have one of the following forms whose meanings are described elsewhere:

                     #pragmaOPENCLFP_CONTRACT(3clc) on-off-switchon-off-switch:oneofONOFFDEFAULT#pragmaOPENCLEXTENSION(3clc) extensionname:behavior#pragmaOPENCLEXTENSION(3clc) all:behavior

       The following predefined macro names are available.

       •   __FILE__ The presumed name of the current source file (a character string literal).

       •   __LINE__ The presumed line number (within the current source file) of the current source line (an
           integer constant).

       •   __OPENCL_VERSION__ substitutes an integer reflecting the version number of the OpenCL supported by
           the OpenCL device. The version of OpenCL described in this document will have __OPENCL_VERSION__
           substitute the integer 120.

       •   CL_VERSION_1_0 substitutes the integer 100 reflecting the OpenCL 1.0 version.

       •   CL_VERSION_1_1 substitutes the integer 110 reflecting the OpenCL 1.1 version.

       •   CL_VERSION_1_2 substitutes the integer 120 reflecting the OpenCL 1.2 version.

       •   __OPENCL_C_VERSION__ substitutes an integer reflecting the OpenCL C version specified by the -cl-std
           build option  to clBuildProgram(3clc) or clCompileProgram(3clc). If the -cl-std build option is not
           specified, the OpenCL C version supported by the compiler for this OpenCL device will be used. The
           version of OpenCL C described in this document will have __OPENCL_C_VERSION__ substitute the integer
           120.

       •   __ENDIAN_LITTLE__ is used to determine if the OpenCL device is a little endian architecture or a big
           endian architecture (an integer constant of 1 if device is little endian and is undefined otherwise).
           Also refer to CL_DEVICE_ENDIAN_LITTLE specified in the table of OpenCL Device Queries for
           clGetDeviceInfo(3clc).

       •   __kernel_exec(X, typen) (and kernel_exec(X, typen)) is defined as follows:

               __kernel __attribute__((work_group_size_hint(X, 1, 1))) \
               __attribute__((vec_type_hint(typen)))

       •   __IMAGE_SUPPORT__ is used to determine if the OpenCL device supports images. This is an integer
           constant of 1 if images are supported and is undefined otherwise. Also refer to
           CL_DEVICE_IMAGE_SUPPORT specified in the table of OpenCL Device Queries for clGetDeviceInfo(3clc).

       •   __FAST_RELAXED_MATH__ is used to determine if the cl-fast-relaxed-math optimization option is
           specified in build options given to  clBuildProgram(3clc) or clCompileProgram(3clc). This is an
           integer constant of 1 if the cl-fast-relaxed-math build option is specified and is undefined
           otherwise.

       •    The macro names defined by the C99 specification but not currently supported by OpenCL are reserved
           for future use.

       •   __EMBEDDED_PROFILE__ will be the integer constant 1 for OpenCL devices that implement the embedded
           profile and is undefined otherwise. CL_PLATFORM_PROFILE defined in table 4.1 (see
           clGetPlatformInfo(3clc)) will return the string EMBEDDED_PROFILE if the OpenCL implementation
           supports the embedded profile only.

Name

       Preprocessor_Directives_and_Macros - Preprocessor Directives and Macros.

       # pragmapp-tokens<sub>opt</sub> new-line

Notes

        1. OpenCL Specification
           page 234, section 6.10 - Preprocessor Directives and Macros

The Khronos Group                                  11/18/2024                         PREPROCESSORDIRECTI(3clc)

See Also

mathConstants(3clc) clBuildProgram(3clc), FP_CONTRACT(3clc), EXTENSION(3clc)

Specification

OpenCLSpecification[1]

See Also