Skip to content

Commit

Permalink
[Bugfix] Implement acquire/release polyfill for Pascal
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha0552 authored Sep 24, 2024
1 parent cc4325b commit 439e60d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions csrc/custom_all_reduce.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,26 @@ DINLINE O downcast(array_t<float, O::size> val) {
}

static DINLINE void st_flag_release(FlagType* flag_addr, FlagType flag) {
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700
asm volatile("st.release.sys.global.u32 [%1], %0;" ::"r"(flag),
"l"(flag_addr));
#else
asm volatile("membar.sys; st.volatile.global.u32 [%1], %0;" ::"r"(flag),
"l"(flag_addr));
#endif
}

static DINLINE FlagType ld_flag_acquire(FlagType* flag_addr) {
FlagType flag;
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700
asm volatile("ld.acquire.sys.global.u32 %0, [%1];"
: "=r"(flag)
: "l"(flag_addr));
#else
asm volatile("ld.volatile.sys.global.u32 %0, [%1]; membar.gl;"
: "=r"(flag)
: "l"(flag_addr));
#endif
return flag;
}

Expand Down

0 comments on commit 439e60d

Please sign in to comment.