Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

doorbell_ring: a volatile store, so the host sees the ring on RDNA4 without a stream sync

Niko122170e24f43e3c5
diff --git a/src/kernels/cuda/elementwise.cu b/src/kernels/cuda/elementwise.cu
index a2e9e53b5..edf8ece0a 100644
--- a/src/kernels/cuda/elementwise.cu
+++ b/src/kernels/cuda/elementwise.cu
@@ -201,9 +201,13 @@ void silu_inplace(float* x, int64_t n, void* stream) {
/// the write was not ordered into host-visible memory, so no amount of reading it would show it, and the driver
/// call was flushing the whole pipeline enough to make it appear. A 10-22 us driver call per iteration is a
/// very expensive substitute for one fence instruction.
+///
+/// **THE STORE IS VOLATILE**, like `doorbell_publish_kernel`'s. On RDNA4 (gfx1201) a plain store to mapped pinned
+/// memory stays in the GPU's L2 until the stream is synchronized - the host never saw the ring (tests/hip/handoff:
+/// 0 of 100 rings seen without a sync; volatile, a system-scope atomic store or a fence after the store: 100 of 100).
__global__ void doorbell_ring_kernel(uint32_t* seq) {
__threadfence_system();
- *seq = *seq + 1u;
+ *(volatile uint32_t*) seq = *(volatile uint32_t*) seq + 1u;
}
__global__ void doorbell_wait_kernel(const volatile uint32_t* flag, const volatile uint32_t* seq) {