EXTENSION(3clc)
β¨ NAME β¨
okay so bestie, welcome to EXTENSION π β it's a #pragma directive that sets the behavior for OpenCL extensions. that's it, that's the whole vibe. (this is the OpenCL Manual, if you were wondering where you wandered into π¦)
#pragma OPENCL EXTENSION extension_name : behavior
#pragma OPENCL EXTENSION all : behavior
πΈ PARAMETERS πΈ
extension_name
the name of the extension, babes. it'll be shaped like cl_khr_<name> for an extension approved by the OpenCL working group, and shaped like cl_<vendor_name>_<name> for vendor extensions. the token all means the behavior applies to all extensions supported by the compiler. here's the legal-values list for extension_name, no cap:
cl_khr_int64_base_atomics(3clc)β 64-bit integer base atomic operationscl_khr_int64_extended_atomics(3clc)β 64-bit integer extended atomic operationscl_khr_3d_image_writes(3clc)β writes to 3D image objectscl_khr_fp16(3clc)β half-precision floating-pointcl_apple_gl_sharingβ MacOS X OpenGL sharingcl_khr_gl_sharing(3clc)β OpenGL sharingcl_khr_gl_event(3clc)β CL event objects from GL sync objectscl_khr_d3d10_sharing(3clc)β sharing memory objects wth Direct3D 10cl_khr_d3d11_sharing(3clc)β sharing memory objects wth Direct3D 11cl_khr_dx9_media_sharing(3clc)β sharing memory objects wth Direct3D 9cl_khr_icd(3clc)β access Khronos OpenCL installable client driver loader (ICD Loader.
behavior
one of these two, pick your fighter π«Ά:
enableβ behave as specified by the extensionextension_name. report an error on the#pragma OPENCL EXTENSIONif theextension_nameis not supported, or ifallis specified.disableβ behave (including issuing errors and warnings) as if the extensionextension_nameis not part of the language definition. ifallis specified, then behavior must revert back to that of the non-extended core version of the language being compiled to. warn on the#pragma OPENCL EXTENSIONif the extensionextension_nameis not supported.
π DESCRIPTION π
the #pragma OPENCL EXTENSION directive is a simple, low-level mechanism to set the behavior for each extension. it does not define policies like which combinations are appropriate β those have to be defined elsewhere, not my problem, not yours either. π
the order of directives matters when setting the behavior for each extension. directives that occur later override those seen earlier. the all variant sets the behavior for all extensions, overriding all previously issued extension directives β but only if the behavior is set to disable. periodt.
the initial state of the compiler is as if the directive #pragma OPENCL EXTENSION all : disable was issued, telling the compiler that all error and warning reporting must be done according to this specification, ignoring any extensions. so like, extensions start off, bestie. that's the default state of being.
every extension which affects the OpenCL language semantics, syntax, or adds built-in functions to the language must create a preprocessor #define that matches the extension name string. this #define would be available in the language if and only if the extension is supported on a given implementation. iykyk. β¨
π NOTES π
this document describes the list of optional features supported by OpenCL 1.2. optional extensions may be supported by some OpenCL devices. optional extensions are not required to be supported by a conformant OpenCL implementation, but are expected to be widely available; they define functionality that is likely to move into the required feature set in a future revision of the OpenCL specification. it's giving "optional but make it main character energy". π
OpenCL extensions approved by the OpenCL working group can be promoted to required core features in later revisions of OpenCL. when this occurs, the extension specifications are merged into the core specification. functions and enumerants that are part of such promoted extensions will have the KHR affix removed. OpenCL implementations of such later revisions must also export the name strings of promoted extensions in the CL_PLATFORM_EXTENSIONS or CL_DEVICE_EXTENSIONS string, and support the KHR-affixed versions of functions and enumerants as a transition aid.
π Example π
an extension which adds the extension string "cl_khr_3d_image_writes" should also add a preprocessor #define called cl_khr_3d_image_writes. a kernel can now use this preprocessor #define to do something like the following:
#ifdef cl_khr_3d_image_writes
// do something using the extension
#else
// do something else or
#error!
#endif
π SPECIFICATION π
OpenCL Specification[1]
π 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 6, section 9.1 - Compiler Directives for Optional Extensions
and that's the whole page, bestie!! π
this was The Khronos Group's page, dated 01/14/2021, living in the manual as EXTENSION(3clc). go forth and #pragma responsibly. πβ¨π«Ά
π¦ 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