clSetEventCallback - Registers a user callback function for a specific command execution status.
Contents
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.
Errors
Returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following
errors:
• CL_INVALID_EVENT if event is not a valid event object.
• CL_INVALID_VALUE if pfn_event_notify is NULL or if command_exec_callback_type is not CL_COMPLETE.
• CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation
on the device.
• CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL
implementation on the host.
Name
clSetEventCallback - Registers a user callback function for a specific command execution status.
cl_intclSetEventCallback(cl_eventevent,cl_intcommand_exec_callback_type,void(CL_CALLBACK*pfn_event_notify)(cl_eventevent,cl_intevent_command_exec_status,void*user_data),void*user_data);Notes
1. OpenCL Specification
page 183, section 5.9 - Event Objects
The Khronos Group 11/18/2024 CLSETEVENTCALLBACK(3clc)
Parameters
event
A valid event object.
command_exec_callback_type
The command execution status for which the callback is registered. The command execution callback
value for which a callback can be registered is CL_SUBMITTED, CL_RUNNING, or CL_COMPLETE. There is no
guarantee that the callback functions registered for various execution status values for an event
will be called in the exact order that the execution status of a command changes. Furthermore, it
should be noted that receiving a call back for an event with a status other than CL_COMPLETE, in no
way implies that the memory model or execution model as defined by the OpenCL specification has
changed. For example, it is not valid to assume that a corresponding memory transfer has completed
unless the event is in a state CL_COMPLETE.
The callback function registered for a command_exec_callback_type value of CL_COMPLETE will be called
when the command has completed successfully or is abnormally terminated.
pfn_event_notify
The event callback function that can be registered by the application. This callback function may be
called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure
that the callback function is thread-safe. The parameters to this callback function are:
• event is the event object for which the callback function is invoked.
• event_command_exec_status represents the execution status of command for which this callback
function is invoked. See the table of values for param_value for clGetEventInfo(3clc) for the
command execution status values. If the callback is called as the result of the command
associated with event being abnormally terminated, an appropriate error code for the error that
caused the termination will be passed to event_command_exec_status instead.
• 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 NULL.
Specification
OpenCLSpecification[1]
