From 0e8ff6bd34893e4e39ad3fc3ea7371f5e2465ff7 Mon Sep 17 00:00:00 2001 From: Massimiliano Meneghin Date: Thu, 26 Nov 2026 04:15:51 -0500 Subject: [PATCH] Skeleton halo transfer matrix; export_dot defaults to the launch matrix Halo descriptors report this rank's cross-rank messages (DistMessage: op, peer, elements, bytes, NCCL group) and Skeleton::halo_messages / gather_halo_messages / export_transfer_matrix_{csv,csv_file,text} read them from the compiled halo kernels without launching anything. LBM gains --export-transfers PATH and --compile-only, plus plot_transfers.py for the rank x message heatmap. Skeleton::export_dot / export_dot_file now render the launch matrix (like export_dot_png); the stream-cluster graph is export_streams_dot / export_streams_dot_file, used by the *_streams.dot sidecars and the tests. Co-authored-by: Cursor --- benchmarks/cg/cg_poisson.cu | 2 +- benchmarks/jacobi_nvidia/jacobi_nvidia.cu | 2 +- benchmarks/lbm_ldc/README.md | 18 ++ benchmarks/lbm_ldc/lbm_ldc.cu | 46 +++- .../scripts/plotting/plot_transfers.py | 170 +++++++++++++++ docs/CHANGELOG.md | 21 ++ docs/skeleton/README.md | 41 +++- examples/cg_poisson_unified.cu | 2 +- include/carbon/detail/halo_kernel_impl_base.h | 9 + include/carbon/detail/kernel_impl.h | 10 + include/carbon/dist_message.h | 34 +++ include/carbon/dist_transfer.h | 27 ++- include/carbon/halo.h | 14 ++ include/carbon/halo_disg.h | 14 ++ include/carbon/halo_disg_distributed.h | 14 ++ include/carbon/halo_distributed.h | 33 +++ include/carbon/kernel.h | 9 + include/carbon/skeleton.h | 103 +++++++-- src/skeleton.cpp | 205 +++++++++++++++++- tests/test_skeleton.cu | 8 +- tests/test_skeleton_region_mask.cu | 7 +- tests/test_skeleton_scalar_pattern.cu | 2 +- 22 files changed, 741 insertions(+), 50 deletions(-) create mode 100644 benchmarks/lbm_ldc/scripts/plotting/plot_transfers.py create mode 100644 include/carbon/dist_message.h diff --git a/benchmarks/cg/cg_poisson.cu b/benchmarks/cg/cg_poisson.cu index c2245219..f539352d 100644 --- a/benchmarks/cg/cg_poisson.cu +++ b/benchmarks/cg/cg_poisson.cu @@ -939,7 +939,7 @@ run_cg(Grid& grid, if (!sk.export_launch_matrix_dot_file(base + ".dot", std::string{"cg_"} + tag)) { CARBON_LOG_ERROR("cg_poisson_unified: failed to write {}.dot", base); } - if (!sk.export_dot_file(base + "_streams.dot", std::string{"cg_"} + tag)) { + if (!sk.export_streams_dot_file(base + "_streams.dot", std::string{"cg_"} + tag)) { CARBON_LOG_ERROR("cg_poisson_unified: failed to write {}_streams.dot", base); } if (!sk.export_launch_order_file(base + ".txt")) { diff --git a/benchmarks/jacobi_nvidia/jacobi_nvidia.cu b/benchmarks/jacobi_nvidia/jacobi_nvidia.cu index fd4d49cd..9d139033 100644 --- a/benchmarks/jacobi_nvidia/jacobi_nvidia.cu +++ b/benchmarks/jacobi_nvidia/jacobi_nvidia.cu @@ -477,7 +477,7 @@ run_solver(DenseGrid& grid, std::string{"jacobi"} + tag)) { std::fprintf(stderr, "jacobi_nvidia: failed to write %s%s.dot\n", dot_prefix.c_str(), tag); } - if (!sk->export_dot_file(dot_prefix + tag + "_streams.dot")) { + if (!sk->export_streams_dot_file(dot_prefix + tag + "_streams.dot")) { std::fprintf(stderr, "jacobi_nvidia: failed to write %s%s_streams.dot\n", dot_prefix.c_str(), tag); } diff --git a/benchmarks/lbm_ldc/README.md b/benchmarks/lbm_ldc/README.md index be5ada8c..28a5ee3b 100644 --- a/benchmarks/lbm_ldc/README.md +++ b/benchmarks/lbm_ldc/README.md @@ -17,6 +17,7 @@ Run every command from the carbon repository root. | `scripts/plotting/plot_scaling.py` | plot MLUPS per GPU vs GPUs and vs N, the hp-halo speedup, and all grids on shared axes | | `scripts/plotting/plot_disg_vs_dense.py` | plot the DenseDisg / Dense ratio | | `scripts/plotting/plot_best_family.py` | colour an N × GPU-count map by the fastest of Dense / DenseDisg × Peeraccess / NCCL | +| `scripts/plotting/plot_transfers.py` | plot the rank × message halo transfer matrix of `--export-transfers` | A YAML file lists *experiments*, each with a type (`strong_scaling`, `domain_size`, `best_family`) that decides its figures, and its own run @@ -140,3 +141,20 @@ python3 benchmarks/lbm_ldc/scripts/plotting/plot_scaling.py --config $cfg [`reference/`](reference/) is a committed copy of a full DGX sweep: its YAML, 1050 JSON reports and the figures. To plot your own `data/` against the same experiments, pass `--data-dir benchmarks/lbm_ldc/data`. + +## Example 6 — halo transfers per rank, without running + +`--export-transfers PATH` reads the cross-rank halo messages of one iteration +from the compiled skeleton and writes them as CSV (one line per rank × +message: launch, NCCL group, send / receive, peer rank, bytes); rank 0 also +logs the rank × message matrix. `--compile-only` exits before the solver +loop, so no iteration runs. + +```bash +mpiexec -n 8 build-mpi/benchmarks/lbm_ldc/carbon_benchmark_lbm_ldc \ + --grid disg_distributed --decomposition pencil --gpus 1 --n 512 \ + --export-transfers benchmarks/lbm_ldc/data/disg_distributed-pencil-mpi-g8-transfers.csv --compile-only +python3 benchmarks/lbm_ldc/scripts/plotting/plot_transfers.py \ + benchmarks/lbm_ldc/data/disg_distributed-pencil-mpi-g8-transfers.csv +# -> data/disg_distributed-pencil-mpi-g8-transfers.png: rank on y, message on x, size as colour +``` diff --git a/benchmarks/lbm_ldc/lbm_ldc.cu b/benchmarks/lbm_ldc/lbm_ldc.cu index 8fb0b1ea..84a94913 100644 --- a/benchmarks/lbm_ldc/lbm_ldc.cu +++ b/benchmarks/lbm_ldc/lbm_ldc.cu @@ -155,6 +155,11 @@ struct Options { std::string export_dot_path = ""; std::string export_dot_png_path = ""; std::string export_dot_streams_path = ""; + // CSV of every rank's cross-rank halo messages of one sk_ab iteration, read from the + // compiled skeleton. + std::string export_transfers_path = ""; + // Stop after compiling the skeletons and writing the exports; no solver iterations. + bool compile_only = false; // Opt in to carbon::Skeleton CUDA-graph capture + replay of each ping-pong // skeleton. Engaged only for single-GPU / single-stream schedules (the // OverlapMode::None single-GPU case); a no-op fallback otherwise. @@ -241,6 +246,15 @@ build_cli(Options& opts) -> clipp::group { "PATH). Also writes a sibling .dot file.", (option("--export-dot-streams") & value("path", opts.export_dot_streams_path)) % "Write the stream-cluster schedule graph (legacy export_dot format) to PATH.", + (option("--export-transfers") & value("path", opts.export_transfers_path)) % + "Write the cross-rank halo messages of one skeleton iteration as CSV to PATH, read " + "from the compiled skeleton (nothing is launched): one row per rank x message with " + "its launch, NCCL group, direction, peer rank and bytes. Rank 0 also logs the " + "rank x message matrix. Needs an mpiexec launch for cross-rank traffic. Plot with " + "scripts/plotting/plot_transfers.py.", + option("--compile-only").set(opts.compile_only) % + "Exit after compiling the skeletons and writing the --export-* files, without " + "running the solver loop.", option("--cuda-graph").set(opts.cuda_graph) % "Capture + replay each ping-pong skeleton as a CUDA graph (single-GPU / " "single-stream only; transparently falls back to eager launch otherwise). " @@ -721,12 +735,42 @@ run_benchmark(const Options& opts, CARBON_LOG_INFO("lbm_ldc: wrote launch-matrix PNG to {}", opts.export_dot_png_path); } if (!opts.export_dot_streams_path.empty()) { - if (!sk_ab.export_dot_file(opts.export_dot_streams_path, "lbm_sk_ab")) { + if (!sk_ab.export_streams_dot_file(opts.export_dot_streams_path, "lbm_sk_ab")) { CARBON_LOG_ERROR("lbm_ldc: --export-dot-streams failed for {}", opts.export_dot_streams_path); return EXIT_FAILURE; } CARBON_LOG_INFO("lbm_ldc: wrote stream-cluster DOT to {}", opts.export_dot_streams_path); } + if (!opts.export_transfers_path.empty()) { + // Collective over all ranks: every rank's messages are read from its compiled sk_ab. + const std::string matrix = sk_ab.export_transfer_matrix_text(); + std::ostringstream about; + about << "grid=" << opts.grid << "\ndecomposition=" << decomposition_mode_name(dec_mode); + if (pg) { + const carbon::int32_3d dims = pg->dims(); + about << "\nprocess_grid=" << dims.x << 'x' << dims.y << 'x' << dims.z; + } + about << "\nn=" << opts.n << "\nranks=" << world_size << "\ngpus=" << total_gpu_count + << "\nlattice=" << lattice_name << "\ncollision=" << collision_name + << "\nprecision=" << opts.precision << "\noverlap=" << opts.overlap; + if (!sk_ab.export_transfer_matrix_csv_file(opts.export_transfers_path, about.str())) { + CARBON_LOG_ERROR("lbm_ldc: --export-transfers failed for {}", opts.export_transfers_path); + return EXIT_FAILURE; + } + if (world_rank == 0) { + CARBON_LOG_INFO( + "lbm_ldc: cross-rank halo messages of one sk_ab iteration (grid={} " + "decomposition={}):\n{}", + opts.grid, decomposition_mode_name(dec_mode), matrix); + CARBON_LOG_INFO("lbm_ldc: wrote transfer matrix CSV to {}", opts.export_transfers_path); + } + } + if (opts.compile_only) { + if (world_rank == 0) { + CARBON_LOG_INFO("lbm_ldc: --compile-only, exiting before the solver loop"); + } + return EXIT_SUCCESS; + } using Clock = std::chrono::steady_clock; using Seconds = std::chrono::duration; diff --git a/benchmarks/lbm_ldc/scripts/plotting/plot_transfers.py b/benchmarks/lbm_ldc/scripts/plotting/plot_transfers.py new file mode 100644 index 00000000..0568559a --- /dev/null +++ b/benchmarks/lbm_ldc/scripts/plotting/plot_transfers.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python3 +"""Plot the rank x message transfer matrix written by ``lbm_ldc --export-transfers``. + +The CSV (``rank,index,seq,kernel,group,op,peer,elements,bytes``) lists every cross-rank halo +message of one skeleton iteration, read from the compiled ``carbon::Skeleton``; the +``# key=value`` lines above its header (grid, decomposition, process grid, N, ...) make +the first line of the title. The plot +has one row per rank and one column per message in issue order; the colour is the +message size and each cell reads ``S>p`` (send to rank p) or ``R argparse.Namespace: + p = argparse.ArgumentParser(description="Plot the rank x message transfer matrix.") + p.add_argument("csv", type=Path, help="CSV written by --export-transfers") + p.add_argument("--out", type=Path, default=None, + help="output PNG (default: the CSV path with a .png suffix)") + return p.parse_args() + + +def checked_paths(args: argparse.Namespace) -> tuple[Path, Path]: + """Resolve and validate the command-line paths: an existing .csv in, a .png out.""" + src = args.csv.expanduser().resolve() + if src.suffix.lower() != ".csv" or not src.is_file(): + raise ValueError(f"{args.csv}: not an existing .csv file") + out = (args.out.expanduser().resolve() if args.out is not None + else src.with_suffix(".png")) + if out.suffix.lower() != ".png": + raise ValueError(f"{out}: output must end in .png") + if not out.parent.is_dir(): + raise ValueError(f"{out.parent}: output directory does not exist") + return src, out + + +def read_messages(src: Path) -> tuple[dict[str, str], list[dict]]: + """``# key=value`` lines above the header (the run description), then the messages.""" + meta: dict[str, str] = {} + body: list[str] = [] + with src.open(newline="") as f: + for line in f: + if line.startswith("#"): + key, sep, value = line[1:].strip().partition("=") + if sep and key.replace("_", "").isalnum(): + meta[key] = value + else: + body.append(line) + reader = csv.DictReader(body) + if tuple(reader.fieldnames or ()) != COLUMNS: + raise ValueError(f"{src}: expected header {','.join(COLUMNS)}") + rows = [] + for r in reader: + if r["op"] not in ("send", "recv"): + raise ValueError(f"{src}: bad op {r['op']!r}") + rows.append({"rank": int(r["rank"]), "index": int(r["index"]), + "seq": int(r["seq"]), "kernel": r["kernel"], + "op": r["op"], "peer": int(r["peer"]), "elements": int(r["elements"]), + "bytes": int(r["bytes"])}) + return meta, rows + + +def run_title(meta: dict[str, str]) -> str: + """One line describing the run, e.g. ``DenseDisgDistributed, slab (z) 1x1x8, N = 512``.""" + if "grid" not in meta: + return "" + parts = [lr.GRID_TITLES.get(meta["grid"], meta["grid"])] + if meta["grid"] in sc.DISTRIBUTED_GRIDS and "decomposition" in meta: + decomp = lr.DECOMP_TITLES.get(meta["decomposition"], meta["decomposition"]) + parts.append(f"{decomp} {meta.get('process_grid', '')}".strip()) + if "n" in meta: + parts.append(f"N = {meta['n']}") + if "ranks" in meta: + parts.append(f"{meta['ranks']} ranks") + model = " ".join(meta[k] for k in ("lattice", "collision", "precision") if k in meta) + if model: + parts.append(model) + return ", ".join(parts) + + +def megabytes(n: int) -> str: + return f"{n / 1e6:.2f} MB" if n >= 1_000_000 else f"{n / 1e3:.1f} KB" + + +def plot(rows: list[dict], title: str, out: Path) -> None: + ranks = max(r["rank"] for r in rows) + 1 + cols = max(r["index"] for r in rows) + 1 + grid = [[math.nan] * cols for _ in range(ranks)] + for r in rows: + grid[r["rank"]][r["index"]] = r["bytes"] / 1e6 + + width = max(7.0, 0.95 * cols + 4.5) + fig, ax = plt.subplots(figsize=(width, max(3.0, 0.6 * ranks + 1.8))) + cmap = plt.get_cmap("viridis").copy() + cmap.set_bad("#f2f2f2") + vmax = max(r["bytes"] for r in rows) / 1e6 + im = ax.imshow(grid, cmap=cmap, aspect="auto", interpolation="nearest", vmin=0.0, vmax=vmax) + for r in rows: + mb = r["bytes"] / 1e6 + arrow = f"S>{r['peer']}" if r["op"] == "send" else f"R<{r['peer']}" + ax.text(r["index"], r["rank"], f"{arrow}\n{megabytes(r['bytes'])}\n{r['elements']:,} el", ha="center", + va="center", fontsize=7, color="black" if mb > 0.6 * vmax else "white") + + totals = [] + for rank in range(ranks): + mine = [r for r in rows if r["rank"] == rank] + sent = sum(r["bytes"] for r in mine if r["op"] == "send") + totals.append(f"{len(mine)} msgs, {megabytes(sent)} sent") + + ax.set_xticks(range(cols), [f"msg {i}" for i in range(cols)], fontsize=8) + ax.set_yticks(range(ranks), [f"rank {i}" for i in range(ranks)]) + right = ax.secondary_yaxis("right") + right.set_yticks(range(ranks), totals, fontsize=8) + ax.set_xlabel("message (issue order)") + ax.set_title(title, fontsize=10) + # pad is a fraction of the axes width; keep ~1.7 in free for the right-hand totals. + fig.colorbar(im, ax=ax, label="MB", pad=1.7 / (width - 2.8)) + fig.tight_layout() + fig.savefig(out, dpi=150) + plt.close(fig) + + +def main() -> int: + args = parse_args() + try: + src, out = checked_paths(args) + meta, rows = read_messages(src) + except (OSError, ValueError, KeyError) as e: + sys.stderr.write(f"error: {e}\n") + return 1 + if not rows: + print(f"note: {src} has no cross-rank messages, nothing to plot") + return 0 + kernels = sorted({(r["seq"], r["kernel"]) for r in rows}) + lines = [run_title(meta), "Cross-rank halo messages per skeleton iteration", + ", ".join(f"#{seq} {name}" for seq, name in kernels)] + title = "\n".join(line for line in lines if line) + plot(rows, title, out) + print(f"wrote {out}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e60f3f32..1354c536 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6696,3 +6696,24 @@ This unblocked the matrix on this host: the `sycl` and `hip-nvidia` images build follow. Scripts, YAMLs, docs and the include path of the examples are updated; the committed reference reports keep the old `benchmark` value they were written with. +- **2026-11 — Halo transfer matrix from the Skeleton.** `DistOp` / `DistMessage` move to + the NCCL-free ``; the four dense halo descriptors gain + `dist_messages()` (this rank's cross-rank messages of one exchange with element count + and bytes, empty without MPI), + surfaced through `KernelImpl::dist_messages()` / `Kernel::dist_messages()`. `Skeleton` + gains `halo_messages()` (per halo launch, in `run()` order), the collective + `gather_halo_messages()` (count and lists broadcast from each rank) and + `export_transfer_matrix_csv[_file]()` / `export_transfer_matrix_text()`. All of it + reads the compiled halo kernels: nothing is launched. LBM adds `--export-transfers PATH` + and `--compile-only` (exit before the solver loop) plus + `scripts/plotting/plot_transfers.py` (rank × message heatmap). N=512 + DenseDisgDistributed on 8 ranks: slab sends 2 × 5.24 MB per interior rank; pencil + 1x2x4 sends 7 messages (2.62 MB z-faces, 3.41 MB y-faces, 26.6 KB edges) per interior + rank; brick 2x2x2 sends 6 per rank, 12.88 MB in total. +- **2026-11 — `Skeleton::export_dot` defaults to the launch matrix.** `export_dot()` / + `export_dot_file()` now return / write `export_launch_matrix_dot()`, matching + `export_dot_png()`, so `log_dot_on_compile`, the examples' `--dot` logs and dumps and the + Python `ioToDot` all produce the launch matrix. The stream-cluster graph is renamed + `export_streams_dot()` / `export_streams_dot_file()`; the `*_streams.dot` sidecars of + jacobi_nvidia, cg and LBM `--export-dot-streams`, and the tests that check its text + (stream clusters, field labels, region-mask tooltips, the copy stream) use the new names. diff --git a/docs/skeleton/README.md b/docs/skeleton/README.md index 7f6e9dce..7a3da340 100644 --- a/docs/skeleton/README.md +++ b/docs/skeleton/README.md @@ -1,12 +1,18 @@ # Skeleton DAG export — reference renderings Visual snapshots of the dependency DAG `carbon::Skeleton` infers from a Jacobi -ping-pong pipeline, produced by `Skeleton::export_dot` (see -``). +ping-pong pipeline, in the stream-cluster format of +`Skeleton::export_streams_dot` (see ``). + +`Skeleton::export_dot()` / `export_dot_file()` / `export_dot_png()` and the +`log_dot_on_compile` option render the **launch matrix** by default (same as +`export_launch_matrix_dot()`, see [Launch order listing](#launch-order-listing)); +the stream-cluster graph shown here is `export_streams_dot()` / +`export_streams_dot_file()`. | File | Source | |------|--------| -| `jacobi_skeleton.dot` | Raw GraphViz DOT, captured from `examples/jacobi_unified.cu --dot`'s `CARBON_LOG_INFO("--- DAG (GraphViz DOT) ---")` block. | +| `jacobi_skeleton.dot` | Raw GraphViz DOT of `export_streams_dot()` for the `examples/jacobi_unified.cu` pipeline (its `--dot` log block printed this format before `export_dot` switched to the launch matrix). | | `jacobi_skeleton.svg` | `dot -Tsvg jacobi_skeleton.dot -o jacobi_skeleton.svg` | | `jacobi_skeleton.png` | `dot -Tpng -Gdpi=120 jacobi_skeleton.dot -o jacobi_skeleton.png` | @@ -25,6 +31,10 @@ node tooltips list each kernel's full token set. ## Regenerating +`--dot` now logs the launch matrix; to capture the stream-cluster graph again, +switch the example's `main_pipe.export_dot(...)` call to +`main_pipe.export_streams_dot(...)` first. + ```bash cmake --build build -j build/examples/carbon_example_jacobi_unified --grid dense --dot 2>&1 \ @@ -49,7 +59,7 @@ share no fields and land on distinct streams; the resulting DOT has two `cluster_stream_0` / `cluster_stream_1` subgraphs and the `copy_xy -> combine` edge is rendered dashed-red to flag the cross-stream event-mediated dependency. That test does not currently dump the DOT to disk -— if you want to see the multi-stream rendering, add an `export_dot` call to +— if you want to see the multi-stream rendering, add an `export_streams_dot` call to the subtest's `sk` instance and pipe through `dot` the same way. ## Standard overlap scheduling (Neon-style) @@ -88,11 +98,11 @@ single `run()` — anchor fork record/waits, per-step event waits, kernel launch The same sequence is what the CUDA/HIP graph capture path records when `Options::use_cuda_graph` is enabled. -`export_dot()` prefixes each schedule node with `#N` (the launch line number) and +`export_streams_dot()` prefixes each schedule node with `#N` (the launch line number) and annotates dashed sync edges with `(rec #R -> wait #W)`. When anchor fork/join is active, extra dashed blue edges show the bracket ops. -`export_launch_matrix_dot()` renders the same sequence as a grid: one column per +`export_launch_matrix_dot()` — the default `export_dot()` — renders the same sequence as a grid: one column per stream, one row per operation (anchor syncs, event waits, launches, event records). Dashed arrows connect each event record to its waits — red for step events, blue for the anchor fork/join — so cross-stream hand-offs read as @@ -111,6 +121,23 @@ matching `.txt` launch-order files; add `--dot-matrix` for the kernel lists `--export-dot-png` likewise default to the launch matrix (`--export-dot-streams` keeps the legacy stream-cluster graph). See `tests/test_skeleton_launch_order.cu`. +## Halo transfer matrix + +`halo_messages()` lists, for this rank, every halo launch of one `run()` (user +and auto-inserted, in `run()` order, numbered like the launch-order rows) with +the cross-rank messages it issues: `DistMessage{op, peer_rank, elements, bytes, group}` +in issue order, `group` being the NCCL group within the exchange. It reads the +compiled halo kernels (`Kernel::dist_messages()`), so nothing is launched; +halos of single-process layouts report no messages. + +`gather_halo_messages()`, `export_transfer_matrix_csv[_file]()` and +`export_transfer_matrix_text()` collect every rank's list (collective on a +distributed `System`) into a rank × message matrix: CSV +`rank,index,seq,kernel,group,op,peer,elements,bytes` (the file is written by +rank 0), or a log table with cells `S>3 5.24 MB (1310720)` / `R<3 ...` (size and +element count). LBM exposes it as `--export-transfers PATH` (with `--compile-only` to skip the solver loop); +`benchmarks/lbm_ldc/scripts/plotting/plot_transfers.py` draws the heatmap. + ## Per-phase profiling `Skeleton::run_profile()` issues the same schedule as `run()` but measures host @@ -205,7 +232,7 @@ and `read(f, M)` / `write(f, M)` / `read_write(f, M)` / `L(f, M)` pin one access debugging; `Skeleton::region_masks_honoured()` reports the effective setting. Inspection: `export_kernel_list_dot()` adds a `region {…}` note under each masked access -chip, `export_dot()` tooltips list each masked token's region, and both option lines show +chip, `export_streams_dot()` tooltips list each masked token's region, and both option lines show `region_masks=ignored` when masks are off. Unmasked pipelines render exactly as before. Costs to keep in mind (numbers from `benchmarks/skeleton_region_mask`, see diff --git a/examples/cg_poisson_unified.cu b/examples/cg_poisson_unified.cu index abc2a96d..6ed7693e 100644 --- a/examples/cg_poisson_unified.cu +++ b/examples/cg_poisson_unified.cu @@ -657,7 +657,7 @@ run_cg(Grid& grid, if (!sk.export_launch_matrix_dot_file(base + ".dot", std::string{"cg_"} + tag)) { CARBON_LOG_ERROR("cg_poisson_unified: failed to write {}.dot", base); } - if (!sk.export_dot_file(base + "_streams.dot", std::string{"cg_"} + tag)) { + if (!sk.export_streams_dot_file(base + "_streams.dot", std::string{"cg_"} + tag)) { CARBON_LOG_ERROR("cg_poisson_unified: failed to write {}_streams.dot", base); } if (!sk.export_launch_order_file(base + ".txt")) { diff --git a/include/carbon/detail/halo_kernel_impl_base.h b/include/carbon/detail/halo_kernel_impl_base.h index be5fc81d..398b7456 100644 --- a/include/carbon/detail/halo_kernel_impl_base.h +++ b/include/carbon/detail/halo_kernel_impl_base.h @@ -160,6 +160,15 @@ class HaloKernelImplBase : public KernelImpl { halo_.launch_on_host(stream); } + [[nodiscard]] auto + dist_messages() const -> std::vector override { + if constexpr (requires(const HaloT& h) { h.dist_messages(); }) { + return halo_.dist_messages(); + } else { + return {}; + } + } + /** The wrapped halo descriptor. */ [[nodiscard]] auto halo() const noexcept -> const HaloT& { diff --git a/include/carbon/detail/kernel_impl.h b/include/carbon/detail/kernel_impl.h index 0f6beaef..b9085277 100644 --- a/include/carbon/detail/kernel_impl.h +++ b/include/carbon/detail/kernel_impl.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -232,6 +233,15 @@ class KernelImpl { return empty; } + /** + * @brief Cross-rank messages one launch of this kernel issues on this rank, in issue order. + * Empty for every kind but halos of distributed layouts. + */ + [[nodiscard]] virtual auto + dist_messages() const -> std::vector { + return {}; + } + /** Optional human-readable name; empty by default. */ [[nodiscard]] auto name() const noexcept -> std::string_view { diff --git a/include/carbon/dist_message.h b/include/carbon/dist_message.h new file mode 100644 index 00000000..e5c86799 --- /dev/null +++ b/include/carbon/dist_message.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +namespace carbon { + +/** + * Direction of a single peer-to-peer NCCL transfer entry. + * + * @c Send issues @c ncclSend on this rank's communicator (the local buffer is the source); + * @c Recv issues @c ncclRecv (the local buffer is the destination). + */ +enum class DistOp : int { + Send = 0, + Recv = 1, +}; + +/** + * One cross-rank message as issued on the wire: direction, remote rank and payload. Halo + * descriptors report their exchange as a list of these ( @c dist_messages() ), in issue order; + * @c Skeleton::halo_messages collects them per halo kernel. Plain data, so ranks can exchange + * lists byte-wise. + */ +struct DistMessage { + DistOp op{DistOp::Send}; + int peer_rank{}; + /** Buffer length in elements of the field's value type. */ + size_t elements{}; + size_t bytes{}; + /** Index of the @c ncclGroupStart / @c ncclGroupEnd block within one exchange. */ + size_t group{}; +}; + +} // namespace carbon diff --git a/include/carbon/dist_transfer.h b/include/carbon/dist_transfer.h index 1418a107..70a07c98 100644 --- a/include/carbon/dist_transfer.h +++ b/include/carbon/dist_transfer.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -15,17 +16,6 @@ namespace carbon { -/** - * Direction of a single peer-to-peer NCCL transfer entry. - * - * @c Send issues @c ncclSend on this rank's communicator (the local buffer is the source); - * @c Recv issues @c ncclRecv (the local buffer is the destination). - */ -enum class DistOp : int { - Send = 0, - Recv = 1, -}; - /** * Asynchronous cross-rank GPU transfer descriptor for the MPI+NCCL build. * @@ -121,6 +111,21 @@ class DistTransfer { return counts_.size(); } + /** + * Append the entries @ref operator() issues (non-zero counts, in order) to @p out , tagged + * with NCCL group index @p group . + */ + auto + append_messages(std::vector& out, + size_t group) const -> void { + for (size_t i = 0; i < counts_.size(); ++i) { + if (counts_[i] > 0U) { + out.push_back( + DistMessage{ops_[i], peer_ranks_[i], counts_[i], counts_[i] * sizeof(T), group}); + } + } + } + /** * Issue every non-zero entry on the given stream as a single NCCL group. Uses the * per-rank handle @c stream[0] internally. Throws @c std::runtime_error on any NCCL diff --git a/include/carbon/halo.h b/include/carbon/halo.h index 6301e035..e29ab3c5 100644 --- a/include/carbon/halo.h +++ b/include/carbon/halo.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -203,6 +204,19 @@ class Halo { #endif } + /** + * This rank's cross-rank messages of one exchange, in issue order (one NCCL group); empty + * without @c CARBON_HAVE_MPI_NCCL . + */ + [[nodiscard]] auto + dist_messages() const -> std::vector { + std::vector out; +#ifdef CARBON_HAVE_MPI_NCCL + dist_.append_messages(out, 0U); +#endif + return out; + } + /** * Issue the halo updates on @p stream. Dispatches the precomputed intra-process * @c Transfer followed by the cross-rank @c DistTransfer (the latter only in MPI diff --git a/include/carbon/halo_disg.h b/include/carbon/halo_disg.h index 2bd08537..d466fb6d 100644 --- a/include/carbon/halo_disg.h +++ b/include/carbon/halo_disg.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -180,6 +181,19 @@ class HaloDisg { #endif } + /** + * This rank's cross-rank messages of one exchange, in issue order (one NCCL group); empty + * without @c CARBON_HAVE_MPI_NCCL . + */ + [[nodiscard]] auto + dist_messages() const -> std::vector { + std::vector out; +#ifdef CARBON_HAVE_MPI_NCCL + dist_.append_messages(out, 0U); +#endif + return out; + } + /** * Issue the device halo exchange on @p stream . Dispatches the precomputed * intra-process @c Transfer followed by the cross-rank @c DistTransfer diff --git a/include/carbon/halo_disg_distributed.h b/include/carbon/halo_disg_distributed.h index 45c6d650..42351eb6 100644 --- a/include/carbon/halo_disg_distributed.h +++ b/include/carbon/halo_disg_distributed.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -170,6 +171,19 @@ class HaloDisgDistributed { #endif } + /** + * This rank's cross-rank messages of one exchange, in issue order (one NCCL group); empty + * without @c CARBON_HAVE_MPI_NCCL . + */ + [[nodiscard]] auto + dist_messages() const -> std::vector { + std::vector out; +#ifdef CARBON_HAVE_MPI_NCCL + dist_.append_messages(out, 0U); +#endif + return out; + } + /** Issue the device halo exchange on @p stream (intra-process, then cross-rank). */ auto operator()(const Stream& stream) const -> void { diff --git a/include/carbon/halo_distributed.h b/include/carbon/halo_distributed.h index 988abf79..f59cc81a 100644 --- a/include/carbon/halo_distributed.h +++ b/include/carbon/halo_distributed.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -229,6 +230,38 @@ class HaloDistributed { #endif } + /** + * This rank's cross-rank messages of one exchange, in issue order; empty without + * @c CARBON_HAVE_MPI_NCCL . Multi-axis layouts issue one NCCL group per staged axis pass + * (field-buffer runs, then packed faces), numbered from 0 in @c DistMessage::group ; empty + * groups take no number. + */ + [[nodiscard]] auto + dist_messages() const -> std::vector { + std::vector out; +#ifdef CARBON_HAVE_MPI_NCCL + size_t group = 0; + const auto add = [&out, &group](const DistTransfer& d) { + const size_t before = out.size(); + d.append_messages(out, group); + if (out.size() > before) { + ++group; + } + }; + if (axis_passes_.empty()) { + add(dist_); + return out; + } + for (const AxisPass& pass : axis_passes_) { + add(pass.dist); +#if CARBON_BACKEND_IS_CUDALIKE + add(pass.dist_staged); +#endif + } +#endif + return out; + } + /** * Issue the halo updates on @p stream. Dispatches the precomputed intra-process * @c Transfer followed by the cross-rank @c DistTransfer (the latter only in MPI diff --git a/include/carbon/kernel.h b/include/carbon/kernel.h index 1a53998c..a08c2891 100644 --- a/include/carbon/kernel.h +++ b/include/carbon/kernel.h @@ -632,6 +632,15 @@ class Kernel { return impl_ ? impl_->kind() : KernelKind::Anchor; } + /** + * Cross-rank messages one launch issues on this rank (halos of distributed layouts only); + * empty otherwise. + */ + [[nodiscard]] auto + dist_messages() const -> std::vector { + return impl_ ? impl_->dist_messages() : std::vector{}; + } + /** Optional human-readable name; empty string for a default-constructed kernel. */ [[nodiscard]] auto name() const noexcept -> std::string_view { diff --git a/include/carbon/skeleton.h b/include/carbon/skeleton.h index 050cb393..4f02b79a 100644 --- a/include/carbon/skeleton.h +++ b/include/carbon/skeleton.h @@ -97,6 +97,7 @@ #include #include #include +#include #include #include #include @@ -702,15 +703,15 @@ class CARBON_API Skeleton { * @ref AccessToken::field_name is captured by copy at @c KernelLoader * record time, so renaming a @ref Field via @c Field::set_name AFTER * adding the kernel that references it does not retroactively rewrite - * the existing tokens. @ref export_dot already prefers the most-recent + * the existing tokens. @ref export_streams_dot already prefers the most-recent * non-empty token name across all kernels, so the typical "rename * then add more kernels" pattern works without this API. This setter * is the escape hatch for the rarer "rename AFTER all kernels are * added" case: the override wins over every token snapshot for the - * matching uid in the next @ref export_dot call. + * matching uid in the next @ref export_streams_dot call. * * Calling with an empty @p label removes any prior override for that - * uid (so @ref export_dot falls back to the token-snapshot chain). + * uid (so @ref export_streams_dot falls back to the token-snapshot chain). * No-op when @p field_uid corresponds to a field no kernel in the * skeleton ever touched. */ @@ -725,7 +726,27 @@ class CARBON_API Skeleton { } /** - * @brief Render the inferred DAG as a GraphViz DOT graph string. + * @brief Default schedule visualization: the launch matrix of one @ref run + * iteration as a GraphViz DOT string (same as @ref export_launch_matrix_dot ). + * Lazy-compiles. The stream-cluster graph is @ref export_streams_dot . + */ + [[nodiscard]] auto + export_dot(std::string graph_name = "carbon_skeleton") -> std::string { + return export_launch_matrix_dot(std::move(graph_name)); + } + + /** + * @brief Write @ref export_dot (the launch matrix) to @p path (GraphViz @c .dot file). + * @return @c false if the file could not be opened. + */ + [[nodiscard]] auto + export_dot_file(std::string path, + std::string graph_name = "carbon_skeleton") -> bool { + return export_launch_matrix_dot_file(std::move(path), std::move(graph_name)); + } + + /** + * @brief Render the inferred DAG as a stream-cluster GraphViz DOT graph string. * * The graph is a digraph (one node per @c Kernel in user-add order; one edge * per inferred dependency). Each node is labelled with the kernel's @@ -754,25 +775,24 @@ class CARBON_API Skeleton { * lazy-compiles before rendering so the user does not have to call * @ref compile first. */ - // Definition lives in src/skeleton.cpp (export_dot). + // Definition lives in src/skeleton.cpp (export_streams_dot). [[nodiscard]] auto - export_dot(std::string graph_name = "carbon_skeleton") -> std::string; + export_streams_dot(std::string graph_name = "carbon_skeleton") -> std::string; /** - * @brief Write @ref export_dot to @p path (GraphViz @c .dot file). + * @brief Write @ref export_streams_dot to @p path (GraphViz @c .dot file). * @return @c false if the file could not be opened. */ [[nodiscard]] auto - export_dot_file(std::string path, - std::string graph_name = "carbon_skeleton") -> bool; + export_streams_dot_file(std::string path, + std::string graph_name = "carbon_skeleton") -> bool; /** * @brief Write a launch-matrix @c .dot beside @p png_path and render PNG via * GraphViz (@c dot -Tpng ). Requires @c dot on @c PATH . * - * Default schedule visualization is the launch matrix (@ref - * export_launch_matrix_dot). For the stream-cluster graph use - * @ref export_dot_file then render separately. + * Same graph as @ref export_dot (the launch matrix). For the stream-cluster + * graph use @ref export_streams_dot_file then render separately. * @return @c false if the dot file or render step failed. */ [[nodiscard]] auto @@ -843,6 +863,59 @@ class CARBON_API Skeleton { export_kernel_list_dot_file(std::string path, std::string graph_name = "carbon_kernel_list") -> bool; + /** One halo launch of @ref run and the cross-rank messages it issues on one rank. */ + struct HaloMessages { + size_t seq{0U}; /**< Row of the launch in @ref export_launch_order (1-based). */ + std::string label{}; /**< Display label, as in the launch matrix. */ + std::vector messages{}; /**< In issue order; empty for intra-rank halos. */ + }; + + /** + * @brief This rank's cross-rank halo messages of one @ref run iteration, read from the + * compiled halo kernels (user and auto-inserted) in run() order. Nothing is + * launched; lazy-compiles. + */ + [[nodiscard]] auto + halo_messages() -> std::vector; + + /** + * @brief @ref halo_messages of every rank, indexed by world rank (one entry without a + * distributed system). Collective when the bound @ref System is distributed: every + * rank must call it. + */ + [[nodiscard]] auto + gather_halo_messages() -> std::vector>; + + /** + * @brief Transfer matrix of one @ref run iteration as CSV, one line per message: + * @c rank,index,seq,kernel,group,op,peer,elements,bytes . @c index numbers the rank's + * messages in issue order across all halo launches (the matrix column), @c seq is + * the launch row from @ref export_launch_order . Collective like + * @ref gather_halo_messages ; every rank gets the full matrix. + */ + [[nodiscard]] auto + export_transfer_matrix_csv() -> std::string; + + /** + * @brief Write @ref export_transfer_matrix_csv to @p path on world rank 0 (other ranks + * only take part in the gather). Collective. + * @param comment Written above the header, each line prefixed with @c "# " (e.g. + * @c "grid=disg_distributed" lines describing the run); empty for none. + * @return @c false if rank 0 could not write the file. + */ + [[nodiscard]] auto + export_transfer_matrix_csv_file(std::string path, + std::string_view comment = {}) -> bool; + + /** + * @brief Plain-text transfer matrix for logs: one row per rank, one column per message + * in issue order, cells @c "S>3 5.24 MB (1310720)" (send to rank 3, size and + * element count) / @c "R<3 ..." (receive from rank 3), and per-rank totals. + * Collective. + */ + [[nodiscard]] auto + export_transfer_matrix_text() -> std::string; + /** * @brief Primary execution stream (stream index 0). Matches the @ref Stream * passed to the constructor (when given) or @c sys.stream() at @@ -1225,8 +1298,8 @@ class CARBON_API Skeleton { /** Index in @ref streams_ of the detached copy stream (scalar readback), or @c kNoStream_. */ size_t copy_stream_idx_{kNoStream_}; bool has_detached_stream_{false}; - // Optional per-uid label overrides for @ref export_dot . Populated by - // @ref set_field_label ; consulted by export_dot's uid_to_label map + // Optional per-uid label overrides for @ref export_streams_dot . Populated by + // @ref set_field_label ; consulted by export_streams_dot's uid_to_label map // BEFORE the token-snapshot fallback so users can rename fields after // adding kernels and still get readable graphs without re-building // the pipeline. @@ -1284,7 +1357,7 @@ class CARBON_API Skeleton { } // namespace carbon // Out-of-class member definitions for compile() / run() / compile_step_graph_occ_() / -// compile_allocate_anchor_events_() / export_dot() / export_launch_order() live in +// compile_allocate_anchor_events_() / export_streams_dot() / export_launch_order() live in // src/skeleton.cpp . // User code only needs ; the .cpp is statically linked // into libcarbon. The Skeleton class above is non-template, so moving the diff --git a/src/skeleton.cpp b/src/skeleton.cpp index 73306a00..594ac3fc 100644 --- a/src/skeleton.cpp +++ b/src/skeleton.cpp @@ -14,7 +14,7 @@ * step-graph rewrite around (halo, stencil) pairs. * - @c compile_allocate_anchor_events_ — start / join events for the * per-run bracket on the anchor. - * - @c export_dot — GraphViz DOT renderer for the inferred DAG. + * - @c export_streams_dot — stream-cluster GraphViz DOT renderer for the schedule. * - @c export_launch_order — text listing of one @c run iteration's ops. * * Splitting these out trims @c by ~700 lines of body @@ -2541,7 +2541,7 @@ Skeleton::export_kernel_list_dot_file(std::string path, } auto -Skeleton::export_dot(std::string graph_name) -> std::string { +Skeleton::export_streams_dot(std::string graph_name) -> std::string { compile(); const std::vector launch_ops = build_launch_order_ops_(); std::unordered_map launch_seq_by_step; @@ -2810,13 +2810,13 @@ Skeleton::export_dot(std::string graph_name) -> std::string { } auto -Skeleton::export_dot_file(std::string path, - std::string graph_name) -> bool { +Skeleton::export_streams_dot_file(std::string path, + std::string graph_name) -> bool { std::ofstream out(path, std::ios::out | std::ios::trunc); if (!out) { return false; } - out << export_dot(std::move(graph_name)); + out << export_streams_dot(std::move(graph_name)); return out.good(); } @@ -2860,4 +2860,199 @@ Skeleton::export_launch_matrix_dot_png(std::string png_path, return render_dot_png(dot_path, png_path); } +auto +Skeleton::halo_messages() -> std::vector { + compile(); + std::vector out; + for (const LaunchOrderOp& op : build_launch_order_ops_()) { + if (op.kind != LaunchOrderOpKind::Launch) { + continue; + } + const Kernel& kernel = effective_kernels_[schedule_[op.step_idx].kernel_idx]; + if (kernel.kind() != KernelKind::Halo) { + continue; + } + out.push_back(HaloMessages{op.seq, step_display_label_(op.step_idx), kernel.dist_messages()}); + } + return out; +} + +auto +Skeleton::gather_halo_messages() -> std::vector> { + std::vector mine = halo_messages(); +#ifdef CARBON_HAVE_MPI_NCCL + const Distributed* dist = sys_.distributed(); + if (dist != nullptr && dist->world_size() > 1) { + std::unordered_map label_by_seq; + for (const HaloMessages& h : mine) { + label_by_seq.emplace(h.seq, h.label); + } + std::vector> all(static_cast(dist->world_size())); + for (int root = 0; root < dist->world_size(); ++root) { + const bool is_root = root == dist->world_rank(); + // Per launch: (seq, message count); then every message of the rank back to back. + std::vector launches; + std::vector messages; + if (is_root) { + for (const HaloMessages& h : mine) { + launches.push_back(h.seq); + launches.push_back(h.messages.size()); + messages.insert(messages.end(), h.messages.begin(), h.messages.end()); + } + } + std::array sizes{launches.size(), messages.size()}; + dist->broadcast(sizes.data(), sizeof(sizes), root); + launches.resize(sizes[0]); + messages.resize(sizes[1]); + if (sizes[0] > 0U) { + dist->broadcast(launches.data(), sizes[0] * sizeof(std::uint64_t), root); + } + if (sizes[1] > 0U) { + dist->broadcast(messages.data(), sizes[1] * sizeof(DistMessage), root); + } + std::vector& list = all[static_cast(root)]; + if (is_root) { + list = mine; + continue; + } + size_t next = 0; + for (size_t i = 0; i + 1U < launches.size(); i += 2U) { + const size_t seq = launches[i]; + const size_t count = std::min(launches[i + 1U], messages.size() - next); + const auto label = label_by_seq.find(seq); + list.push_back(HaloMessages{ + seq, label != label_by_seq.end() ? label->second : "#" + std::to_string(seq), + std::vector( + messages.begin() + static_cast(next), + messages.begin() + static_cast(next + count))}); + next += count; + } + } + return all; + } +#endif + return {std::move(mine)}; +} + +namespace { + +[[nodiscard]] auto +format_bytes(size_t bytes) -> std::string { + std::ostringstream s; + s << std::fixed; + if (bytes >= 1000000U) { + s << std::setprecision(2) << static_cast(bytes) / 1e6 << " MB"; + } else { + s << std::setprecision(1) << static_cast(bytes) / 1e3 << " KB"; + } + return s.str(); +} + +[[nodiscard]] auto +csv_quote(std::string_view text) -> std::string { + std::string out = "\""; + for (const char c : text) { + out += c; + if (c == '"') { + out += '"'; + } + } + return out + "\""; +} + +} // namespace + +auto +Skeleton::export_transfer_matrix_csv() -> std::string { + const std::vector> all = gather_halo_messages(); + std::ostringstream os; + os << "rank,index,seq,kernel,group,op,peer,elements,bytes\n"; + for (size_t rank = 0; rank < all.size(); ++rank) { + size_t index = 0; + for (const HaloMessages& h : all[rank]) { + for (const DistMessage& m : h.messages) { + os << rank << ',' << index++ << ',' << h.seq << ',' << csv_quote(h.label) << ',' << m.group + << ',' << (m.op == DistOp::Send ? "send" : "recv") << ',' << m.peer_rank << ',' + << m.elements << ',' << m.bytes << '\n'; + } + } + } + return os.str(); +} + +auto +Skeleton::export_transfer_matrix_csv_file(std::string path, + std::string_view comment) -> bool { + const std::string csv = export_transfer_matrix_csv(); +#ifdef CARBON_HAVE_MPI_NCCL + const Distributed* dist = sys_.distributed(); + if (dist != nullptr && dist->world_rank() != 0) { + return true; + } +#endif + std::ofstream out(path, std::ios::out | std::ios::trunc); + if (!out) { + return false; + } + for (size_t begin = 0; begin < comment.size();) { + const size_t end = std::min(comment.find('\n', begin), comment.size()); + out << "# " << comment.substr(begin, end - begin) << '\n'; + begin = end + 1U; + } + out << csv; + return out.good(); +} + +auto +Skeleton::export_transfer_matrix_text() -> std::string { + const std::vector> all = gather_halo_messages(); + std::vector> rows(all.size()); + std::set> launches; + size_t columns = 0; + for (size_t rank = 0; rank < all.size(); ++rank) { + for (const HaloMessages& h : all[rank]) { + launches.emplace(h.seq, h.label); + rows[rank].insert(rows[rank].end(), h.messages.begin(), h.messages.end()); + } + columns = std::max(columns, rows[rank].size()); + } + + constexpr int kRankW = 6; + constexpr int kCellW = 26; + std::ostringstream os; + os << "halo launches per run():"; + for (const auto& [seq, label] : launches) { + os << " #" << seq << ' ' << label; + } + if (launches.empty()) { + os << " none"; + } + os << "\ncells: S>p = send to rank p, R

