Template Numerical Library version\ main:ab3532f7
|
CSRBase serves as a base class for CSR and CSRView. More...
#include <TNL/Algorithms/Segments/CSRBase.h>
Public Types | |
using | ConstOffsetsView = typename OffsetsView::ConstViewType |
The type for representing the constant vector view with row offsets used in the CSR format. | |
using | DeviceType = Device |
The device where the segments are operating. | |
using | IndexType = std::remove_const_t< Index > |
The type used for indexing of segments elements. | |
using | OffsetsView = Containers::VectorView< Index, DeviceType, IndexType > |
The type for representing the vector view with row offsets used in the CSR format. | |
using | SegmentViewType = SegmentView< IndexType, RowMajorOrder > |
Accessor type fro one particular segment. | |
Public Member Functions | |
__cuda_callable__ | CSRBase ()=default |
Default constructor with no parameters to create empty segments view. | |
__cuda_callable__ | CSRBase (const CSRBase &)=default |
Copy constructor. | |
__cuda_callable__ | CSRBase (const OffsetsView &offsets) |
Binds a new CSR view to an offsets vector. | |
__cuda_callable__ | CSRBase (CSRBase &&) noexcept=default |
Move constructor. | |
__cuda_callable__ | CSRBase (OffsetsView &&offsets) |
Binds a new CSR view to an offsets vector. | |
template<typename Function> | |
void | forAllElements (Function &&function) const |
Call TNL::Algorithms::Segments::CSR::forElements for all elements of the segments. | |
template<typename Function> | |
void | forAllSegments (Function &&function) const |
Call TNL::Algorithms::Segments::CSR::forSegments for all segments. | |
template<typename Function> | |
void | forElements (IndexType begin, IndexType end, Function &&function) const |
Iterate over all elements of given segments in parallel and call given lambda function. | |
template<typename Function> | |
void | forSegments (IndexType begin, IndexType end, Function &&function) const |
Iterate over all segments in parallel and call given lambda function. | |
__cuda_callable__ IndexType | getGlobalIndex (Index segmentIdx, Index localIdx) const |
Computes the global index of an element managed by the segments. | |
__cuda_callable__ OffsetsView | getOffsets () |
Returns a modifiable vector view with row offsets used in the CSR format. | |
__cuda_callable__ ConstOffsetsView | getOffsets () const |
Returns a constant vector view with row offsets used in the CSR format. | |
__cuda_callable__ IndexType | getSegmentsCount () const |
Returns the number of segments. | |
__cuda_callable__ IndexType | getSegmentSize (IndexType segmentIdx) const |
Returns the size of a particular segment denoted by segmentIdx. | |
__cuda_callable__ SegmentViewType | getSegmentView (IndexType segmentIdx) const |
Returns segment view (i.e. segment accessor) of segment with given index. | |
__cuda_callable__ IndexType | getSize () const |
Returns the number of elements managed by all segments. | |
__cuda_callable__ IndexType | getStorageSize () const |
Returns number of elements that needs to be allocated by a container connected to this segments. | |
CSRBase & | operator= (const CSRBase &)=delete |
Copy-assignment operator. | |
CSRBase & | operator= (CSRBase &&)=delete |
Move-assignment operator. | |
template<typename Function> | |
void | sequentialForAllSegments (Function &&function) const |
Call TNL::Algorithms::Segments::CSR::sequentialForSegments for all segments. | |
template<typename Function> | |
void | sequentialForSegments (IndexType begin, IndexType end, Function &&function) const |
Call TNL::Algorithms::Segments::CSR::forSegments sequentially for particular segments. | |
Static Public Member Functions | |
static constexpr ElementsOrganization | getOrganization () |
Returns the data layout for the CSR format (it is always row-major order). | |
static std::string | getSegmentsType () |
Returns string with the segments type. | |
static std::string | getSerializationType () |
Returns string with the serialization type. | |
static constexpr bool | havePadding () |
This function denotes that the CSR format does not use padding elements. | |
Protected Member Functions | |
__cuda_callable__ void | bind (OffsetsView offsets) |
Re-initializes the internal attributes of the base class. | |
Protected Attributes | |
OffsetsView | offsets |
Vector view with row offsets used in the CSR format. | |
CSRBase serves as a base class for CSR and CSRView.
Device | is type of device where the segments will be operating. |
Index | is type for indexing of the elements managed by the segments. |
|
protected |
Re-initializes the internal attributes of the base class.
Note that this function is protected to ensure that the user cannot modify the base class of segments. For the same reason, in future code development we also need to make sure that all non-const functions in the base class return by value and not by reference.
void TNL::Algorithms::Segments::CSRBase< Device, Index >::forAllElements | ( | Function && | function | ) | const |
Call TNL::Algorithms::Segments::CSR::forElements for all elements of the segments.
See TNL::Algorithms::Segments::CSR::forElements for more details.
void TNL::Algorithms::Segments::CSRBase< Device, Index >::forAllSegments | ( | Function && | function | ) | const |
Call TNL::Algorithms::Segments::CSR::forSegments for all segments.
See TNL::Algorithms::Segments::CSR::forSegments for more details.
void TNL::Algorithms::Segments::CSRBase< Device, Index >::forElements | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function ) const |
Iterate over all elements of given segments in parallel and call given lambda function.
Function | is a type of the lambda function to be performed on each element. |
begin | defines begining of an interval [ begin, end ) of segments on elements of which we want to apply the lambda function. |
end | defines end of an interval [ begin, end ) of segments on elements of which we want to apply the lambda function. |
function | is the lambda function to be applied on the elements of the segments. |
Declaration of the lambda function function is supposed to be
where segmentIdx is index of segment where given element belong to, localIdx is rank of the element within the segment and globalIdx is index of the element within the related container.
void TNL::Algorithms::Segments::CSRBase< Device, Index >::forSegments | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function ) const |
Iterate over all segments in parallel and call given lambda function.
Function | is a type of the lambda function to be performed on each segment. |
begin | defines begining of an interval [ begin, end ) of segments on elements of which we want to apply the lambda function. |
end | defines end of an interval [ begin, end ) of segments on elements of which we want to apply the lambda function. |
function | is the lambda function to be applied on the elements of the segments. |
Declaration of the lambda function function is supposed to be
where segment represents given segment (see TNL::Algorithms::Segments::SegmentView). Its type is given by SegmentViewType.
|
nodiscard |
Computes the global index of an element managed by the segments.
The global index serves as a refernce on the element in its container.
segmentIdx | is index of a segment with the element. |
localIdx | is tha local index of the element within the segment. |
|
staticnodiscard |
Returns string with the segments type.
|
nodiscard |
Returns segment view (i.e. segment accessor) of segment with given index.
segmentIdx | is index of the request segment. |
|
staticnodiscard |
Returns string with the serialization type.
void TNL::Algorithms::Segments::CSRBase< Device, Index >::sequentialForAllSegments | ( | Function && | function | ) | const |
Call TNL::Algorithms::Segments::CSR::sequentialForSegments for all segments.
See TNL::Algorithms::Segments::CSR::sequentialForSegments for more details.
void TNL::Algorithms::Segments::CSRBase< Device, Index >::sequentialForSegments | ( | IndexType | begin, |
IndexType | end, | ||
Function && | function ) const |
Call TNL::Algorithms::Segments::CSR::forSegments sequentially for particular segments.
With this method, the given segments are processed sequentially one-by-one. This is usefull for example for printing of segments based data structures or for debugging reasons.
begin | defines begining of an interval [ begin, end ) of segments on elements of which we want to apply the lambda function. |
end | defines end of an interval [ begin, end ) of segments on elements of which we want to apply the lambda function. |
function | is the lambda function to be applied on the elements of the segments. |
See TNL::Algorithms::Segments::CSR::forSegments for more details.