|
Template Numerical Library version\ main:4e6e2c1
|
Data structure for the Adaptive CSR segments format. More...
#include <TNL/Algorithms/Segments/AdaptiveCSR.h>
Public Types | |
| using | BlocksArray = typename ViewType::BlocksArray |
| Type for arrays of descriptor block of AdaptiveCSR. | |
| using | BlocksType = typename ViewType::BlocksType |
| Type for descriptor blocks of AdaptiveCSR. | |
| using | BlocksView = typename BlocksType::ViewType |
| Type for descriptor blocks view of AdaptiveCSR. | |
| using | BlocksViewArray = typename ViewType::BlocksViewArray |
| Type for arrays of descriptor block view of AdaptiveCSR. | |
| using | ConstViewType = AdaptiveCSRView< Device, std::add_const_t< Index > > |
| Type of constant segments view. | |
| template<typename Device_ = Device, typename Index_ = Index, typename IndexAllocator_ = typename Allocators::Default< Device_ >::template Allocator< Index_ >> | |
| using | Self = AdaptiveCSR< Device_, Index_, IndexAllocator_ > |
| Templated type for creating AdaptiveCSR segments with different template parameters. | |
| template<typename Device_, typename Index_> | |
| using | ViewTemplate = AdaptiveCSRView< Device_, Index_ > |
| Templated view type. | |
| using | ViewType = AdaptiveCSRView< Device, Index > |
| Type of segments view. | |
| Public Types inherited from TNL::Algorithms::Segments::CSR< Device, Index, typename Allocators::Default< Device >::template Allocator< Index > > | |
| using | ConstViewType |
| Type of constant segments view. | |
| using | IndexAllocatorType |
| using | OffsetsContainer |
| Type of container storing offsets of particular segments. | |
| using | Self |
| Templated type for creating CSR segments with different template parameters. | |
| using | ViewTemplate |
| Templated view type. | |
| using | ViewType |
| Type of segments view. | |
| Public Types inherited from TNL::Algorithms::Segments::CSRBase< Device, Index > | |
| using | ConstOffsetsView = typename OffsetsView::ConstViewType |
| The type for representing the constant vector view with segment 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 segment offsets used in the CSR format. | |
| using | SegmentViewType = SegmentView< IndexType, RowMajorOrder > |
| Accessor type for one particular segment. | |
Public Member Functions | |
| AdaptiveCSR () | |
| Constructor with no parameters to create empty segments. | |
| AdaptiveCSR (AdaptiveCSR &&) noexcept=default | |
| Move constructor. | |
| AdaptiveCSR (const AdaptiveCSR &segments) | |
| Copy constructor (makes deep copy). | |
| template<typename SizesContainer, std::enable_if_t< IsArrayType< SizesContainer >::value, bool > = true> | |
| AdaptiveCSR (const SizesContainer &segmentsSizes) | |
| Constructor that initializes segments based on their sizes. | |
| template<typename ListIndex> | |
| AdaptiveCSR (const std::initializer_list< ListIndex > &segmentsSizes) | |
| Constructor that initializes segments using an initializer list. | |
| const BlocksViewArray & | getBlocks () const |
| Returns a view with blocks used in the Adaptive CSR format. | |
| ConstViewType | getConstView () const |
| Returns a constant view for this instance of segments which can by used for example in lambda functions running in GPU kernels. | |
| ViewType | getView () |
| Returns a view for this instance of segments which can by used for example in lambda functions running in GPU kernels. | |
| void | load (File &file) |
| Method for loading the segments from a file in a binary form. | |
| AdaptiveCSR & | operator= (AdaptiveCSR &&) noexcept(false) |
| Move-assignment operator. | |
| AdaptiveCSR & | operator= (const AdaptiveCSR &segments) |
| Copy-assignment operator (makes a deep copy). | |
| template<typename Device_, typename Index_, typename IndexAllocator_> | |
| AdaptiveCSR & | operator= (const AdaptiveCSR< Device_, Index_, IndexAllocator_ > &segments) |
| Assignment operator for segments with different template parameters. | |
| void | reset () |
| Reset the segments to empty states (it means that there is no segment in the segments). | |
| void | save (File &file) const |
| Method for saving the segments to a file in a binary form. | |
| template<typename SizesContainer> | |
| void | setSegmentsSizes (const SizesContainer &segmentsSizes) |
| Set sizes of particular segments. | |
| Public Member Functions inherited from TNL::Algorithms::Segments::CSR< Device, Index, typename Allocators::Default< Device >::template Allocator< Index > > | |
| CSR () | |
| Constructor with no parameters to create empty segments. | |
| ConstViewType | getConstView () const |
| Returns a constant view for this instance of segments which can by used for example in lambda functions running in GPU kernels. | |
| ViewType | getView () |
| Returns a view for this instance of segments which can by used for example in lambda functions running in GPU kernels. | |
| void | load (File &file) |
| Method for loading the segments from a file in a binary form. | |
| CSR & | operator= (const CSR &segments) |
| Copy-assignment operator (makes a deep copy). | |
| void | reset () |
| Reset the segments to empty states (it means that there is no segment in the segments). | |
| void | save (File &file) const |
| Method for saving the segments to a file in a binary form. | |
| void | setSegmentsSizes (const SizesContainer &segmentsSizes) |
| Set sizes of particular segments. | |
| Public Member Functions inherited from TNL::Algorithms::Segments::CSRBase< Device, Index > | |
| __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 Condition, typename Function> | |
| void | forAllElementsIf (Condition condition, Function function) const |
| template<typename Function> | |
| void | forAllSegments (Function &&function) const |
| Call TNL::Algorithms::Segments::CSR::forSegments for all segments. | |
| template<typename Array, typename Function> | |
| void | forElements (const Array &segmentIndexes, Function function) const |
| template<typename Array, typename Function> | |
| void | forElements (const Array &segmentIndexes, Index begin, Index end, Function function) const |
| 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 Condition, typename Function> | |
| void | forElementsIf (IndexType begin, IndexType end, Condition condition, Function function) const |
| 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 | getElementCount () const |
| Returns the number of elements managed by all segments. | |
| __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 segment offsets used in the CSR format. | |
| __cuda_callable__ ConstOffsetsView | getOffsets () const |
| Returns a constant vector view with segment offsets used in the CSR format. | |
| __cuda_callable__ IndexType | getSegmentCount () const |
| Returns the number of segments. | |
| __cuda_callable__ IndexType | getSegmentsCount () const |
| Returns the number of segments. Deprecated, use getSegmentCount(). | |
| __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 a segment view (i.e., a segment accessor) for the specified segment 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 std::string | getSegmentsType () |
| Returns string with the segments type. | |
| static std::string | getSerializationType () |
| Returns string with the serialization type. | |
| static constexpr int | MaxValueSizeLog () |
| Static Public Member Functions inherited from TNL::Algorithms::Segments::CSRBase< Device, Index > | |
| 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 | |
| template<int SizeOfValue, typename Offsets> | |
| Index | findLimit (Index start, const Offsets &offsets, Index size, detail::Type &type) |
| template<int SizeOfValue, typename Offsets> | |
| void | initValueSize (const Offsets &offsets) |
| Protected Member Functions inherited from TNL::Algorithms::Segments::CSRBase< Device, Index > | |
| __cuda_callable__ void | bind (OffsetsView offsets) |
| Re-initializes the internal attributes of the base class. | |
Static Protected Member Functions | |
| static int | getSizeValueLog (const int &i) |
Protected Attributes | |
| BlocksArray | blocksArray |
| blocksArray[ i ] stores blocks for sizeof( Value ) == 2^i. | |
| ViewType | view |
| Protected Attributes inherited from TNL::Algorithms::Segments::CSR< Device, Index, typename Allocators::Default< Device >::template Allocator< Index > > | |
| OffsetsContainer | offsets |
| Protected Attributes inherited from TNL::Algorithms::Segments::CSRBase< Device, Index > | |
| OffsetsView | offsets |
| Vector view with row offsets used in the CSR format. | |
Data structure for the Adaptive CSR segments format.
Adaptive CSR segments are inspired by the following paper:
[M. Daga and J. L. Greathouse, Structural Agnostic SpMV: Adapting CSR-Adaptive for Irregular Matrices, 2015 IEEE 22nd International Conference on High Performance Computing (HiPC), Bengaluru, India, 2015, pp. 64-74.](https://ieeexplore.ieee.org/document/7397620).
This format extends the Compressed Sparse Row (CSR) format. The data are organized similarly to CSR, but the segments contain additional meta-information to optimize GPU thread mapping. In particular, reduction operations can benefit from this extension. However, reading the meta-information introduces overhead, which may impact performance, especially for small segments. Use this segment type only if you anticipate significant variation in segment sizes.
See TNL::Algorithms::Segments for more details about segments.
| Device | The type of device on which the segments will operate. |
| Index | The type used for indexing the elements managed by the segments. |
| IndexAllocator | The allocator used for managing index containers. |
| using TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::Self = AdaptiveCSR< Device_, Index_, IndexAllocator_ > |
Templated type for creating AdaptiveCSR segments with different template parameters.
| Device_ | is alternative device type. |
| Index_ | is alternative index type. |
| IndexAllocator_ | is alternative index allocator type. |
| using TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::ViewTemplate = AdaptiveCSRView< Device_, Index_ > |
Templated view type.
| Device_ | is alternative device type for the view. |
| Index_ | is alternative index type for the view. |
| TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::AdaptiveCSR | ( | const SizesContainer & | segmentsSizes | ) |
Constructor that initializes segments based on their sizes.
The number of segments is determined by the size of segmentsSizes. Each element in this container specifies the size of a corresponding segment.
| SizesContainer | The type of container used to store segment sizes. It can be, for example, TNL::Containers::Array or TNL::Containers::Vector. |
| segmentsSizes | An instance of the container holding the sizes of the segments. |
See the following example:
The expected output is:
| TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::AdaptiveCSR | ( | const std::initializer_list< ListIndex > & | segmentsSizes | ) |
Constructor that initializes segments using an initializer list.
The number of segments is determined by the size of segmentsSizes. Each element in this initializer list specifies the size of a corresponding segment.
| ListIndex | The type used for indexing elements in the initializer list. |
| segmentsSizes | An initializer list defining the sizes of the segments. |
See the following example:
The expected output is:
|
staticnodiscard |
Returns string with the segments type.
|
staticnodiscard |
Returns string with the serialization type.
| void TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::load | ( | File & | file | ) |
Method for loading the segments from a file in a binary form.
| file | is the source file. |
| AdaptiveCSR & TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::operator= | ( | const AdaptiveCSR< Device_, Index_, IndexAllocator_ > & | segments | ) |
Assignment operator for segments with different template parameters.
Performs a deep copy of the source segments.
| Device_ | The device type of the source segments. |
| Index_ | The index type of the source segments. |
| IndexAllocator_ | The index allocator type of the source segments. |
| segments | The source segments object. |
| void TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::save | ( | File & | file | ) | const |
Method for saving the segments to a file in a binary form.
| file | is the target file. |
| void TNL::Algorithms::Segments::AdaptiveCSR< Device, Index, IndexAllocator >::setSegmentsSizes | ( | const SizesContainer & | segmentsSizes | ) |
Set sizes of particular segments.
| SizesContainer | is a container with segments sizes. It can be TNL::Containers::Array or TNL::Containers::Vector for example. |
| segmentsSizes | is an instance of the container with segments sizes. |