From e52051dc71fc79f27243862b38830c706689c46c Mon Sep 17 00:00:00 2001 From: BlueKingMuch <53972523+BlueKingMuch@users.noreply.github.com> Date: Thu, 1 Oct 2026 11:04:51 +0000 Subject: [PATCH] HIP: time the PCIe probe on the host on Windows The PCIe probe sets the share of the missed experts the GPU reads over the link (--pcie-frac): the native default 0.55 from 20 GB/s up, less on a slower link (#44). On Windows HIP it timed its copies with events that do not bracket them there: an RX 6800 read between 3,348 and 25,999 GB/s in 24 engine starts, so every link kept the x16 share. A standalone copy of the probe on that card: its events measure 0.13 ms for the 1 GiB, the host clock 43 ms (25.1 GB/s). On Windows HIP the probe now times the same copies on the host, between two synchronizes (1 GiB, tens of milliseconds): the same RX 6800 on PCIe 4.0 x16 reads 27.2 GB/s in every run, which keeps 0.55 there. On a PCIe 4.0 x8 or 3.0 x16 link the share now shrinks as #44 intended. CUDA and Linux keep the events. --- src/program/generate.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/program/generate.cpp b/src/program/generate.cpp index c447dd76..609179ba 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -971,12 +971,24 @@ double probe_pcie_h2d_gbps() { } std::memset(h, 0, kBytes); // fault the pages in before timing cudaMemcpyAsync(d, h, kBytes, cudaMemcpyHostToDevice); // warmup: context up, copy engine primed +#if defined(STRATA_USE_HIP) && defined(_WIN32) + // Windows HIP: the events do not bracket the copies there (an RX 6800 read 3,300-26,000 GB/s, so every link kept + // the x16 share), so the copies are timed on the host: 1 GiB takes tens of milliseconds, so the synchronize + // around them hardly matters + const bool warm = cudaDeviceSynchronize() == cudaSuccess; + const Clock::time_point t0 = Clock::now(); + for (int i = 0; i < kIters; ++i) cudaMemcpyAsync(d, h, kBytes, cudaMemcpyHostToDevice); + const bool ok = warm && cudaDeviceSynchronize() == cudaSuccess; + const float ms = (float) std::chrono::duration(Clock::now() - t0).count(); + const bool timed = ok && ms > 0.01f; +#else cudaEventRecord(ev0); for (int i = 0; i < kIters; ++i) cudaMemcpyAsync(d, h, kBytes, cudaMemcpyHostToDevice); cudaEventRecord(ev1); const bool ok = cudaEventSynchronize(ev1) == cudaSuccess; float ms = 0.f; const bool timed = ok && cudaEventElapsedTime(&ms, ev0, ev1) == cudaSuccess && ms > 0.01f; +#endif const double bw = timed ? ((double) kIters * (double) kBytes / (ms * 1e-3)) / 1e9 : -1.0; cudaEventDestroy(ev0); cudaEventDestroy(ev1);