24template<
typename IndexType>
27 IndexType finalValue = 0;
28 const auto inSpan = intervals.
view();
31 auto offsSpan = offsets.
view().subspan(1);
38 KOKKOS_LAMBDA(
const localIdx i, IndexType& update,
const bool final) {
56template<
typename ValueType,
typename IndexType = NeoN::localIdx>
77 KOKKOS_INLINE_FUNCTION
80 return Kokkos::pair<IndexType, IndexType> {
segments[segI],
segments[segI + 1]};
89 KOKKOS_INLINE_FUNCTION
92 return Kokkos::pair<IndexType, IndexType> {
106 auto [start, length] =
range(segI);
107 return values.subspan(start, length);
116 KOKKOS_INLINE_FUNCTION
126template<
typename ValueType,
typename IndexType>
148 : values_(intervals.
exec(), 0),
149 segments_(intervals.
exec(), intervals.
size() + 1, IndexType(0))
205 return {values_.view(), segments_.
view()};
A class representing a segment of indices.
KOKKOS_INLINE_FUNCTION View< ValueType > span(localIdx segI) const
Get a subspan of values corresponding to a segment.
View< IndexType > segments
A span of indices representing the segments.
KOKKOS_INLINE_FUNCTION Kokkos::pair< IndexType, IndexType > range(localIdx segI) const
Get the range, ie. [start,end), of a segment.
KOKKOS_INLINE_FUNCTION IndexType operator[](localIdx i) const
Access an element of the segments.
View< ValueType > values
A span with the values.
KOKKOS_INLINE_FUNCTION Kokkos::pair< IndexType, IndexType > bounds(localIdx segI) const
Get the bounds of a segment.
Data structure that stores a segmented fields or a vector of vectors.
SegmentedVector(const Vector< ValueType > &values, const Vector< IndexType > &segments)
Constructor to create a segmentedVector from values and the segments.
const Vector< ValueType > & values() const
SegmentedVector(const Vector< IndexType > &intervals)
const Vector< IndexType > & segments() const
SegmentedVectorView< ValueType, IndexType > view() &
get a view of the segmented field
SegmentedVector(const Executor &exec, localIdx size, localIdx numSegments)
Create a segmented field with a given size and number of segments.
localIdx numSegments() const
Get the number of segments in the segmented field.
const Executor & exec() const
Get the executor associated with the segmented field.
std::pair< View< ValueType >, View< IndexType > > spans() &&=delete
std::pair< View< ValueType >, View< IndexType > > spans() &
get the combined value and range spans of the segmented field
SegmentedVectorView< ValueType, IndexType > view() &&=delete
localIdx size() const
Get the size of the segmented field.
A class to contain the data and executors for a field and define some basic operations.
localIdx size() const
Gets the size of the field.
const Executor & exec() const
Gets the executor associated with the field.
View< ValueType > view() &&=delete
#define NF_ASSERT_EQUAL(a, b)
Macro for asserting that two values are equal and printing an error message if they are not.
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
IndexType segmentsFromIntervals(const Vector< IndexType > &intervals, Vector< IndexType > &offsets)
Compute segment offsets from an input field corresponding to lengths by computing a prefix sum.
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
void parallelScan(const Executor &exec, std::pair< localIdx, localIdx > range, Kernel kernel)