Single-page arena ToT for all size-determinable construction (init_tiles_nested, retile)#570
Open
zhihao-deng wants to merge 3 commits into
Open
Single-page arena ToT for all size-determinable construction (init_tiles_nested, retile)#570zhihao-deng wants to merge 3 commits into
zhihao-deng wants to merge 3 commits into
Conversation
init_tiles_nested's range/fill callbacks are random-access, so the tile size is known up front. Build via arena_outer_init (one contiguous page) instead of the incremental ArenaToTBuilder, whose multi-page spill reverts the strided-BLAS fast path to per-cell AXPY. Reverts the 176df8a switch; ArenaToTBuilder stays the single-pass init_tiles fall-back.
make_with_new_trange rebuilt each retiled arena-ToT tile incrementally, though the source cell ranges are known up front. Use arena_outer_init so TA::retile keeps arena ToT tiles single-page.
TA_ASSERT_SINGLE_PAGE (env, off by default) makes arena_outer_init and ArenaToTBuilder::finish check Arena::page_count() <= 1, throw a TiledArray::Exception on a multi-page tile, and print a checked/violations summary at exit. Uses page_count() rather than classify_run so it stays valid for tiles with null or non-uniform inner cells. Zero overhead when unset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Route the size-determinable arena ToT construction paths through the up-front
arena_outer_initallocator instead of the incremental, multi-pageArenaToTBuilder, so every such outer tile is a single contiguous arena page.Multi-page outer tiles silently disqualify the strided-BLAS outer-contract +
inner-AXPY fast path (it reverts to per-cell AXPY).
make_nested_tile(
init_tiles_nested) andmake_with_new_trange(TA::retile) had regressed tothe multi-page builder in
176df8a2, though their range/fill callbacks arerandom-access — so the up-front allocator applies with no peak-memory penalty.
Why it matters
Fixing this at the construction layer makes the single-page guarantee universal:
all arena ToT built via these paths are single-page — not just one hand-patched
category. Downstream (e.g. MPQC CSV-CCk/PNO) every operand — amplitudes,
coefficients, energies, PNO/OSV-domain tensors — is single-page, instead of relying
on a post-hoc compaction of a single variable (which also costs an extra deep-copy
and a peak-memory spike).
ArenaToTBuilderis kept for the one genuinelysingle-pass path (
init_tiles), preserving the176df8a2optimization where itstill applies.
Companion MPQC change (expected)
This TA change covers ToT built through
init_tiles_nested/retile. MPQC alsoconstructs some operands via direct
ArenaToTBuildercalls, which need amatching conversion to
arena_outer_initto be single-page — landing separatelyin MPQC:
cc/solvers.h: the PNO Jacobi amplitude update and the coefficient/energyaccessors (
_pno_coeffs_tot,_osv_coeffs_tot,f_pno_diag,osv_energy).mbpt/pao_to_pno_mp2.ipp: the PAO→PNO contribution-slice builders.mbpt/csv.ipp: drops the now-redundantcompact_csv_coeffspost-hoc compaction(coefficients are now born single-page).
Validation
With both the TA and MPQC changes applied: new
make_nested_tile/retilesingle-page regression tests + full
tot_constructionsuite pass. Downstream MPQCCSV-CCk (C4H10) with
TA_ASSERT_SINGLE_PAGE=1: 0 violations across 490,124 ToTtiles, ~10% faster.