To enqueue a command to indicate which device a set of ranges of SVM allocations should be associated with, call the function
cl_int clEnqueueSVMMigrateMem( cl_command_queue command_queue, cl_uint num_svm_pointers, const void** svm_pointers, const size_t* sizes, cl_mem_migration_flags flags, cl_uint num_events_in_wait_list, const cl_event* event_wait_list, cl_event* event);
command_queue is a valid host command queue. The specified set of allocation ranges will be migrated to the OpenCL device associated with command_queue.
num_svm_pointers is the number of pointers in the specified svm_pointers array, and the number of sizes in the sizes array, if sizes is not
svm_pointers is a pointer to an array of pointers. Each pointer in this array must be within an allocation produced by a call to clSVMAlloc.
sizes is an array of sizes. The pair svm_pointers[i] and sizes[i] together define the starting address and number of bytes in a range to be migrated. sizes may be
NULLindicating that every allocation containing any svm_pointer[i] is to be migrated. Also, if sizes[i] is zero, then the entire allocation containing svm_pointer[i] is migrated.
flags is a bit-field that is used to specify migration options. The Memory Migration Flags describes the possible values for flags.
event_wait_list and num_events_in_wait_list specify events that need to complete before this particular command can be executed. If event_wait_list is
NULL, then this particular command 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 particular command and can be used to query or queue a wait for this particular command to complete. event can be
NULLin which case it will not be possible for the application to query the status of this command or queue another command that waits for this command to complete. If the event_wait_list and event arguments are not
NULL, the event argument should not refer to an element of the event_wait_list array.
Once the event returned by clEnqueueSVMMigrateMem has become
the ranges specified by svm pointers and sizes have been successfully
migrated to the device associated with command queue.
The user is responsible for managing the event dependencies associated with this command in order to avoid overlapping access to SVM allocations. Improperly specified event dependencies passed to clEnqueueSVMMigrateMem could result in undefined results.
CL_SUCCESS if the function is executed
Otherwise, it returns one of the following errors:
CL_INVALID_COMMAND_QUEUEif command_queue is not a valid host command-queue.
CL_INVALID_CONTEXTif context associated with command_queue and events in event_wait_list are not the same.
CL_INVALID_VALUEif num_svm_pointers is zero or svm_pointers is
CL_INVALID_VALUEif sizes[i] is non-zero range [svm_pointers[i], svm_pointers[i]+sizes[i]) is not contained within an existing clSVMAlloc allocation.
CL_INVALID_EVENT_WAIT_LISTif event_wait_list is
NULLand num_events_in_wait_list > 0, or if 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_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.