Skip to content

GPU matvec: no unused host copy of the result tile - #46

Open
AdvaitTahilyani wants to merge 5 commits into
scale/28-local-wakeupsfrom
scale/29-matvec-host-copy
Open

AdvaitTahilyani wants to merge 5 commits into
scale/28-local-wakeupsfrom
scale/29-matvec-host-copy

Conversation

@AdvaitTahilyani

@AdvaitTahilyani AdvaitTahilyani commented Nov 26, 2026 •

Copy link
Copy Markdown

What was wrong. The 1-D chare that assembles a matrix-vector product took data_ptr() of the result before adding the partials. Only the CPU (Eigen) path uses that pointer; on Kokkos builds data_ptr() creates the array's host mirror, so every GPU matvec allocated and zero-filled a host copy of the result tile that nothing read (4 MB per chare for linreg -n 4000 at 16 processes, 16 MB at 1), dropped again when the array was retired. The heap of those processes also grew by about 45 MB/s (freed 4 MB holes that later requests did not fit). Found with a sampling heap profiler: 23.5 GB allocated in 55 s from that call site.

Change. The data_ptr() call is under #ifndef USE_KOKKOS. CPU builds are unchanged.

Measured (linreg -n 4000 -i 2000, seconds per repeat, ofi build; measured on the older integration tree scale-int with #45's commit, with and without this one):

layout before after
1 process, 1 A100 5.88–5.98 (without either commit) 4.53–4.55
1 node × 4 A100 4.42–4.47 3.51–3.54
16 processes on 4 A100 (CUDA IPC only) 14.46–14.63 13.26–13.31
4 nodes × 4 A100 9.54–9.65 8.73–8.81

Not a cause of the repeat-to-repeat drift fixed in #45; repeats were flat with and without it.

Validated. nc and GPU (netlrts-cuda) builds; GPU runs: covered by the validation of the top of this stack (#48).

Known limits. Other places that call data_ptr() on device arrays were not audited.

🤖 Generated with Claude Code

AdvaitTahilyani and others added 2 commits November 24, 2026 22:58
The 1-D chare that assembles a matrix-vector product took the result's
host pointer before summing the partials. Only the CPU build uses it; on
Kokkos builds data_ptr() creates the array's host mirror, so every matvec
allocated and zero-filled a host copy of the result tile (4 MB per chare
for linreg -n 4000 at 16 processes, 16 MB at 1), dropped again when the
array was retired. The brk heap of those processes also grew by about
45 MB/s (freed 4 MB holes that later requests did not fit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant