diff --git a/include/svs/lib/prefetch.h b/include/svs/lib/prefetch.h index 0fd438ba..416195e9 100644 --- a/include/svs/lib/prefetch.h +++ b/include/svs/lib/prefetch.h @@ -18,6 +18,7 @@ #include "svs/lib/misc.h" +#include #include #include #include @@ -56,8 +57,11 @@ template void prefetch_l0(std::span span) ); } + // The fence is a no-op at runtime; without it GCC 12 drops all but the first + // prefetch here, so neighbor vectors load cold from DRAM and search slows ~24%. for (size_t i = 0; i < num_prefetches; ++i) { prefetch_l0(base + CACHELINE_BYTES * i); + std::atomic_signal_fence(std::memory_order_seq_cst); } }