To enqueue a command to free the shared virtual memory allocated using clSVMAlloc or a shared system memory pointer, call the function
void (CL_CALLBACK* pfn_free_func)(cl_command_queue queue, cl_uint num_svm_pointers, void* svm_pointers, void* user_data),
const cl_event* event_wait_list,
|clEnqueueSVMFree is missing before version 2.0.
command_queue is a valid host command-queue.
svm_pointers and num_svm_pointers specify shared virtual memory pointers to be freed. Each pointer in svm_pointers that was allocated using clSVMAlloc must have been allocated from the same context from which command_queue was created. The memory associated with svm_pointers can be reused or freed after the function returns.
pfn_free_func specifies the callback function to be called to free the SVM pointers. 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. pfn_free_func takes four arguments: queue which is the command-queue in which clEnqueueSVMFree was enqueued, the count and list of SVM pointers to free and user_data which is a pointer to user specified data. If pfn_free_func is
NULL, all pointers specified in svm_pointers must be allocated using clSVMAlloc and the OpenCL implementation will free these SVM pointers. pfn_free_func must be a valid callback function if any SVM pointer to be freed is a shared system memory pointer i.e. not allocated using clSVMAlloc. If pfn_free_func is a valid callback function, the OpenCL implementation will call pfn_free_func to free all the SVM pointers specified in svm_pointers.
user_data will be passed as the user_data argument when pfn_free_func is called. user_data can be
event_wait_list and num_events_in_wait_list specify events that need to complete before clEnqueueSVMFree can be executed. If event_wait_list is
NULL, then clEnqueueSVMFree does not wait on any event to complete. If event_wait_list is
NULL, num_events_in_wait_list must be 0. If event_wait_list is not
NULL, the list of events pointed to by event_wait_list must be valid and num_events_in_wait_list must be greater than 0. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same. The memory associated with event_wait_list can be reused or freed after the function returns.
event returns an event object that identifies this command and can be used to query or queue a wait for this command to complete. If event is
NULLor the enqueue is unsuccessful, no event will be created and therefore it will not be possible to query the status of this command or to wait for this command to complete. If event_wait_list and event are not
NULL, event must not refer to an element of the event_wait_list array.
CL_SUCCESS if the function is executed
Otherwise, it returns one of the following errors:
CL_INVALID_if command_queue is not a valid host command-queue.
CL_INVALID_if the device associated with command_queue does not support SVM.
CL_INVALID_if num_svm_pointers is 0 and svm_pointers is non-
NULL, or if svm_pointers is
NULLand num_svm_pointers is not 0.
CL_INVALID_if event_wait_list is
EVENT_ WAIT_ LIST
NULLand num_events_in_wait_list > 0, or event_wait_list is not
NULLand num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the device.
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the host.
OF_ HOST_ MEMORY
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.