feat(rocSHMEM): separate p and g from memcpy paths, #AIROCSHMEM-506 - #10908
Open
amirsojoodi wants to merge 2 commits into
Open
feat(rocSHMEM): separate p and g from memcpy paths, #AIROCSHMEM-506#10908amirsojoodi wants to merge 2 commits into
amirsojoodi wants to merge 2 commits into
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a scalar-specific RMA fast path for p()/g() so IPC/GDA backends can safely use global (non-flat) load/store instructions without accidentally applying them to non-global (e.g., private/stack) addresses.
Changes:
- Add
memcpy_lane_scalar<Kind>(dst, src, size)for byte-size-dispatched scalar copies that only applyAsmAccessto the remote pointer. - Add
putmem_scalar/getmem_scalarto IPC and GDA contexts and rewirep()/g()to use these scalar paths. - Switch
AsmAccessinline asm fromflat_*toglobal_*instructions and document the “global address required” constraint.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocshmem/src/util.hpp | Adds scalar lane copy helper and documents global-address constraints for bulk/remainder paths. |
| projects/rocshmem/src/ipc/context_ipc_tmpl_device.hpp | Rewires IPC p()/g() to use scalar put/get helpers. |
| projects/rocshmem/src/ipc/context_ipc_device.hpp | Declares IPC putmem_scalar/getmem_scalar. |
| projects/rocshmem/src/ipc/context_ipc_device.cpp | Implements IPC scalar put/get via memcpy_lane_scalar. |
| projects/rocshmem/src/gda/context_gda_tmpl_device.hpp | Rewires GDA p()/g() to use scalar put/get helpers. |
| projects/rocshmem/src/gda/context_gda_device.hpp | Declares GDA putmem_scalar/getmem_scalar. |
| projects/rocshmem/src/gda/context_gda_device.cpp | Implements GDA scalar put/get (IPC fast-path + fallback behavior). |
| projects/rocshmem/src/assembly.hpp | Updates AsmAccess to emit global_load_* / global_store_* asm and updates related commentary. |
Suppressed comments (4)
projects/rocshmem/src/util.hpp:516
- Same strict-aliasing/alignment issue as the 1-byte case: dereferencing
Acc::type*from aT*-backed pointer is UB whenTdiffers in signedness or alignment. Prefer memcpy to/from a temporary.
if constexpr (is_put(Kind)) {
Acc::store(dst, *static_cast<typename Acc::type*>(src));
} else {
*static_cast<typename Acc::type*>(dst) = Acc::load(src);
}
projects/rocshmem/src/util.hpp:525
- Same strict-aliasing/alignment issue as above: avoid dereferencing
Acc::type*sourced from avoid*that actually points to aTobject by using memcpy to/from a temporary.
if constexpr (is_put(Kind)) {
Acc::store(dst, *static_cast<typename Acc::type*>(src));
} else {
*static_cast<typename Acc::type*>(dst) = Acc::load(src);
}
projects/rocshmem/src/util.hpp:534
- Same strict-aliasing/alignment issue as above for the 8-byte case. Using memcpy avoids UB when p()/g() instantiate for unsigned 64-bit types or types with weaker alignment.
if constexpr (is_put(Kind)) {
Acc::store(dst, *static_cast<typename Acc::type*>(src));
} else {
*static_cast<typename Acc::type*>(dst) = Acc::load(src);
}
projects/rocshmem/src/util.hpp:543
- Same strict-aliasing/alignment issue as above for the 16-byte case: dereferencing
Acc::type*is UB if the pointed-to object isn't actually__int128_t(or isn't sufficiently aligned). memcpy to/from a temporary avoids that.
if constexpr (is_put(Kind)) {
Acc::store(dst, *static_cast<typename Acc::type*>(src));
} else {
*static_cast<typename Acc::type*>(dst) = Acc::load(src);
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Enable IPC backend to move to global instructions from flat ones.
Technical Details
memcpy_lane_scalar<Kind>(dst, src, size)to util.hpp, mirroring memcpy_lane's signature, to back scalar p()/g() RMAflatinstructions toglobalIssue Tracking
JIRA ID: AIROCSHMEM-506