ch4/shm/posix: avoiding device id lookup for ZE registered host memory - #7939
ch4/shm/posix: avoiding device id lookup for ZE registered host memory#7939colleeneb wants to merge 1 commit into
Conversation
This is root of the issue. I always advocate to use signed int for any variables that will do arithmetic or comparisons. This is a case in point. |
| MPIDI_RMA_choose_engine(MPL_gpu_attr_is_dev(&origin_attr), origin_dev_id, | ||
| MPL_gpu_attr_is_dev(&target_attr), target_dev_id); | ||
| MPIDI_RMA_choose_engine(MPL_gpu_attr_is_strict_dev(&origin_attr), origin_dev_id, | ||
| MPL_gpu_attr_is_strict_dev(&target_attr), target_dev_id); |
There was a problem hiding this comment.
MPL_gpu_attr_is_dev and MPL_gpu_attr_is_strict_dev are so confusing to any one who is not familiar with ZE. I think I we should have MPL_gpu_attr_is_dev and MPL_gpu_attr_is_host. !MPL_gpu_attr_is_host() would be so much clearer than the current MPL_gpu_attr_is_dev.
There was a problem hiding this comment.
Agreed! I can change it here or in another PR unless you want to.
For local_ze_device_count is an unsigned int32,, same I can change it here or in another PR.
There was a problem hiding this comment.
I think this PR is good as is. Let's make a separate PR for refactoring.
Pull Request Description
This is a change to fix #7927 . The assertion
Assertion local_dev_id < local_ze_device_countwas failing because the local dev id was -1 (since Level Zero registered host memory, unlike Level Zero device memory, does not have a specific device associated with it(zeMemGetAllocProperties returns a NULL device handle for it)), but local_ze_device_count is an unsigned int32, so in the comparison the -1 was converted to unsigned, and this was larger than the device count. When the asserts are off, it would returnlocal_to_global_map[-1], which is out of bounds.To fix this, this PR:
Adds a check in
MPL_gpu_local_to_global_dev_idfor if the local_dev_id is -1 and returns -1 in that case, avoiding the signed-to-unsigned conversion in the assert and the out-of-boundslocal_to_global_map[-1]call when the assert is off.Changes
MPL_gpu_attr_is_devtoMPL_gpu_attr_is_strict_devinsrc/mpid/ch4/shm/posix/posix_rma.hfor whenever it tries to look up a device_id, since ZE host registered memory does not have a specific device id. (MPL_gpu_attr_is_strict_devis only true for ZE device memory, and false for ZE host memory). This isn't necessary after the change in 1) but it seems clearer to me since if it's host registered memory we know there's no device id.Changes
MPL_gpu_attr_is_devtoMPL_gpu_attr_is_strict_devinsrc/mpid/ch4/shm/posix/posix_rma.has arguments toMPIDI_RMA_choose_engine. This is to avoid hitting another assert atmpich/src/mpl/src/gpu/mpl_gpu_ze.c
Line 1594 in 6a79bf6
MPIDI_RMA_choose_engineis called withMPL_gpu_attr_is_devand then callsMPL_gpu_query_is_same_dev. If insteadMPL_gpu_attr_is_strict_devis used, for Level Zero registered host memory, it will be considered "host memory" and it takes the host memory engine path (mpich/src/mpid/ch4/shm/posix/posix_rma.h
Line 91 in 6a79bf6
I'm happy to make any adjustments in the PR! And thanks to Claude for help understanding the code.
Author Checklist
Particularly focus on why, not what. Reference background, issues, test failures, xfail entries, etc.
Commits are self-contained and do not do two things at once.
Commit message is of the form:
module: short descriptionCommit message explains what's in the commit.
Whitespace checker. Warnings test. Additional tests via comments.
For non-Argonne authors, check contribution agreement.
If necessary, request an explicit comment from your companies PR approval manager.