502 ippl does consistently consider striding in indexes#503
Open
aaadelmann wants to merge 14 commits into
Open
502 ippl does consistently consider striding in indexes#503aaadelmann wants to merge 14 commits into
aaadelmann wants to merge 14 commits into
Conversation
Collaborator
|
cscs-ci run cscs-ci-gh200, cscs-ci-mi300, cscs-ci-openmp |
Avoid routing SIndex predicate assignment through addIndex(), which performs a linear duplicate scan for every selected point. Predicate assignment clears the index and visits each local candidate point once, so selected points can be appended directly after reserving capacity. This removes the quadratic host-side construction cost that made the high-rank SparseIndexSubsetPredicateAssignment tests look like a hang, especially under MPI/GPU test runs.
Keep the existing reinterpret-cast capture model, but align CapturedExpression and its byte buffer to the captured expression type. This avoids reinterpreting byte-aligned storage as expression objects that may contain stricter-aligned members such as Kokkos views. Also speed up predicate-built SIndex construction by reserving selected capacity and appending selected points directly. Predicate assignment clears the sparse index and visits each candidate point once, so the public addIndex duplicate scan is unnecessary there and caused quadratic host-side cost in high-rank sparse-index tests.
Add a focused Field regression test for power-of-two 3D subdomains. The test initializes a cubic field to one, verifies the full-field sum, then repeatedly assigns smaller N/2, N/4, ..., 2^3 subdomains into a zeroed target field and checks that the summed value matches the expected subdomain volume. The target keeps the same global layout as the source so the test is stable under MPI-backed ctest runs while still exercising the Field subdomain access and assignment path.
Add a BareField regression for assigning between compatible rectangular
subsets with different physical strides:
A[a] = B[b] + scalar
The test constructs local owned subdomains where the left-hand side uses a
larger stride than the right-hand side while both subsets have the same
logical extent. It verifies that IndexedBareField evaluates each side in its
own subdomain coordinates instead of assuming identical strides.
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
This PR adds a subset of old-IPPL field indexing behavior to the Kokkos-based implementation:
Index/NDIndexaccess forBareFieldBareField[NDIndex]and chainedBareField[Index]...subsetsBareField[SIndex]subsetsSOffsetSIndex<Dim>as a sparse set of selected field points.The goal is to make the common strided and sparse
BareFieldworkflows workwithout attempting to port the full old
SubField/SubParticleAttribmachinery in this PR.The main goal is that
Index,NDIndex, and sparseSIndexfield operations consistently respectstrides and can be used naturally in field expressions.
User-Facing Field Indexing
Dense subdomains can now be assigned directly:
Chained indexing is also supported:
The indexed views preserve the selected global index coordinates and map them back to local Kokkos view coordinates, including ghost offsets.
Indexstrides are now respected when accessing aBareFieldthrough anNDIndex.Chained indexing is also supported:
Compatible subsets with different physical strides are supported as long as
they have the same logical extent:
A[a] = B[b] + 2.0;In this case, the left and right sides are evaluated in their own subdomain
coordinate systems.
Sparse field subsets
Sparse selected points can be assigned directly:
Compound assignment is supported for sparse field subsets:
Sparse predicates
Sparse indexes can be constructed from field predicates:
Predicate construction can also be restricted to a strided subset:
Sparse offsets
Sparse offset expressions are supported through
SOffset:Strided Index Semantics
Index behavior now accounts for actual grid points rather than only interval endpoints:
This fixes cases such as even and odd strided indexes being incorrectly treated as touching.
Sparse SIndex Access
Predicate-Built Sparse Indexes
Sparse indexes can be built from field predicates, matching the main old TestSIndex.cpp workflow:
ippl::SIndex<Dim> si(layout); si = field > threshold; out[si] = field[si];Subsetted predicate construction is also supported:
A compatibility helper is provided:
Sparse Compound Assignment
Sparse field views support compound updates:
This covers the old benchmark pattern:
B[SI] *= 1.01;SIndex Set Operations
The following sparse set operations are available:
Implementation notes
IndexedBareFieldimplements rectangularBareFieldsubset access.SparseIndexedBareFieldimplements sparseBareField[SIndex]access.SIndexstores selected points and supports predicate assignment, setoperations, and
SOffsetshifts needed by the sparse field paths.the existing captured-expression reinterpretation path.
field and sparse-index operations.
Tests
Added coverage for:
IndexsemanticsA[a] = B[b] + scalarDeferred
SubParticleAttribSubField/SubBareFieldparitySubFieldTraitsgeneric compositionSIndex[NDIndex<Dim2>]IndexedSIndex<Dim, Brackets>chaining/generalizationint*sparse offset overloadsPA[S] = A[S]