-
Notifications
You must be signed in to change notification settings - Fork 84
feat(shmem): add a CPU host-proxy RDMA transport alongside IBGDA #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
134 commits
Select commit
Hold shift + click to select a range
e54d0b1
feat(shmem): CPU proxy for IBGDA operations on Pensando AINIC
5d8813a
feat(shmem): integrate CPU proxy into MORI SHMEM layer
e04802b
fix(ionic): expose ibv_qp/ibv_cq handles for CPU proxy thread
ff9ece2
test: cross-NIC DMA capability test for multi-rail approach
efa6e45
feat: send-side routing — multi-rail QPs + lkey override
51d2607
wip: send-side routing — per-NIC MR + rkey exchange
924f285
fix: QP index mapping for proxy — use epIndex-indexed array
50759a7
wip: save progress — need to debug SIGSEGV in proxy EP test
102db5e
debug: found SIGSEGV crash location — line 345 in setup()
e61a4c4
fix: skip parent domain creation in proxy mode to avoid GPU corruption
62fcf6b
fix: use posix_memalign for proxy ring + document JIT cache invalidation
3572353
wip: re-enable proxy thread + plain QP + parent domain skip
dcdd2cd
fix: move per-NIC MR to symmetric_memory + skip 0-QP thread + narrow …
9bf0280
fix: lazy CQ poll + hipHostRegister for GPU-accessible ring
49b5d3c
feat: SEND_WITH_IMM atomic emulation + agreed-rail QP mapping + TC fix
31af7e7
fix: uncached VRAM + PCIe read fence for data/signal ordering
b4eed72
fix: increase recv WR count to 512 per proxy QP
3e4fea3
debug: add trace for uncached symmetric memory allocation path
a3a59b4
fix: conditional hipSetDevice in proxy thread
9b769e3
cleanup: simplify hipSetDevice in proxy MainLoop
016a329
fix: replace SEND_WITH_IMM with RDMA_WRITE for signal delivery
c50ce8e
feat: hybrid signal delivery — RDMA_WRITE for data signals, SEND_WITH…
e4fbddf
fix: increase proxy ring size to 8192 for large token counts
a18fd17
fix: increase proxy ring to 64K slots for bench-scale token counts
db3a42c
fix: remove FENCE from PROXY_SIGNAL_WRITE to unblock bench at scale
9243d69
cleanup: remove debug logging from proxy thread
4b235d1
cleanup: remove all debug fprintf from proxy infrastructure
bdbbb64
fix: remove orphaned fprintf arguments from sed cleanup
003cbab
cleanup: remove MoRI-RAIL debug prints from context.cpp
fba19f7
fix: only do per-NIC MR registration for the heap, not sub-allocations
21da9b6
debug: add minimal traces for vLLM init hang diagnosis
47770c2
fix: skip redundant MR registration + Allgather for heap sub-allocations
76e5162
feat: per-NIC proxy threads + targeted quiet for 3.4x dispatch speedup
e1622ce
v5: Full kernel separation — GpuStates clean, separate ProxyGpuState
46c069a
v5: Fix proxy dispatch for Warp/Block scope — root cause of AINIC hang
8eec84b
v5: Remove debug traces from init.cpp and runtime.cpp
a841a66
v5: Gate application layer proxy changes behind env var
49c405d
v5: Consolidate env var to MORI_EP_OVER_RDMA only
82870eb
v5: Revert shmem_ibgda_kernels.hpp to main — no proxy changes needed
0e7968e
v5: Minimal shmem_device_api.hpp — keep original macros, add one guar…
1fb0510
v5: Simplify proxy guard to just #ifdef MORI_PROXY_ENABLED
9cc3949
v6: Use TransportType::PROXY — native dispatch framework
bc08dfc
v6: Gate proxy dispatch branches with #ifdef MORI_PROXY_ENABLED
f329260
v6: Fix template specialization signatures and long/unsigned long redefs
236673b
v6: Remove address-based overloads, fix duplicate GetGlobalProxyStatePtr
3e98858
v6: Add address-based and signal stubs for all kernel templates
7947482
refactor: consolidate MORI_EP_OVER_RDMA env var checks
e1fc7dc
cleanup: move shmem_proxy_state.hpp include to top of internal.hpp
f3027ee
feat: add ProxyGpuStates as subclass of GpuStates
0cc49b9
cleanup: remove tp8-1p1d-bench skill file
b79a125
refactor: use ProxyGpuStates as single gpuStates in ShmemStates
cfd8cdc
refactor: single-symbol copy with size gated on proxy active
55caf81
refactor: use Context::IsProxyEnabled() for copy size gate
485dda6
cleanup: tidy internal.hpp — remove proxy_state include, move forward…
602833e
refactor: move proxyThreads to init.cpp file-local, use IsProxyEnabled()
bd0064a
cleanup: use inherited ProxyGpuStates in shmem.hpp weak symbol
e6d4e88
cleanup: delete shmem_proxy_state.hpp, fix shmem.hpp two-symbol approach
7082cb2
refactor: align ProxyGpuStates name, move extern + getter to internal…
5a3963a
fix: restore assert(false) fallthrough in dispatch macros
f29f4f0
fix: restore separate GpuStates + ProxyGpuStates in ShmemStates
5564238
rename: proxyGpuState → proxyGpuStates in ShmemStates
b9c02da
fix: update init.cpp and runtime.cpp for standalone ProxyGpuStates
433d1e4
cleanup: remove ProxyGpuStates.active field
bb8e8b1
refactor: use proxyEnabled directly in context.cpp, clean if/else paths
8ecc796
fix: remove unnecessary (int) cast to match main
933f8c5
refactor: clean if/else separation in BuildAndConnectInitialEndpoints
5f76d30
refactor: add GetRailContext() helper, deduplicate agreed-rail formula
c5e2806
cleanup: symmetric_memory.cpp — remove debug fprintf, use IsProxyEnab…
7547d18
refactor: keep main's MR registration untouched, single proxy if block
c8b8196
refactor: optimize proxy sub-allocation path, keep native untouched
ef8c6ac
refactor: cache proxyEnabled in IonicDeviceContext constructor
397aaed
cleanup: remove dead duplicate proxy QP block in ionic.cpp
aa7e241
fix: restore commented-out cqPool.insert from main
c267827
fix: reorder cqPool/qpPool insert before ibv handle expose
4b06cbe
cleanup: remove ibvHandle expose from native IBGDA path
0b19f69
cleanup: deduplicate MORI_DEFINE_GPU_STATES macro
3634247
fix: add VMM heap support to proxy PutMemNbi and PutSizeImmNbi
e469c21
fix: rename PROXY_STATE_MAX_NICS → PROXY_MAX_NICS in init.cpp
60a7674
debug: add traces for hang diagnosis
d72e52c
debug: add more traces for hang diagnosis (iteration 3)
555b69e
debug: add proxy thread traces for perf diagnosis
02d4209
debug: add thread count trace
3171441
fix: gate Warp/Block proxy kernels on lane 0 / thread 0
9ed32f2
Revert "fix: gate Warp/Block proxy kernels on lane 0 / thread 0"
90d8b7b
debug: add proxy thread ops counter on shutdown
546155b
fix: gate Warp/Block proxy kernels on lane 0 / thread 0
7e010ad
perf: symmetric agreed-rail formula for even NIC distribution
13bf51d
Revert "perf: symmetric agreed-rail formula for even NIC distribution"
13e308a
cleanup: remove all debug traces for v7 release
6cb8f76
fix: remove orphaned fprintf arguments in init.cpp
efb1fb2
investigation: add proxy fields to GpuStates (v3 style)
ae3ee1c
investigation: use GpuStates proxy fields from shmem_proxy_kernels
c925208
cleanup: remove unused useProxy field from GpuStates
96556e5
cleanup: remove ProxyGpuStates entirely — proxy state lives in GpuStates
c1638e3
test: add 8-byte padding before proxyRings to match ae3ee1c2 layout
6a379ba
cleanup: revert runtime.cpp whitespace to match main
a688cc0
cleanup: remove debug tools from PR
bd2fbfa
cleanup: remove stale compile tests
750ba3e
feat: CX7 proxy QP support — port ionic proxy pattern to mlx5
b7eb51e
fix: use RdmaDeviceVendorId::Mellanox (not Mlx5)
48c14da
debug: add traces for CX7 proxy combine hang
683dfe9
debug: trace op type and post count per 1000 ops
b203b0a
debug: add heartbeat trace to proxy thread — shows pending/head/next …
653fb88
debug: trace RECV handler — target addr, value, byte_len
ab19c0a
debug: trace ALL recv CQEs including opcode/status/byte_len
0bad02d
debug: trace recv_buf/recv_count on recv CQE, remove heartbeat
d00973d
fix: use native RDMA atomics on CX7, SEND_WITH_IMM on ionic
ca6f985
restore original comments in BuildAndConnectInitialEndpoints
a65ed24
cleanup: merge duplicate IsProxyEnabled blocks, restore comments
b7d8b14
cleanup: remove all debug traces from proxy_thread.cpp and init.cpp
189a45f
add: Broadcom bnxt proxy RDMA support for EP
9c4c3dc
fix: skip BnxtDvApi check when proxy mode enabled
9ae6ebd
fix: skip DV API check for all providers when proxy enabled
a571258
Merge pull request #12 from itej89/feat/ep-rdma-sharing-bnxt
itej89 32f8129
fix: use hipHostGetDevicePointer for proxy ring GPU pointers (#13)
itej89 4902eb0
add proxy mode log line for RDMA init verification
fb190f0
refactor: route proxy through IBVerbsDeviceContext (#14)
itej89 228e68b
fix: remove proxy code from bnxt DV provider (#15)
itej89 4c77d8c
fix: remove proxy code from bnxt DV provider (#16)
itej89 1efe5e9
fix: add _tunable_defines() to _hipcc_device_bc for Triton/FlyDSL (#17)
itej89 b008bf2
fix: restore rdmaRegister guard and guard heapRkeys_ memcpy in proxy …
itej89 b8a5d7f
fix: check wc.status before opcode, use MORI logger in proxy (#19)
itej89 0a1deda
rename: MORI_EP_OVER_RDMA → MORI_ENABLE_HOST_PROXY (#20)
itej89 7d04f1a
fix: remove MORI_EP_OVER_RDMA fallback completely
645f5ed
fix: log error on null atomic target address in proxy DrainCq
8b60e6a
fix: use MORI_APP_ERROR for proxy transport logs
de983fb
fix: write atomic fetch result back to ring slot for native atomics
d9bc81f
fix: replace x86 asm with portable std::atomic_thread_fence (#21)
itej89 ac2a6b6
fix: stage inline data in ProxyCmd for PROXY_RDMA_WRITE_INLINE (#22)
itej89 ebf8bf8
fix: validate atomic target addr against heap range in proxy DrainCq …
itej89 3bca0d4
trial2: atomic fetch round-trip over SEND_WITH_IMM emulation (#25)
itej89 7d16bd4
Merge upstream/main into feat/ep-rdma-sharing
1781fa1
style: fix clang-format and license headers for pre-commit CI
700751a
fix: tag atomic-fetch reply WR with sentinel wr_id to prevent slot 0 …
itej89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
212 changes: 212 additions & 0 deletions
212
include/mori/core/transport/rdma/proxy/proxy_device_primitives.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| // Copyright © Advanced Micro Devices, Inc. All rights reserved. | ||
| // | ||
| // MIT License | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in all | ||
| // copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| // SOFTWARE. | ||
| // Copyright © Advanced Micro Devices, Inc. All rights reserved. | ||
| // MIT License | ||
| #pragma once | ||
|
|
||
| #include "mori/core/transport/rdma/proxy/proxy_types.hpp" | ||
|
|
||
| #ifdef __HIPCC__ | ||
|
|
||
| namespace mori { | ||
| namespace core { | ||
|
|
||
| // Returns sequence number (monotonically increasing). Mask with PROXY_RING_MASK for slot index. | ||
| inline __device__ uint32_t ProxyReserveSlot(volatile ProxyRing* ring) { | ||
| return __hip_atomic_fetch_add((uint32_t*)&ring->gpu_head, 1u, __ATOMIC_RELAXED, | ||
| __HIP_MEMORY_SCOPE_AGENT); | ||
| } | ||
|
|
||
| inline __device__ void ProxyWaitSlotFree(volatile ProxyRing* ring, uint32_t slot) { | ||
| int spins = 0; | ||
| while (true) { | ||
| uint32_t st = __hip_atomic_load((uint32_t*)&ring->cmds[slot].status, __ATOMIC_RELAXED, | ||
| __HIP_MEMORY_SCOPE_SYSTEM); | ||
| if (st == PROXY_FREE || st == PROXY_COMPLETED) break; | ||
| if (++spins % 100000 == 0) __builtin_amdgcn_s_sleep(1); | ||
| } | ||
| } | ||
|
|
||
| inline __device__ void ProxyWaitSlotCompleted(volatile ProxyRing* ring, uint32_t slot) { | ||
| while (true) { | ||
| uint32_t st = __hip_atomic_load((uint32_t*)&ring->cmds[slot].status, __ATOMIC_RELAXED, | ||
| __HIP_MEMORY_SCOPE_SYSTEM); | ||
| if (st == PROXY_COMPLETED || st == PROXY_ERROR) break; | ||
| __builtin_amdgcn_s_sleep(1); | ||
| } | ||
| } | ||
|
|
||
| inline __device__ uint32_t ProxyPostWrite(volatile ProxyRing* ring, uint32_t qp_idx, | ||
| uint64_t src_addr, uint32_t lkey, uint64_t dst_addr, | ||
| uint32_t rkey, uint32_t length) { | ||
| uint32_t seq = ProxyReserveSlot(ring); | ||
| uint32_t slot = seq & PROXY_RING_MASK; | ||
| ProxyWaitSlotFree(ring, slot); | ||
|
|
||
| ring->cmds[slot].op = PROXY_RDMA_WRITE; | ||
| ring->cmds[slot].qp_idx = qp_idx; | ||
| ring->cmds[slot].src_addr = src_addr; | ||
| ring->cmds[slot].dst_addr = dst_addr; | ||
| ring->cmds[slot].length = length; | ||
| ring->cmds[slot].lkey = lkey; | ||
| ring->cmds[slot].rkey = rkey; | ||
| ring->cmds[slot].flags = 1; | ||
|
|
||
| __threadfence_system(); | ||
| ring->cmds[slot].status = PROXY_PENDING; | ||
| return seq; | ||
| } | ||
|
|
||
| inline __device__ uint32_t ProxyPostWriteInline(volatile ProxyRing* ring, uint32_t qp_idx, | ||
| const void* src, uint32_t lkey, uint64_t dst_addr, | ||
| uint32_t rkey, uint32_t length) { | ||
| uint32_t seq = ProxyReserveSlot(ring); | ||
| uint32_t slot = seq & PROXY_RING_MASK; | ||
| ProxyWaitSlotFree(ring, slot); | ||
|
|
||
| ring->cmds[slot].op = PROXY_RDMA_WRITE_INLINE; | ||
| ring->cmds[slot].qp_idx = qp_idx; | ||
| ring->cmds[slot].dst_addr = dst_addr; | ||
| ring->cmds[slot].length = length; | ||
| ring->cmds[slot].lkey = lkey; | ||
| ring->cmds[slot].rkey = rkey; | ||
| ring->cmds[slot].flags = 1; | ||
|
|
||
| if (src != nullptr && length > 0 && length <= PROXY_MAX_INLINE_DATA) { | ||
| const uint64_t* s64 = reinterpret_cast<const uint64_t*>(src); | ||
| volatile uint64_t* d64 = reinterpret_cast<volatile uint64_t*>(ring->cmds[slot].inline_data); | ||
| for (uint32_t i = 0; i < (length + 7) / 8; i++) d64[i] = s64[i]; | ||
| ring->cmds[slot].inline_tag = PROXY_INLINE_SCALAR_WRITE; | ||
| ring->cmds[slot].inline_len = length; | ||
| } else { | ||
| ring->cmds[slot].inline_tag = PROXY_INLINE_NONE; | ||
| ring->cmds[slot].inline_len = 0; | ||
| } | ||
|
|
||
| __threadfence_system(); | ||
| ring->cmds[slot].status = PROXY_PENDING; | ||
| return seq; | ||
| } | ||
|
|
||
| inline __device__ uint32_t ProxyPostAtomicNonFetch(volatile ProxyRing* ring, uint32_t qp_idx, | ||
| uint64_t dst_addr, uint32_t rkey, | ||
| uint64_t add_value, uint32_t lkey, | ||
| uint64_t ibuf_addr) { | ||
| uint32_t seq = ProxyReserveSlot(ring); | ||
| uint32_t slot = seq & PROXY_RING_MASK; | ||
| ProxyWaitSlotFree(ring, slot); | ||
|
|
||
| ring->cmds[slot].op = PROXY_ATOMIC_FETCH_ADD; | ||
| ring->cmds[slot].qp_idx = qp_idx; | ||
| ring->cmds[slot].src_addr = ibuf_addr; | ||
| ring->cmds[slot].dst_addr = dst_addr; | ||
| ring->cmds[slot].length = 8; | ||
| ring->cmds[slot].lkey = lkey; | ||
| ring->cmds[slot].rkey = rkey; | ||
| ring->cmds[slot].atomic_arg = add_value; | ||
| ring->cmds[slot].flags = PROXY_FLAGS_DEFAULT; | ||
|
|
||
| __threadfence_system(); | ||
| ring->cmds[slot].status = PROXY_PENDING; | ||
| return seq; | ||
| } | ||
|
|
||
| // Signal write: RDMA_WRITE of value to remote addr on the SAME NIC path | ||
| // as the preceding data write. Used for signals paired with data | ||
| // (ShmemPutMemNbiSignalThread) to ensure PCIe write ordering. | ||
| inline __device__ uint32_t ProxyPostSignalWrite(volatile ProxyRing* ring, uint32_t qp_idx, | ||
| uint64_t dst_addr, uint32_t rkey, uint64_t value, | ||
| uint32_t lkey, uint64_t ibuf_addr) { | ||
| uint32_t seq = ProxyReserveSlot(ring); | ||
| uint32_t slot = seq & PROXY_RING_MASK; | ||
| ProxyWaitSlotFree(ring, slot); | ||
|
|
||
| ring->cmds[slot].op = PROXY_SIGNAL_WRITE; | ||
| ring->cmds[slot].qp_idx = qp_idx; | ||
| ring->cmds[slot].src_addr = ibuf_addr; | ||
| ring->cmds[slot].dst_addr = dst_addr; | ||
| ring->cmds[slot].length = 8; | ||
| ring->cmds[slot].lkey = lkey; | ||
| ring->cmds[slot].rkey = rkey; | ||
| ring->cmds[slot].atomic_arg = value; | ||
| ring->cmds[slot].flags = 1; | ||
|
|
||
| __threadfence_system(); | ||
| ring->cmds[slot].status = PROXY_PENDING; | ||
| return seq; | ||
| } | ||
|
|
||
| inline __device__ uint64_t ProxyPostAtomicFetch(volatile ProxyRing* ring, uint32_t qp_idx, | ||
| uint64_t dst_addr, uint32_t rkey, | ||
| uint64_t add_value, uint32_t lkey, | ||
| uint64_t ibuf_addr) { | ||
| uint32_t seq = ProxyReserveSlot(ring); | ||
| uint32_t slot = seq & PROXY_RING_MASK; | ||
| ProxyWaitSlotFree(ring, slot); | ||
|
|
||
| ring->cmds[slot].op = PROXY_ATOMIC_FETCH_ADD; | ||
| ring->cmds[slot].qp_idx = qp_idx; | ||
| ring->cmds[slot].src_addr = ibuf_addr; | ||
| ring->cmds[slot].dst_addr = dst_addr; | ||
| ring->cmds[slot].length = 8; | ||
| ring->cmds[slot].lkey = lkey; | ||
| ring->cmds[slot].rkey = rkey; | ||
| ring->cmds[slot].atomic_arg = add_value; | ||
| ring->cmds[slot].flags = PROXY_FLAGS_FETCH_REQUIRED; | ||
| // Store slot index in inline_data so the remote can send it back in the reply | ||
| *reinterpret_cast<volatile uint64_t*>(&ring->cmds[slot].inline_data[0]) = | ||
| static_cast<uint64_t>(slot); | ||
| ring->cmds[slot].result = 0; | ||
|
|
||
| __threadfence_system(); | ||
| ring->cmds[slot].status = PROXY_PENDING; | ||
|
|
||
| ProxyWaitSlotCompleted(ring, slot); | ||
| return ring->cmds[slot].result; | ||
| } | ||
|
|
||
| // Wait for all ops from [first_seq, first_seq + count) to complete. | ||
| // When count > PROXY_RING_SIZE, slots were reused during submission. | ||
| // ProxyWaitSlotFree already ensured earlier slots completed before reuse, | ||
| // so we only need to wait for the tail — the last PROXY_RING_SIZE slots. | ||
| inline __device__ void ProxyQuiet(volatile ProxyRing* ring, uint32_t first_seq, uint32_t count) { | ||
| if (count == 0) return; | ||
| uint32_t start = first_seq; | ||
| if (count > PROXY_RING_SIZE) { | ||
| start = first_seq + count - PROXY_RING_SIZE; | ||
| } | ||
| uint32_t end = first_seq + count; | ||
| for (uint32_t seq = start; seq < end; seq++) { | ||
| uint32_t slot = seq & PROXY_RING_MASK; | ||
| ProxyWaitSlotCompleted(ring, slot); | ||
| } | ||
| } | ||
|
|
||
| // Range variant for multi-warp callers that know the exact range. | ||
| inline __device__ void ProxyQuietRange(volatile ProxyRing* ring, uint32_t from, uint32_t to) { | ||
| ProxyQuiet(ring, from, to - from); | ||
| } | ||
|
|
||
| } // namespace core | ||
| } // namespace mori | ||
|
|
||
| #endif // __HIPCC__ | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // Copyright © Advanced Micro Devices, Inc. All rights reserved. | ||
| // | ||
| // MIT License | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in all | ||
| // copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| // SOFTWARE. | ||
| // Copyright © Advanced Micro Devices, Inc. All rights reserved. | ||
| // MIT License | ||
| #pragma once | ||
|
|
||
| #if !defined(__HIPCC__) && !defined(__CUDACC__) | ||
|
|
||
| #include <infiniband/verbs.h> | ||
| #include <pthread.h> | ||
|
|
||
| #include <atomic> | ||
| #include <vector> | ||
|
|
||
| #include "mori/core/transport/rdma/proxy/proxy_types.hpp" | ||
|
|
||
| namespace mori { | ||
| namespace core { | ||
|
|
||
| struct InlineBuf { | ||
| uint64_t data[4]; | ||
| }; | ||
|
|
||
| struct ProxyQpHandle { | ||
| ibv_qp* qp{nullptr}; | ||
| ibv_cq* cq{nullptr}; | ||
| uint32_t lkey_override{0}; | ||
| uint32_t rkey_override{0}; | ||
| void* recv_buf{nullptr}; | ||
| uint32_t recv_lkey{0}; | ||
| uint32_t recv_count{0}; | ||
| bool use_native_atomics{false}; | ||
| }; | ||
|
|
||
| class ProxyThread { | ||
| public: | ||
| ProxyThread() = default; | ||
| ~ProxyThread(); | ||
|
|
||
| void Init(ProxyRing* ring, std::vector<ProxyQpHandle> qps, int gpuId = 0, uintptr_t heapBase = 0, | ||
| uintptr_t heapEnd = 0); | ||
| void Start(); | ||
| void Shutdown(); | ||
|
|
||
| private: | ||
| static void* ThreadFunc(void* arg); | ||
| void MainLoop(); | ||
| void DrainCq(ProxyQpHandle& qph); | ||
| bool BuildWr(volatile ProxyCmd* cmd, ProxyQpHandle& qph, ibv_send_wr& wr, ibv_sge& sge, | ||
| uint32_t slot_id, InlineBuf& ibuf); | ||
|
|
||
| ProxyRing* ring_{nullptr}; | ||
| std::vector<ProxyQpHandle> qps_; | ||
| pthread_t thread_{}; | ||
| std::atomic<bool> running_{false}; | ||
| uint32_t next_slot_{0}; | ||
| uint64_t ops_posted_{0}; | ||
| uint64_t ops_completed_{0}; | ||
| int gpu_id_{0}; | ||
| uintptr_t heap_base_{0}; | ||
| uintptr_t heap_end_{0}; | ||
| }; | ||
|
|
||
| } // namespace core | ||
| } // namespace mori | ||
|
|
||
| #endif // !defined(__HIPCC__) && !defined(__CUDACC__) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do atomic fetch operations always return 0? Is this the expected?