Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions deep_ep/include/deep_ep/common/comm.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,12 @@ __forceinline__ __device__ void gin_barrier_wo_local_sync(
const auto shadow_ptr = gin.getSignalShadowPtr(signal_idx);
const auto target = ++(*shadow_ptr);

const auto gdaki = static_cast<struct ncclGinGdakiGPUContext*>(gin._ginHandle) + gin.contextId;
const auto signal_ptr = reinterpret_cast<uint64_t*>(__ldg(reinterpret_cast<uint64_t*>(&gdaki->signals_table.buffer))) + signal_idx;
timeout_while<kNumTimeoutCycles>([=](const bool& is_last_check) {
const auto signal = ptx::ld_acquire_sys<uint64_t>(signal_ptr);
// Read the signal through the backend-dispatched accessor instead of
// casting the opaque GIN handle to one backend's context struct: the
// handle layout differs per backend, so a direct cast is only correct
// for GDAKI and only at context 0.
const auto signal = gin.readSignal(signal_idx, 64, cuda::memory_order_acquire);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔵 suggestion: Non-blocking: the previous inline-asm poll used ld.acquire.sys.L1::no_allocate.global.u64; cuda::atomic_ref::load (via readSignal) will emit ld.acquire.sys.b64 without the L1::no_allocate hint. Scope/ordering/width/count are preserved, but the cache hint on the busy-wait spin poll is lost. As acknowledged in the PR this is a performance property with no measurement made; if the hint is considered worth keeping on the poll, consider restoring it without reintroducing the cast.

🤖 v3

if (signal >= target)
return true;

Expand Down
9 changes: 5 additions & 4 deletions deep_ep/include/deep_ep/impls/pp_send_recv.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ __device__ __forceinline__ void check_signal(
const ncclGinSignal_t& signal_idx,
const int64_t& target,
const timeout_print_t& timeout_print) {
const auto gdaki = static_cast<struct ncclGinGdakiGPUContext*>(gin.gin._ginHandle) + gin.gin.contextId;
const auto signal_ptr = reinterpret_cast<int64_t*>(
__ldg(reinterpret_cast<int64_t*>(&gdaki->signals_table.buffer))) + signal_idx;
comm::timeout_while<kNumTimeoutCycles>([=](const bool& is_last_check) {
const auto signal = ptx::ld_acquire_sys<int64_t>(signal_ptr);
// Read the signal through the backend-dispatched accessor instead of casting
// the opaque GIN handle to one backend's context struct. The result is cast
// back to int64_t so the comparison below stays signed: `target` is allowed
// to be negative here (send_count - num_max_inflight_tensors + 1).
const auto signal = static_cast<int64_t>(gin.gin.readSignal(signal_idx, 64, cuda::memory_order_acquire));
if (signal >= target)
return true;

Expand Down