Fix relaxedWait() (#594)

This commit is contained in:
Changho Hwang
2025-08-01 12:51:30 +08:00
committed by GitHub
parent 5b84c8a3d1
commit aa28b06bf5

View File

@@ -77,7 +77,7 @@ struct MemoryDevice2DeviceSemaphoreDeviceHandle {
/// Relaxed wait; no memory completion guarantee. Use it only for synchronizing execution, not data.
MSCCLPP_DEVICE_INLINE void relaxedWait([[maybe_unused]] int64_t maxSpinCount = 100000000) {
auto expected = incExpectedInbound();
POLL_MAYBE_JAILBREAK((loadInbound() < expected), maxSpinCount);
POLL_MAYBE_JAILBREAK((loadInboundRelaxed() < expected), maxSpinCount);
}
/// Signal remote device, ensures prior memory ops complete.
@@ -115,6 +115,12 @@ struct MemoryDevice2DeviceSemaphoreDeviceHandle {
return atomicLoad<uint64_t, scopeSystem>(inboundToken, memoryOrderAcquire);
}
/// Thread-safe read of inbound value without memory completion guarantee.
/// @return The inbound value.
MSCCLPP_DEVICE_INLINE uint64_t loadInboundRelaxed() {
return atomicLoad<uint64_t, scopeSystem>(inboundToken, memoryOrderRelaxed);
}
/// Thread-safe read of outbound value.
/// @return The outbound value.
MSCCLPP_DEVICE_INLINE uint64_t loadOutbound() {