Consider to add a new error code for `urVirtualMemMap` when the VA is already mapped
Currently, the error code of urVirtualMemMap is invalid argument when the VA is already mapped.
But this error code is not clear enough, since returning invalid argument could also be due to other reasons, like the size is not proper.
This could be UR_RESULT_ERROR_INVALID_OPERATION instead. However looking at urVirtulMemMap spec, UR_RESULT_ERROR_INVALID_VALUE isn't listed as a valid return value. Will need to update the spec either way.
For the sanitizer we'd ideally have a dedicated error code for VA already having a physical mapping, because in that case it essentially means "success". Using a generic error code like invalid operation might lead to it being reused later on for something different.
For the sanitizer we'd ideally have a dedicated error code for VA already having a physical mapping, because in that case it essentially means "success". Using a generic error code like invalid operation might lead to it being reused later on for something different.
Yes, I totally agree. But if we can document that "UR_RESULT_ERROR_INVALID_OPERATION" only means the VA is already mapped but not other reasons, I think using the existing error code is fine as well.
@steffenlarsen Do you have thoughts on this? Is a new error code for this situation okay, and does it seem like all adapters could accurately provide it?
Sadly I don't see the cuMemMap function specifying a special error code for that case, so I don't know if it reports an error in the mentioned scenario and if it does, whether that error is distinct like what is asked for here.
Sadly I don't see the cuMemMap function specifying a special error code for that case, so I don't know if it reports an error in the mentioned scenario and if it does, whether that error is distinct like what is asked for here.
I'm not sure, just from the document, it seems like "CUDA_ERROR_OUT_OF_MEMORY" is what I want.
The CUDA adapter has this error code mapping: https://github.com/oneapi-src/unified-runtime/blob/03cd9d10b5cea7d0bf20738e046703ff08926e43/source/adapters/cuda/common.cpp#L29-L30
Not sure if that's what a CUDA driver will actually return if a VA is already mapped though.