Files
leleka/engine/strata/sycl/probe/doorbell_store.cpp
T
Pavlo RatushnyiandClaude Sonnet 5.5 87e2633afe engine/strata: bring the Strata subtree to upstream 41cf05a0 (engine 0.1.50) with the local patches re-applied
Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree
(570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base =
the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main).

Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR
experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details,
conflict table and left-out files are in docs/upstream.md.

Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61),
docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out.

scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run").
Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR
macros on. No GPU run, no quality gate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:49:15 +01:00

44 lines
2.3 KiB
C++

// doorbell_store: does the host see a device's store to host USM while the kernel is still running? This is the
// ring publish of Strata's decode handshake (the GPU rings a sequence number the host polls, and the host answers a
// flag the GPU spins on). A `volatile`/atomic store is served from the GPU's cache on an Arc (xe) and reaches the
// host only when the kernel ends; the uncached L1+L3 write hint (strata::sys_store, sycl_doorbell.hpp) reaches memory
// at once. Build twice and compare:
// icpx -fsycl -I sycl/include sycl/probe/doorbell_store.cpp -o /tmp/db # uncached write (the fix)
// icpx -fsycl -DSTRATA_DOORBELL_ATOMIC_STORE -I sycl/include ... -o /tmp/db_atomic # old atomic store
// On an Arc A770 (xe) the first prints "SAW ... at ~0.2 s" with the kernel running to ~2 s; the second prints
// "NEVER SAW" and the value appears only at the kernel's end. Exit 0 when the store was seen mid-kernel.
#include <sycl/sycl.hpp>
#include <cstdio>
#include <chrono>
#include "strata/sycl_doorbell.hpp"
int main() {
sycl::queue q{sycl::gpu_selector_v};
uint32_t* flag = (uint32_t*) sycl::malloc_host(sizeof(uint32_t), q);
*flag = 0;
const auto t0 = std::chrono::steady_clock::now();
q.submit([&](sycl::handler& h) {
h.single_task([=]() {
for (volatile long i = 0; i < 1000000; i++) {} // ~0.2 s before the publish
strata::sys_store(flag, 12345u);
for (volatile long i = 0; i < 10000000; i++) {} // ~2 s more running after the publish
});
});
uint32_t v = 0;
double seen_ms = -1.0;
while (std::chrono::steady_clock::now() - t0 < std::chrono::seconds(6)) {
v = *flag;
if (v == 12345u) { seen_ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count(); break; }
}
q.wait();
const double end_ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count();
#ifdef STRATA_DOORBELL_ATOMIC_STORE
const char* label = "ATOMIC_STORE ";
#else
const char* label = "UNCACHED_WRITE";
#endif
std::printf("%s: host %s flag=%u at %.1f ms; kernel ended at %.1f ms\n", label,
seen_ms >= 0 ? "SAW" : "NEVER SAW", v, seen_ms, end_ms);
return (seen_ms >= 0 && seen_ms < end_ms - 100.0) ? 0 : 3; // seen well before the kernel ended
}