Skip to content

feat(rocSHMEM): separate p and g from memcpy paths, #AIROCSHMEM-506 - #10908

Open
amirsojoodi wants to merge 2 commits into
developfrom
users/asojoodi/rocshmem-fix-p-and-g
Open

feat(rocSHMEM): separate p and g from memcpy paths, #AIROCSHMEM-506#10908
amirsojoodi wants to merge 2 commits into
developfrom
users/asojoodi/rocshmem-fix-p-and-g

Conversation

@amirsojoodi

@amirsojoodi amirsojoodi commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Motivation

Enable IPC backend to move to global instructions from flat ones.

Technical Details

  • Add memcpy_lane_scalar<Kind>(dst, src, size) to util.hpp, mirroring memcpy_lane's signature, to back scalar p()/g() RMA
  • Add putmem_scalar/getmem_scalar to IPCContext and GDAContext, mirroring the existing putmem/getmem pattern, and rewire p()/g() to use them
  • Revert the Access asm blocks from flat instructions to global

Issue Tracking

JIRA ID: AIROCSHMEM-506

Copilot AI lite review requested due to automatic review settings August 28, 2026 19:14
@amirsojoodi
amirsojoodi requested a review from a team as a code owner August 28, 2026 19:15
@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass
Forbidden Files ✅ Pass
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocshmem/src/assembly.hpp, projects/rocshmem/src/gda/context_gda_device.cpp, projects/rocshmem/src/gda/context_gda_device.hpp, projects/rocshmem/src/gda/context_gda_tmpl_device.hpp, projects/rocshmem/src/ipc/context_ipc_device.cpp (+3 more); no test file found
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@amirsojoodi amirsojoodi changed the title Dev: separate p and g from memcpy paths, #AIROCSHMEM-506 feat(rocSHMEM): separate p and g from memcpy paths, #AIROCSHMEM-506 Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 apply AsmAccess to the remote pointer.
  • Add putmem_scalar/getmem_scalar to IPC and GDA contexts and rewire p()/g() to use these scalar paths.
  • Switch AsmAccess inline asm from flat_* to global_* 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 a T*-backed pointer is UB when T differs 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 a void* that actually points to a T object 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.

Comment thread projects/rocshmem/src/util.hpp Outdated
Comment thread projects/rocshmem/src/util.hpp Outdated
Comment thread projects/rocshmem/src/assembly.hpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants