[UR][L0v2] Check for external memory mapping extension before use#21645
Conversation
|
Please review @kswiecicki |
|
Please review @intel/unified-runtime-reviewers and/or @intel/unified-runtime-reviewers-level-zero |
|
Please review @KFilipek |
4d46cd3 to
8795325
Compare
|
Rebased because of a merge conflict |
|
Please review @intel/unified-runtime-reviewers and/or @intel/unified-runtime-reviewers-level-zero |
1 similar comment
|
Please review @intel/unified-runtime-reviewers and/or @intel/unified-runtime-reviewers-level-zero |
There was a problem hiding this comment.
Pull request overview
This PR fixes Level Zero v2 USM host memory registration behavior when the external memory mapping extension is not supported by the driver, aligning the returned error code with the expected UR_RESULT_ERROR_UNSUPPORTED_FEATURE and updating the CTS to skip gracefully in that case.
Changes:
- Add a platform-level flag indicating support for
ZE_EXTERNAL_MEMORY_MAPPING_EXT_NAMEduring Level Zero driver extension enumeration. - Gate
urUSMHostAllocRegisterExpin the Level Zero v2 adapter on that flag and returnUR_RESULT_ERROR_UNSUPPORTED_FEATUREwhen unavailable. - Update the conformance test to accept success or unsupported feature (skip when unsupported).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| unified-runtime/source/adapters/level_zero/platform.hpp | Adds a cached boolean for external memory mapping extension support. |
| unified-runtime/source/adapters/level_zero/platform.cpp | Detects the external memory mapping extension during driver extension enumeration. |
| unified-runtime/source/adapters/level_zero/v2/usm.cpp | Returns unsupported feature early for host memory registration when the extension is absent. |
| unified-runtime/test/conformance/exp_usm_host_mem_register/urUSMHostMemRegister.cpp | Updates CTS to skip (not fail) when host registration is unsupported. |
unified-runtime/test/conformance/exp_usm_host_mem_register/urUSMHostMemRegister.cpp
Outdated
Show resolved
Hide resolved
8795325 to
360dd7e
Compare
|
Please review @intel/unified-runtime-reviewers and/or @intel/unified-runtime-reviewers-level-zero |
urUSMHostAllocRegisterExp in the L0v2 adapter was unconditionally using the ZE_extension_external_memmap_sysmem extension to register host memory, causing zeMemAllocHost to return ZE_RESULT_ERROR_INVALID_ARGUMENT on drivers that do not support this extension. This resulted in UR_RESULT_ERROR_INVALID_VALUE being returned instead of the expected UR_RESULT_ERROR_UNSUPPORTED_FEATURE. Add a platform-level check for ZE_EXTERNAL_MEMORY_MAPPING_EXT_NAME during driver extension enumeration, and return UR_RESULT_ERROR_UNSUPPORTED_FEATURE early from urUSMHostAllocRegisterExp when the extension is not available. Update the conformance test to use UUR_ASSERT_SUCCESS_OR_UNSUPPORTED so it gracefully skips when the driver does not support the extension, rather than failing. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
urUSMHostAllocUnregisterExp calls zeMemFree on a pointer that was previously registered via urUSMHostAllocRegisterExp (which uses zeMemAllocHost with the ZE_extension_external_memmap_sysmem extension). If the extension is not supported and urUSMHostAllocRegisterExp returned UR_RESULT_ERROR_UNSUPPORTED_FEATURE early, calling urUSMHostAllocUnregisterExp on the same unregistered pointer would invoke zeMemFree on a pointer that was never registered with the driver, leading to undefined behaviour. Add the same ZeExternalMemoryMappingExtensionSupported guard that urUSMHostAllocRegisterExp already has, so both register and unregister consistently return UR_RESULT_ERROR_UNSUPPORTED_FEATURE when the extension is unavailable. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
|
@intel/llvm-gatekeepers please consider merging |
urUSMHostAllocRegisterExp in the L0v2 adapter was unconditionally using
the ZE_extension_external_memmap_sysmem extension to register host
memory, causing zeMemAllocHost to return ZE_RESULT_ERROR_INVALID_ARGUMENT
on drivers that do not support this extension. This resulted in
UR_RESULT_ERROR_INVALID_VALUE being returned instead of the expected
UR_RESULT_ERROR_UNSUPPORTED_FEATURE.
Add a platform-level check for ZE_EXTERNAL_MEMORY_MAPPING_EXT_NAME
during driver extension enumeration, and return
UR_RESULT_ERROR_UNSUPPORTED_FEATURE early from urUSMHostAllocRegisterExp
when the extension is not available.
Update the conformance test to use UUR_ASSERT_SUCCESS_OR_UNSUPPORTED so
it gracefully skips when the driver does not support the extension,
rather than failing.