= rows[rank].size()) { + os << std::setw(kCellW) << ""; + continue; + } + const DistMessage& m = rows[rank][i]; + const bool send = m.op == DistOp::Send; + (send ? sent : received) += m.bytes; + os << std::setw(kCellW) + << ((send ? "S>" : "R<") + std::to_string(m.peer_rank) + " " + format_bytes(m.bytes) + + " (" + std::to_string(m.elements) + ")"); + } + os << format_bytes(sent) << " / " << format_bytes(received) << " in " << rows[rank].size() + << " msgs"; + } + return os.str(); +} + } // namespace carbon diff --git a/tests/test_skeleton.cu b/tests/test_skeleton.cu index 21646757..860ddb66 100644 --- a/tests/test_skeleton.cu +++ b/tests/test_skeleton.cu @@ -422,7 +422,7 @@ run_parallel_sibling_subtest(carbon::System& sys, // - per-stream cluster scopes (subgraph cluster_stream_0 / 1); // - all three kernel labels (uv, xy, combine) with DataView tags; // - schedule execution-order edges and cross-stream wait styling. - const std::string dot = sk.export_dot("sibling_pipeline"); + const std::string dot = sk.export_streams_dot("sibling_pipeline"); auto contains = [&dot](std::string_view needle) -> bool { return dot.find(needle) != std::string::npos; }; @@ -1523,7 +1523,7 @@ main() { fb.set_name("fb_renamed_via_set_name"); sk_dot.add(build_copy_kernel(dense, fb, fa, "rename_swap")); - const std::string dot_path1 = sk_dot.export_dot(); + const std::string dot_path1 = sk_dot.export_streams_dot(); if (dot_path1.find("fa_renamed_via_set_name") == std::string::npos || dot_path1.find("fb_renamed_via_set_name") == std::string::npos) { CARBON_LOG_ERROR( @@ -1535,7 +1535,7 @@ main() { // Path 2: explicit override after all kernels added. sk_dot.set_field_label(fa.gpu_buffers().get_uid(), "fa_explicit_override"); sk_dot.set_field_label(fb.gpu_buffers().get_uid(), "fb_explicit_override"); - const std::string dot_path2 = sk_dot.export_dot(); + const std::string dot_path2 = sk_dot.export_streams_dot(); if (dot_path2.find("fa_explicit_override") == std::string::npos || dot_path2.find("fb_explicit_override") == std::string::npos) { CARBON_LOG_ERROR("test_skeleton: DOT export missing set_field_label override"); @@ -1551,7 +1551,7 @@ main() { // Empty-string clears the override (back to token-snapshot path). sk_dot.set_field_label(fa.gpu_buffers().get_uid(), ""); - const std::string dot_path3 = sk_dot.export_dot(); + const std::string dot_path3 = sk_dot.export_streams_dot(); if (dot_path3.find("fa_renamed_via_set_name") == std::string::npos) { CARBON_LOG_ERROR( "test_skeleton: clearing the override (empty label) did not fall back to " diff --git a/tests/test_skeleton_region_mask.cu b/tests/test_skeleton_region_mask.cu index 9cf1c077..02b6ac2b 100644 --- a/tests/test_skeleton_region_mask.cu +++ b/tests/test_skeleton_region_mask.cu @@ -664,9 +664,10 @@ subtest_ignore_and_determinism(carbon::System& sys, if (has(list_ignored, "region {") || !has(list_ignored, "region_masks=ignored")) { return fail("export_kernel_list_dot: ignored masks must be reported, not annotated"); } - const std::string dot_masked = sk_a.export_dot("masked"); - if (!has(dot_masked, "region {0}") || has(sk_unmasked.export_dot("unmasked"), "region {")) { - return fail("export_dot: tooltips must carry non-all masks only"); + const std::string dot_masked = sk_a.export_streams_dot("masked"); + if (!has(dot_masked, "region {0}") || + has(sk_unmasked.export_streams_dot("unmasked"), "region {")) { + return fail("export_streams_dot: tooltips must carry non-all masks only"); } return true; } diff --git a/tests/test_skeleton_scalar_pattern.cu b/tests/test_skeleton_scalar_pattern.cu index ede76247..88e6236a 100644 --- a/tests/test_skeleton_scalar_pattern.cu +++ b/tests/test_skeleton_scalar_pattern.cu @@ -87,7 +87,7 @@ main() { return EXIT_FAILURE; } - const std::string dot = sk.export_dot(); + const std::string dot = sk.export_streams_dot(); if (dot.find("scalar_readback") == std::string::npos) { CARBON_LOG_ERROR("test_skeleton_scalar_pattern: DOT missing scalar_readback node"); return EXIT_FAILURE;