PREPROCESSORDIRECTIVES(3clc)
π PREPROCESSOR DIRECTI(3clc) β the OpenCL Manual, but make it make sense π
okay bestie, sit down, hydrate, because we're about to talk about the Preprocessor Directives and Macros in OpenCL and honestly? it's giving "underrated icon." β¨ this is the <pink>3clc</pink> section of the OpenCL manual, no cap.
πΈ NAME πΈ
Preprocessor_Directives_and_Macros β Preprocessor Directives and Macros.
and here's the lil shape of the directive itself, keep it in your notes:
# pragma pp-tokens<sub>opt</sub>
new-line
β¨ DESCRIPTION β¨
so basically: the preprocessing directives that the C99 specification defines? yeah, those are supported. all of them. we love a standards moment. π
now here's the tea about # pragma. π«
If you write a # pragma directive where the preprocessing token OPENCL (which is used instead of STDC) does not immediately follow pragma in the directive β and we mean prior to any macro replacement β then the implementation is allowed to behave in an implementation-defined manner. π and what does that mean for you? it might make translation fail, or make the translator or the resulting program behave in a non-conforming manner. not cute. Any such pragma that the implementation doesn't recognize just gets ignored, so no drama, it just vibes past you.
BUT. if the preprocessing token OPENCL does immediately follow pragma in the directive (again, prior to any macro replacement), then no macro replacement is performed on the directive, and the directive has to have one of these forms, whose meanings are described elsewhere:
#pragma OPENCL FP_CONTRACT(3clc) on-off-switch
on-off-switch: one of ON OFF DEFAULT
#pragma OPENCL EXTENSION(3clc) extensionname : behavior
#pragma OPENCL EXTENSION(3clc) all : behavior
π the predefined macro names, aka the whole squad π
these are available, bestie. memorize them, they're iconic:
__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 integer120.CL_VERSION_1_0β substitutes the integer100reflecting the OpenCL 1.0 version.CL_VERSION_1_1β substitutes the integer110reflecting the OpenCL 1.1 version.CL_VERSION_1_2β substitutes the integer120reflecting the OpenCL 1.2 version.__OPENCL_C_VERSION__β substitutes an integer reflecting the OpenCL C version specified by the-cl-stdbuild option toclBuildProgram(3clc)orclCompileProgram(3clc). If the-cl-stdbuild 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 integer120.__ENDIAN_LITTLE__β is used to determine if the OpenCL device is a little endian architecture or a big endian architecture (an integer constant of1if device is little endian and is undefined otherwise). Also refer toCL_DEVICE_ENDIAN_LITTLEspecified in the table of OpenCL Device Queries forclGetDeviceInfo(3clc).__kernel_exec(X, typen)(andkernel_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 of1if images are supported and is undefined otherwise. Also refer toCL_DEVICE_IMAGE_SUPPORTspecified in the table of OpenCL Device Queries forclGetDeviceInfo(3clc).__FAST_RELAXED_MATH__β is used to determine if thecl-fast-relaxed-mathoptimization option is specified in build options given toclBuildProgram(3clc)orclCompileProgram(3clc). This is an integer constant of1if thecl-fast-relaxed-mathbuild 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. π (yes, that means hands off, don't go using them, they're spoken for.)
__EMBEDDED_PROFILE__β will be the integer constant1for OpenCL devices that implement the embedded profile and is undefined otherwise.CL_PLATFORM_PROFILEdefined in table 4.1 (seeclGetPlatformInfo(3clc)) will return the stringEMBEDDED_PROFILEif the OpenCL implementation supports the embedded profile only.
π SPECIFICATION π
OpenCL Specification[1]
π¦ SEE ALSO π¦
mathConstants(3clc) clBuildProgram(3clc), FP_CONTRACT(3clc), EXTENSION(3clc)
π AUTHORS π
The Khronos Group
β COPYRIGHT β
Copyright Β© 2007-2011 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.
π NOTES π
- OpenCL Specification page 234, section 6.10 - Preprocessor Directives and Macros
and that's the whole page, bestie π«Ά shoutout to The Khronos Group for writing all of this, and to the version stamped 01/14/2021 β that's when this little PREPROCESSOR DIRECTI(3clc) beauty got its date. slay, periodt. π
β¨
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms