CLGETEXTENSIONFUNCTI(3clc)
β¨ CLGETEXTENSIONFUNCTI β the clGetExtensionFunctionAddressForPlatform era β¨
okay bestie, welcome to the OpenCL Manual, section 3clc, and today's main character is clGetExtensionFunctionAddressForPlatform π she's the one who tells you where an extension function lives. iykyk π
π NAME π
clGetExtensionFunctionAddressForPlatform β returns the address of the extension function named by funcname for a given platform.
void* clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
const char *funcname);
πΈ PARAMETERS πΈ
- funcname β the name of an extension function. that's it, that's the girl π«Ά
π¦ DESCRIPTION π¦
so like. clGetExtensionFunctionAddressForPlatform returns the address of the extension function named by funcname for a given platform. the pointer that comes back? you must cast it to a function pointer type that matches the extension function's definition β the one defined in the appropriate extension specification and header file. no freestyling, bestie π
a return value of NULL means the specified function does not exist for the implementation, or that platform is not a valid platform. either way: nothing for you here π
β οΈ real talk: a non-NULLreturn value fromclGetExtensionFunctionAddressForPlatformdoes not guarantee that an extension function is actually supported by the platform. it's giving "maybe". the application must also make a corresponding query usingclGetPlatformInfo(3clc)(platform,CL_PLATFORM_EXTENSIONS, ... ) orclGetDeviceInfo(3clc)(device,CL_DEVICE_EXTENSIONS, ... ) to figure out if an extension is actually supported by the OpenCL implementation. do both or perish β¨
clGetExtensionFunctionAddressForPlatform may not be queried for core (non-extension) functions in OpenCL. for functions that are queryable with clGetExtensionFunctionAddressForPlatform, implementations may choose to also export those functions statically from the object libraries implementing those functions β but portable applications cannot rely on this behavior. no cap π«
function pointer typedefs must be declared for all extensions that add API entrypoints. these typedefs are a required part of the extension interface, and they get provided in an appropriate header β such as cl_ext.h if the extension is an OpenCL extension, or cl_gl_ext.h if the extension is an OpenCL/OpenGL sharing extension. iconic behavior, truly π
π NOTES π
since there's no way to qualify the query with a device, the function pointer you get back must work for all implementations of that extension on different devices for a platform. and the behavior of calling a device extension function on a device that doesn't support that extension is undefined. literally do not. π
π§ Example π§
the following convention must be followed for all extensions affecting the host API, where TAG can be KHR, EXT or vendor-specific:
#ifndef extension_name #define
extension_name 1
// all data typedefs, token #defines,
prototypes, and // function pointer
typedefs for this extension
// function pointer typedefs must use
the // following naming convention
typedef CL_API_ENTRY return type
(CL_API_CALL
*clextension_func_nameTAG_fn)(...);
#endif // extension_name
consider, for example, the cl_khr_gl_sharing(3clc) extension. this extension would add the following to cl_gl_ext.h::
#ifndef cl_khr_gl_sharing #define
cl_khr_gl_sharing 1
// all data typedefs, token #defines,
prototypes, and // function pointer
typedefs for this extension #define
CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR
-1000 #define
CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR
0x2006 #define
CL_DEVICES_FOR_GL_CONTEXT_KHR
0x2007 #define CL_GL_CONTEXT_KHR
0x2008 #define CL_EGL_DISPLAY_KHR
0x2009 #define CL_GLX_DISPLAY_KHR
0x200A #define CL_WGL_HDC_KHR
0x200B #define CL_CGL_SHAREGROUP_KHR
0x200C
// function pointer typedefs must use
the // following naming convention
typedef CL_API_ENTRY cl_int
(CL_API_CALL
*clGetGLContextInfoKHR_fn)( const
cl_context_properties * /* properties
*/, cl_gl_context_info /* param_name
*/, size_t /* param_value_size */, void
* /* param_value */, size_t *
/*param_value_size_ret*/); #endif //
cl_khr_gl_sharing
π SPECIFICATION π
OpenCL Specification[1] β yes queen, cite your sources π
β SEE ALSO β
π AUTHORS π
The Khronos Group β the icons themselves π«Ά
π 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 7, section 9.2 - Getting OpenCL API Extension Function Pointers
and that's the whole page bestie, no crumbs left π shoutout to The Khronos Group for writing this back on 01/14/2021 β we stan a documented extension lookup. this was CLGETEXTENSIONFUNCTI(3clc) from the OpenCL Manual, and she ate. 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