Skip to content

lib-cuda: record the measured cost of the 32-bit index axis on this backend - #151

Merged
balbasty merged 1 commit into
mainfrom
docs/index32-measured-cuda-table
Aug 20, 2026
Merged

lib-cuda: record the measured cost of the 32-bit index axis on this backend#151
balbasty merged 1 commit into
mainfrom
docs/index32-measured-cuda-table

Conversation

@balbasty

Copy link
Copy Markdown
Collaborator

Comment-only follow-up to #143, which merged before these numbers were in hand.
No build behaviour changes.

#143 landed INDEXFLAGS / FF_INDEX32 and made build-cuda a two-leg matrix
over the two positions. Its own text still quoted the axis's cost from the
host-compiler measurement in #94 plus an assumption that CUDA would behave
similarly. The matrix's first run has now produced the real CUDA figures, so
this records them above MODULES in src/lib-cuda/Makefile — both positions,
one CI run, one runner class, nvcc -O1 -j2 with the shipping bound/spline
policy.

Peak nvcc RSS (GiB) / wall per module:

moduleFF_INDEX32=1FF_INDEX32=0Δ RSS
reg_flow12.97 / 1023 s5.69 / 497 s−56.1%
reg_field8.09 / 791 s3.76 / 343 s−53.5%
reg_field_rls7.07 / 701 s3.42 / 353 s−51.7%
resize2.00 / 193 s1.08 / 113 s−46.2%
reg_flow_rls1.90 / 155 s1.01 / 89 s−46.9%
pushpull_backward1.51 / 167 s0.80 / 102 s−46.9%
pushpull1.48 / 158 s0.79 / 97 s−46.6%
restrict1.30 / 120 s0.68 / 72 s−47.4%
distance0.80 / 118 s0.54 / 61 s−33.1%
splinc0.42 / 68 s0.27 / 37 s−35.5%
posdef0.37 / 40 s0.35 / 28 s−6.9%
total nvcc CPU3532 s1791 s−49.3%
job wall clock~38 min~19 min

Source: run
32363152580,
jobs build-cuda (index32) and build-cuda (index64), both green.

Two things this makes visible, and the reason for recording rather than
quietly updating:

  • CUDA is worse than the host-compiler extrapolation implied, not better.
    reg_flow sheds 56.1% of peak RSS here, against the 44.6% clang showed.
  • The existing table's reproducibility claim does not hold uniformly. It
    says the heavy modules reproduce to better than 0.1%. reg_flow does — 12.97
    against the recorded 12.98 GiB. reg_field came in at 8.09 against a
    recorded 8.93, ~9% low. Both figures are now in the file with that noted,
    instead of the older one being overwritten as though nothing had moved.

The -j2 overlap hazard described further down that comment is unchanged:
halving each peak halves the sums too, but only in the position that is not the
default.

MIGRATION.md gets one correction in the same commit: it said "365 of 365
relevant impl/cuda upload sites use the synchronous copyToDevice", a figure
inherited from #94. On current main it is 363 of 391distance_ {euclidean,l1,mesh}.h now use copyToDeviceAsync. The point stands for almost
every op; the number was stale.

The benchmark that would actually settle the axis is still #144.


Generated by Claude Code

The knob's cost was previously quoted from a host-compiler measurement
(fastfields-lib#94) and an assumption that CUDA would behave the same way.
The `build-cuda` matrix added in the previous commit builds both positions in
one run, so the CUDA figures are now measured rather than extrapolated: peak
nvcc RSS and wall time per module, side by side, from a single CI run on one
runner class.
They are worse than the host-compiler extrapolation suggested, not better --
reg_flow drops 56.1% rather than the 44.6% measured with clang, and the whole
compile drops 49.3% of nvcc CPU (~38 min -> ~19 min wall).
Also notes, because the table below claims the heavy modules reproduce to
better than 0.1%: reg_flow does (12.97 vs the recorded 12.98 GiB), reg_field
does not (8.09 vs a recorded 8.93). Recording that rather than quietly
overwriting the older figure.
Comment-only; no build behaviour changes.
@balbasty
balbasty merged commit b0463bc into mainAug 20, 2026
10 checks passed
@balbasty
balbasty deleted the docs/index32-measured-cuda-table branch August 20, 2026 15:55
balbasty pushed a commit that referenced this pull request Aug 20, 2026
Brings in #143 (per-backend FF_INDEX32), #145 (#pragma once), #146
(<fastfields/...> includes) and #151 (the measured index-axis table).
One conflict, in src/lib-cuda/reg_flow.cpp: this branch splits the file and
moves the dtype x offset dispatch macros into reg_flow_slice.inl, while #143
rewrote the narrow arm of those same macros from int32_t to off32_t and #146
rewrote the include lines. Resolved by taking this branch's structure with both
of main's changes applied in their new home:
* all 20 narrow dispatch arms in reg_flow_slice.inl now name off32_t, which
is exactly the count main's reg_flow.cpp carries;
* the new files already spelled public includes <fastfields/...> and kept
the same-directory sibling quoted, so #146 needed nothing;
* reg_flow_slice.h switched from an #ifndef guard to #pragma once -- #145
landed the opposite way round from its original proposal, and the new
files followed the proposal rather than the merge.
tools/normalise-header-guards.py --check, tools/normalise-include-delimiters.py
--check and tools/rename-macros.py --check are all clean on the result.
Re-verified after the merge:
* tools/test-baseline.sh --legs default,lib -> row-for-row identical to
tools/test-baseline.expected across all 15 rows. 59,886 checks / 13 suites
for the default leg, plus the 2 hub suites, 0 failures.
* every one of the 30 slice functions is still defined exactly once across
the twelve slice TUs (preprocessor census: 13 occurrences each -- twelve
declarations from the shared header plus one definition).
* the front TU still instantiates nothing: 205,400 kB, 1.8 s.
* the heaviest slice still compiles: 2,037,652 kB, matching the 2,039,660 kB
build-cuda reported for it before the rebase (0.1%).
balbasty added a commit that referenced this pull request Aug 20, 2026
#151 recorded what FF_INDEX32 costs on the unsplit modules. This is the same
question asked of a slice, because the interesting case is whether splitting
makes the axis cheap enough that the knob stops mattering.
It does not. Same TU, index axis toggled:
reg_flow_matvec_3d FF_INDEX32=1 1.94 GiB 277.1 s 17.0 MB
FF_INDEX32=0 1.05 GiB 174.4 s 10.0 MB
-45.8% peak, which is the same proportion #94 measured on the unsplit file with
the host compiler (-44.6%). The split and the knob multiply rather than
overlap: 12.98 -> 1.94 GiB from one, 1.94 -> 1.05 GiB from the other.
Sign up for freeto 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

@balbasty