Preprocessor Directives and Macros

Preprocessor Directives and Macros.

# pragma pp-tokensopt new-line

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:

          #pragma OPENCL FP_CONTRACT on-off-switch
               on-off-switch: one of ON OFF DEFAULT
          #pragma OPENCL EXTENSION extensionname : behavior
          #pragma OPENCL EXTENSION 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 100.
  • __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.
  • __ROUNDING_MODE__ is used to determine the current rounding mode and is set to rte. The __ROUNDING_MODE__ only affects the rounding mode of conversions to a float type. __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.
  • __FAST_RELAXED_MATH__ is used to determine if the cl-fast-relaxed-math optimization option is specified in build options given to clBuildProgram. 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.

Specification

OpenCL Specification

Also see

clBuildProgram, FP_CONTRACT, EXTENSION

Copyright © 2007-2009 The Khronos Group Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.