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++

prefill: guard std::atomic::wait/notify_all with __cpp_lib_atomic_wait so a GCC 10 build spins as before #1057 (#1488)

Niko1221df29e3b2e629
diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp
index 4e03dc8b6..7a92b58ce 100644
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -1,5 +1,9 @@
// src/prefill/prefill.cpp - see include/strata/prefill/prefill.hpp.
#include "strata/prefill/prefill.hpp"
+#include <atomic>
+#if defined(__cpp_lib_atomic_wait)
+#define STRATA_ATOMIC_WAIT 1 // #1488: std::atomic::wait / notify_all are a GCC 11 library feature; GCC 10 spins instead
+#endif
#include "mmq_resident_sort.hpp"
#include "wmma_gemm.h"
#include "strata/core/mtp.hpp"
@@ -477,9 +481,11 @@ struct Stager {
// (atomic wait, and a blocking-sync event below), not a yield spin - 32 spinners took every core
// (Linux; see stager_sleep for Windows).
if (i >= kRing) { // job i - kRing's DMA from this buffer is queued
+#if defined(STRATA_ATOMIC_WAIT)
if (stager_sleep())
for (int x; (x = issued.load(std::memory_order_acquire)) <= i - kRing;) issued.wait(x);
else
+#endif
while (issued.load(std::memory_order_acquire) <= i - kRing) std::this_thread::yield();
}
// and done - for a generation's first kRing jobs that is the previous generation's last DMA from
@@ -541,13 +547,17 @@ struct Stager {
void issued_one(int j, cudaStream_t copy) {
cudaEventRecord(dma_done[j % kRing], copy);
issued.store(j + 1, std::memory_order_release);
+#if defined(STRATA_ATOMIC_WAIT)
issued.notify_all();
+#endif
}
/// No job is running after this (the end of a layer, or an early return in the middle of one).
void finish() {
head.store((uint64_t) gen << 32, std::memory_order_release); // n = 0: nothing more to claim
issued.store(1 << 30, std::memory_order_release);
+#if defined(STRATA_ATOMIC_WAIT)
issued.notify_all();
+#endif
while (active.load(std::memory_order_acquire) != 0) std::this_thread::yield();
}
};