Skip to content

502 ippl does consistently consider striding in indexes#503

Draft
aaadelmann wants to merge 8 commits into
masterfrom
502-ippl-does-consistently-consider-striding-in-indexes
Draft

502 ippl does consistently consider striding in indexes#503
aaadelmann wants to merge 8 commits into
masterfrom
502-ippl-does-consistently-consider-striding-in-indexes

Conversation

@aaadelmann
Copy link
Copy Markdown
Member

@aaadelmann aaadelmann commented May 12, 2026

Summary

This PR restores old-IPPL-style field access behavior for strided indexes and adds a first Kokkos IPPL implementation of dense and sparse subfield access.

This PR adds an initial SIndex and sparse field view implementation.

Users can build explicit sparse point sets:

The main goal is that Index, NDIndex, and sparse SIndex field operations consistently respect strides and can be used naturally in field expressions.

User-Facing Field Indexing

Dense subdomains can now be assigned directly:

ippl::NDIndex<Dim> subdomain = field.getDomain();
subdomain[0] = ippl::Index(subdomain[0].first(),
                           subdomain[0].last(),
                           2 * subdomain[0].stride());

field[subdomain] = 7.0;
lhs[subdomain] = rhs[subdomain] + 2.0;

Chained indexing is also supported:

field[I][J][K] = 7.0;
lhs[I][J][K] = rhs[I][J][K] + 2.0;

The indexed views preserve the selected global index coordinates and map them back to local Kokkos view coordinates, including ghost offsets.

Strided Index Semantics

Index behavior now accounts for actual grid points rather than only interval endpoints:

  • Index::contains() checks that all points in the candidate index are present in the containing index.
  • Index::touches() requires a real strided intersection.
  • Index::grow(n) grows coordinate bounds by n * stride.
    This fixes cases such as even and odd strided indexes being incorrectly treated as touching.

Sparse SIndex Access

field[si] = 7.0;
lhs[si] = rhs[si] + 2.0;

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:

ippl::NDIndex<Dim> subdomain = field.getDomain();
subdomain[0] = ippl::Index(subdomain[0].first(),
                           subdomain[0].last(),
                           2 * subdomain[0].stride());

si[subdomain] = field[subdomain] > threshold;
out[si] = field[si];

A compatibility helper is provided:

si = gt(field, threshold);

Sparse Compound Assignment

Sparse field views support compound updates:

field[si] += value;
field[si] -= value;
field[si] *= value;
field[si] /= value;

field[si] += rhs[si];
field[si] -= rhs[si];
field[si] *= rhs[si];
field[si] /= rhs[si];

This covers the old benchmark pattern:

B[SI] *= 1.01;

SIndex Set Operations

The following sparse set operations are available:

si &= otherSi;
si |= otherSi;

si &= domain;
si |= domain;

si &= offset;
si |= offset;

Tests

Added coverage for:

  • strided Index::contains, touches, and grow
  • dense field[NDIndex] assignment and expression assignment
  • chained dense field[I][J]... assignment and expression assignment
  • sparse scalar and expression assignment
  • sparse RHS offset expressions
  • sparse predicate construction
  • subsetted sparse predicate construction
  • sparse compound assignment
  • multi-dimensional coverage from 1D through 6D for float and double
  • explicit multi-rank BareField execution

Deferred

  • ParticleAttrib[SIndex] interop from old IPPL is intentionally deferred for a follow-up PR.

@biddisco
Copy link
Copy Markdown
Collaborator

biddisco commented May 13, 2026

cscs-ci run cscs-ci-gh200, cscs-ci-mi300, cscs-ci-openmp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPPL doesn't consistently consider striding in indexes

3 participants