29template<
typename IndexType>
37 KOKKOS_INLINE_FUNCTION
63template<
typename IndexType>
66 IndexType finalValue = 0;
67 const auto inView = intervals.
view();
70 auto offsView = offsets.
view().subview(1);
88template<
typename ValueType,
typename IndexType = NeoN::localIdx>
109 KOKKOS_INLINE_FUNCTION
112 return Kokkos::pair<IndexType, IndexType> {
segments[segI],
segments[segI + 1]};
121 KOKKOS_INLINE_FUNCTION
124 return Kokkos::pair<IndexType, IndexType> {
138 auto [start, length] =
range(segI);
139 return values.subview(start, length);
148 KOKKOS_INLINE_FUNCTION
158template<
typename ValueType,
typename IndexType>
180 : values_(intervals.
exec(), 0),
181 segments_(intervals.
exec(), intervals.
size() + 1, IndexType(0))
244 return {values_.view(), segments_.
view()};
A class representing a segment of indices.
View< IndexType > segments
A View of indices representing the segments.
KOKKOS_INLINE_FUNCTION View< ValueType > view(localIdx segI) const
Get a subview of values corresponding to a segment.
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 View 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)
std::pair< View< ValueType >, View< IndexType > > views() &
get the combined value and range views of the segmented vector
SegmentedVector< ValueType, IndexType > copyToExecutor(Executor exec) const override
const Vector< IndexType > & segments() const
std::pair< View< ValueType >, View< IndexType > > views() &&=delete
SegmentedVectorView< ValueType, IndexType > view() &
get a view of the segmented vector
SegmentedVector(const Executor &exec, localIdx size, localIdx numSegments)
Create a segmented vector with a given size and number of segments.
localIdx numSegments() const
Get the number of segments in the segmented vector.
const Executor & exec() const
Get the executor associated with the segmented vector.
SegmentedVectorView< ValueType, IndexType > view() &&=delete
localIdx size() const
Get the size of the segmented vector.
MixinClass signaling copyTo is supported.
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.
Vector< ValueType > copyToExecutor(Executor dstExec) const
Copies the data to a new field on a specific executor.
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.
Integer types used throughout NeoN.
IndexType segmentsFromIntervals(const Vector< IndexType > &intervals, Vector< IndexType > &offsets)
Compute segment offsets from an input field corresponding to lengths by computing a prefix sum.
void parallelScan(const Executor &exec, std::pair< localIdx, localIdx > range, const Kernel &kernel)
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
KOKKOS_INLINE_FUNCTION void operator()(const localIdx i, IndexType &update, const bool final) const
View< const IndexType > intervals
View< IndexType > offsets