Skip to content

Commit

Permalink
fifo should be correct now as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
eschouks committed Oct 6, 2023
1 parent d985516 commit 8dfdf11
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/semaphore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ MSCCLPP_API_CPP void Host2HostSemaphore::signal() {
}

MSCCLPP_API_CPP bool Host2HostSemaphore::poll() {
bool signaled = (*(volatile uint64_t*)localInboundSemaphore_.get() > (*expectedInboundSemaphore_));
bool signaled = (cuda::atomic_ref<uint64_t, cuda::thread_scope_system>{*(uint64_t*)localInboundSemaphore_.get()}.load(
cuda::memory_order_acquire) > (*expectedInboundSemaphore_));
if (signaled) (*expectedInboundSemaphore_) += 1;
return signaled;
}

MSCCLPP_API_CPP void Host2HostSemaphore::wait(int64_t maxSpinCount) {
(*expectedInboundSemaphore_) += 1;
int64_t spinCount = 0;
while (*(volatile uint64_t*)localInboundSemaphore_.get() < (*expectedInboundSemaphore_)) {
while (cuda::atomic_ref<uint64_t, cuda::thread_scope_system>{*(uint64_t*)localInboundSemaphore_.get()}.load(
cuda::memory_order_acquire) < (*expectedInboundSemaphore_)) {
if (spinCount++ == maxSpinCount) {
throw Error("Host2HostSemaphore::wait timed out", ErrorCode::Timeout);
}
Expand Down

0 comments on commit 8dfdf11

Please sign in to comment.