OpenCL-Docs
OpenCL-Docs copied to clipboard
Clarify svm_ptr argument to clEnqueueSVMMemFill
Found while discussing and developing the unified SVM extension: the current description for the svm_ptr argument to clEnqueueSVMMemFill is confusing and should be improved. For reference, the current text is:
svm_ptr is a pointer to a memory region that will be filled with pattern. It must be aligned to pattern_size bytes. If svm_ptr is allocated using clSVMAlloc then it must be allocated from the same context from which command_queue was created. Otherwise the behavior is undefined.
There are three specific svm_ptr cases I believe we need to document:
- svm_ptr is unaligned. This is a
CL_INVALID_VALUEerror. - svm_ptr is
NULL. This is aCL_INVALID_VALUEerror. - svm_ptr was allocated using clSVMAlloc from a different context. This is undefined behavior (note: even if the device supports system SVM?).
- svm_ptr was not allocated using clSVMAlloc. This is valid if the device associated with the command_queue supports system SVM, otherwise this is undefined behaivor.
- svm_ptr was allocated using clSVMAlloc from the same context. This is a valid.
Debatably cases (3) and (4) should be errors instead of undefined behavior, but this would be a change compared to the current spec. Note though:
- It is possible for an implementation to return an error in these cases (because behavior is undefined), but this would not be required.
- If we really wanted to, we could consider tightening the behavior for implementations supporting unified SVM.