unified-runtime icon indicating copy to clipboard operation
unified-runtime copied to clipboard

Consider to add a new error code for `urVirtualMemMap` when the VA is already mapped

Open AllanZyne opened this issue 2 years ago • 7 comments

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.

AllanZyne avatar Dec 10 '23 12:12 AllanZyne

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.

kbenzie avatar Dec 11 '23 15:12 kbenzie

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.

pbalcer avatar Dec 11 '23 15:12 pbalcer

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.

AllanZyne avatar Dec 13 '23 02:12 AllanZyne

@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?

alycm avatar Jan 10 '24 15:01 alycm

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.

steffenlarsen avatar Jan 10 '24 16:01 steffenlarsen

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.

AllanZyne avatar Jan 12 '24 07:01 AllanZyne

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.

kbenzie avatar Feb 12 '24 16:02 kbenzie