To register a user callback function with a program object, call the function
cl_int clSetProgramReleaseCallback( cl_program program, void (CL_CALLBACK* pfn_notify)(cl_program program, void* user_data), void* user_data);
program is a valid program object
pfn_notify is the callback function that can be registered by the application. This callback function may be called asynchronously by the OpenCL implementation. It is the applications responsibility to ensure that the callback function is thread safe. The parameters to this callback function are:
prog is the program object whose destructors are being called. When the user callback is called by the implementation, this program object is not longer valid. prog is only provided for reference purposes.
user_data is a pointer to user supplied data. user_data will be passed as the user_data argument when pfn_notify is called. user data can be
Each call to clSetProgramReleaseCallback registers the specified user callback function on a callback stack associated with program. The registered user callback functions are called in the reverse order in which they were registered. The user callback functions are called after destructors (if any) for program scope global variables (if any) are called and before the program is released. This provides a mechanism for the application (and libraries) to be notified when destructors are complete.
CL_SUCCESS if the function is executed
Otherwise, it returns one of the following errors:
CL_INVALID_PROGRAMif program is not a valid program object.
CL_INVALID_VALUEif pfn_notify is
CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.
CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
For more information, see the OpenCL Specification
This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.
Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.