sycl: the PCIe probe's pinned source (PR #1669) only on a layer split; a single card keeps the pageable source

Pinned memory reads the link 1.7x faster (A750 10.3 -> 17.2 GB/s, B70 13.6 -> 25.6), which moves the derived default pcie_frac
(A750 0.28 -> 0.47) and cost 10% of decode there (median 12.07 -> 10.67 tok/s, 4 of 5 interleaved pairs slower). The B70 is unchanged
(0.37 -> 0.55, 31.4 vs 31.4). The fault the PR fixes is a layer split's.

Co-authored-by: maxious <maxious@lambdacomplex.org>
This commit is contained in:
Niko1221andmaxious committed 2026-10-09 16:45:52 +02:00
1 parent 9310d3bdf8
commit 3540500232
1 file changed
+8 -6
+8 -6
View File
@@ -1500,15 +1500,17 @@ bool load_control_vectors(const Options& o, const strata::core::ModelGeometry& g
// median would still follow a disturbance that lasts through half the bursts). Each burst takes ~10 ms on an x16
// PCIe 4 link, so the probe takes no longer than the one 1 GiB burst did. `samples`, when given, gets every
// burst's reading for the log.
double probe_pcie_h2d_gbps(std::string *samples = nullptr) try {
double probe_pcie_h2d_gbps(std::string *samples = nullptr, bool pin_source = false) try {
constexpr size_t kBytes = 256ull << 20;
constexpr int kBursts = 4;
void* h = nullptr;
void* d = nullptr;
if (DPCT_CHECK_ERROR(h = (void *)sycl::malloc_host(kBytes, dpct::get_in_order_queue())) != 0) return -1.0;
// PR #1669: a pageable source made the copy engine fault on a layer split (VM_NOT_FOUND), so a split pins it. A single card keeps the
// pageable source of 0.1.41: pinned reads 1.7x faster, which moves the default pcie_frac (A750 0.28 -> 0.47, 10% slower decode).
if (DPCT_CHECK_ERROR(h = pin_source ? (void *)sycl::malloc_host(kBytes, dpct::get_in_order_queue()) : (void *)malloc(kBytes)) != 0 || h == nullptr) return -1.0;
if (DPCT_CHECK_ERROR(d = (void *)sycl::malloc_device(
kBytes, dpct::get_in_order_queue())) != 0) {
sycl::free(h, dpct::get_in_order_queue());
if (pin_source) sycl::free(h, dpct::get_in_order_queue()); else free(h);
return -1.0;
}
std::memset(h, 0, kBytes); // fault the pages in before timing
@@ -1577,7 +1579,7 @@ double probe_pcie_h2d_gbps(std::string *samples = nullptr) try {
*/
if (!ok)(void) 0;
sycl::free(d, dpct::get_in_order_queue());
sycl::free(h, dpct::get_in_order_queue());
if (pin_source) sycl::free(h, dpct::get_in_order_queue()); else free(h);
return bw;
}
catch (sycl::exception const &exc) {
@@ -2537,7 +2539,7 @@ int main(int argc, char **argv) try {
if (o.pcie_frac < 0.0) {
const double base = native_pack ? 0.55 : 0.2;
std::string bursts;
const double bw = native_pack ? probe_pcie_h2d_gbps(&bursts) : -1.0;
const double bw = native_pack ? probe_pcie_h2d_gbps(&bursts, multi_gpu) : -1.0;
if (!native_pack) {
o.pcie_frac = base;
} else if (bw > 0.0) {
@@ -3337,7 +3339,7 @@ int main(int argc, char **argv) try {
st.pcie_frac = o.pcie_frac;
if (!pcie_given && native_pack) {
std::string bursts;
const double bw = probe_pcie_h2d_gbps(&bursts);
const double bw = probe_pcie_h2d_gbps(&bursts, true);
if (bw > 0.0) st.pcie_frac = pcie_frac_for_gbps(bw, 0.55);
std::fprintf(stderr, "strata generate: layer split: CUDA%d PCIe probe %.1f GB/s (best of %s) -> pcie_frac "
"%.2f\n", st.dev, bw, bursts.c_str(), st.pcie_frac);