'\" t .\" Title: Preprocessor Directives and Macros .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/14/2021 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "PREPROCESSOR DIRECTI" "3clc" "01/14/2021" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" Preprocessor_Directives_and_Macros \- Preprocessor Directives and Macros\&. .SS "" .TS tab(:); l. T{ # \fBpragma\fR \fIpp\-tokens\fRopt \fInew\-line\fR T} .TE .sp 1 .SH "DESCRIPTION" .PP The preprocessing directives defined by the C99 specification are supported\&. .PP A \fB# pragma\fR directive where the preprocessing token \fBOPENCL\fR (used instead of \fBSTDC\fR) does not immediately follow \fBpragma\fR 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 \fBpragma\fR that is not recognized by the implementation is ignored\&. If the preprocessing token \fBOPENCL\fR does immediately follow \fBpragma\fR 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: .PP .if n \{\ .RS 4 .\} .nf \fB #pragma OPENCL \fR\fB\fBFP_CONTRACT\fR(3clc)\fR\fB \fR\fB\fIon\-off\-switch\fR\fR\fB \fR\fB\fIon\-off\-switch\fR\fR\fB: one of ON OFF DEFAULT #pragma OPENCL \fR\fB\fBEXTENSION\fR(3clc)\fR\fB \fR\fB\fIextensionname : behavior\fR\fR\fB #pragma OPENCL \fR\fB\fBEXTENSION\fR(3clc)\fR\fB all : \fR\fB\fIbehavior\fR\fR .fi .if n \{\ .RE .\} .PP The following predefined macro names are available\&. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __FILE__ The presumed name of the current source file (a character string literal)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __LINE__ The presumed line number (within the current source file) of the current source line (an integer constant)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_VERSION_1_0 substitutes the integer 100 reflecting the OpenCL 1\&.0 version\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_VERSION_1_1 substitutes the integer 110 reflecting the OpenCL 1\&.1 version\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_VERSION_1_2 substitutes the integer 120 reflecting the OpenCL 1\&.2 version\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __OPENCL_C_VERSION__ substitutes an integer reflecting the OpenCL C version specified by the \-cl\-std build option to \fBclBuildProgram\fR(3clc) or \fBclCompileProgram\fR(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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __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 \fBCL_DEVICE_ENDIAN_LITTLE\fR specified in the table of OpenCL Device Queries for \fBclGetDeviceInfo\fR(3clc)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __kernel_exec(X, type\fIn\fR) (and kernel_exec(X, type\fIn\fR)) is defined as follows: .sp .if n \{\ .RS 4 .\} .nf __kernel __attribute__((work_group_size_hint(X, 1, 1))) \e __attribute__((vec_type_hint(type\fIn\fR))) .fi .if n \{\ .RE .\} .sp .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __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 \fBCL_DEVICE_IMAGE_SUPPORT\fR specified in the table of OpenCL Device Queries for \fBclGetDeviceInfo\fR(3clc)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __FAST_RELAXED_MATH__ is used to determine if the cl\-fast\-relaxed\-math optimization option is specified in build options given to \fBclBuildProgram\fR(3clc) or \fBclCompileProgram\fR(3clc)\&. This is an integer constant of 1 if the cl\-fast\-relaxed\-math build option is specified and is undefined otherwise\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The macro names defined by the C99 specification but not currently supported by OpenCL are reserved for future use\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} __EMBEDDED_PROFILE__ will be the integer constant 1 for OpenCL devices that implement the embedded profile and is undefined otherwise\&. \fBCL_PLATFORM_PROFILE\fR defined in table 4\&.1 (see \fBclGetPlatformInfo\fR(3clc)) will return the string EMBEDDED_PROFILE if the OpenCL implementation supports the embedded profile only\&. .RE .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBmathConstants\fR(3clc) \fBclBuildProgram\fR(3clc), \fBFP_CONTRACT\fR(3clc), \fBEXTENSION\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br 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. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 234, section 6.10 - Preprocessor Directives and Macros .RE