specfem::chunk_element::Index¶
-
template<specfem::element::dimension_tag DimensionTag, typename SIMD, typename ViewType, typename TeamMemberType, typename G, int ChunkSize>
class Index : public specfem::execution::ChunkElementIndex<DimensionTag, SIMD, ViewType, TeamMemberType, G, ChunkSize>, public specfem::data_access::Accessor<specfem::datatype::AccessorType::chunk_element, specfem::data_access::DataClassType::index, DimensionTag, SIMD::using_simd>¶ Chunk element index for high-performance spectral element computations.
This class provides a specialized indexing interface for accessing and iterating over chunks of spectral elements. It combines the functionality of the chunked domain iterator with the SPECFEM++ data access layer, enabling efficient chunk-based processing of multiple elements simultaneously.
The Index class is designed to work with team-based Kokkos execution patterns where multiple elements are processed together in chunks to improve cache locality, enable vectorization, and maximize computational throughput. It provides both spatial indexing within elements (GLL points) and iteration over element chunks.
// Example: Using chunk index with field accessors specfem::execution::ChunkedDomainIterator chunk(...); specfem::execution::for_each_level("process_elements", chunk, KOKKOS_LAMBDA(const decltype(chunk)::index_type &index) { // Access the chunk element index auto chunk_index = index.get_index(); // Use chunk_index to access field data ChunkField field(chunk_index.team_scratch(0)); specfem::assembly::load_on_device(chunk_index.get_index(), field_container, field); // Perform computations on the field ... (computation logic) });
See also
specfem::execution::ChunkElementIndex for iteration functionality
Note
This class inherits from both ChunkElementIndex (for iteration functionality) and Accessor (for data access layer integration), providing a complete interface for chunk-based element processing.
- Template Parameters:
DimensionTag – Spatial dimension (dim2 or dim3) of the elements
SIMD – SIMD type configuration for vectorized operations
ViewType – Kokkos view type for element indices storage
TeamMemberType – Kokkos team member type for parallel execution
Public Types
Public Functions
-
inline Index(const base_type &base)¶
Construct index from existing chunk element index base.
Creates a chunk element index by wrapping an existing ChunkElementIndex object. This constructor is useful when you already have a base chunk element index and want to add the data access layer functionality.
// Create base chunk element index auto base_index = specfem::execution::ChunkElementIndex<...>(...); // Wrap it with data access layer IndexType chunk_index(base_index);
- Parameters:
base – The base chunk element index to wrap
-
inline constexpr const TeamMemberType get_policy_index() const¶
Get the policy index that defined this chunk element index.
- Returns:
const TeamMemberType The policy index that defined this chunk element index.
-
inline constexpr const index_type get_index() const¶
Get the underlying index used to store elements in the chunk.
- Returns:
const index_type The underlying index that defines the chunk elements.
-
inline constexpr const iterator_type get_iterator() const¶
Get the iterator used to iterate over the elements in the chunk.
- Returns:
const iterator_type The iterator for this chunk element index.
-
inline Kokkos::pair<typename ViewType::value_type, typename ViewType::value_type> get_range() const¶
Get a pair representing the range of indices in this chunk.
- Returns:
Kokkos::pair<typename ViewType::value_type, typename ViewType::value_type> A pair containing the first and last index in the chunk.
Private Types
-
using base_type = specfem::execution::ChunkElementIndex<DimensionTag, SIMD, ViewType, TeamMemberType, G, ChunkSize>¶
Base type providing chunk element iteration functionality.
-
using index_type = specfem::chunk_element::Index<DimensionTag, SIMD, ViewType, TeamMemberType, G, ChunkSize>¶
Underlying index type for the chunk element index.
Private Members
-
specfem::mesh_entity::element_grid<DimensionTag, G> element_grid¶
Element grid information
-
TeamMemberType kokkos_index¶
Kokkos index type.
-
iterator_type iterator¶
Iterator for iterating over the elements in the chunk.
specfem::chunk_element::MappedIndex¶
-
template<specfem::element::dimension_tag DimensionTag, typename SIMD, typename ViewType, typename TeamMemberType, typename G, int ChunkSize>
class MappedIndex : public specfem::execution::MappedChunkElementIndex<DimensionTag, SIMD, ViewType, TeamMemberType, G, ChunkSize>, public specfem::data_access::Accessor<specfem::datatype::AccessorType::chunk_element, specfem::data_access::DataClassType::mapped_index, DimensionTag, SIMD::using_simd>¶ Mapped index for chunked element operations with indirection.
Provides index mapping capabilities for chunks of spectral elements, combining execution context with data access patterns. Enables indirect element access through mapping arrays for non-contiguous element processing.
- Template Parameters:
DimensionTag – Spatial dimension (2D/3D)
SIMD – SIMD configuration for vectorization
ViewType – Kokkos view type for index storage
TeamMemberType – Kokkos team execution context
Public Types
Public Functions
-
inline MappedIndex(const base_type &base)¶
Construct from base index.
- Parameters:
base – Base mapped chunk element index
-
inline MappedIndex(const ViewType indices, const ViewType mapping, const int &ngllz, const int &ngllx, const TeamMemberType &kokkos_index)¶
Construct with explicit parameters.
- Parameters:
indices – Element indices view
mapping – Index mapping view for indirection
ngllz – Number of GLL points in z-dimension
ngllx – Number of GLL points in x-dimension
kokkos_index – Team member execution context
-
inline constexpr const TeamMemberType get_policy_index() const¶
Get the policy index that defined this chunk element index.
- Returns:
const TeamMemberType The policy index that defined this chunk element index.
-
inline Kokkos::pair<typename ViewType::value_type, typename ViewType::value_type> get_range() const¶
Get a pair representing the range of indices in this chunk.
- Returns:
Kokkos::pair<typename ViewType::value_type, typename ViewType::value_type> A pair containing the first and last index in the chunk.
Private Types
-
using base_type = specfem::execution::MappedChunkElementIndex<DimensionTag, SIMD, ViewType, TeamMemberType, G, ChunkSize>¶
Base execution index type for chunk element mapping.
-
using index_type = specfem::chunk_element::MappedIndex<DimensionTag, SIMD, ViewType, TeamMemberType, G, ChunkSize>¶
Underlying index type used to store the indices within the chunk.
Private Members
-
specfem::mesh_entity::element_grid<DimensionTag, G> element_grid¶
Element grid information
-
TeamMemberType kokkos_index¶
Kokkos index type.