|
Template Numerical Library version\ main:4e6e2c1
|
Data structure for Bisection Ellpack segments. More...
#include <TNL/Algorithms/Segments/BiEllpack.h>
Public Types | |
| using | ConstViewType = typename ViewType::ConstViewType |
| Type of constant segments view. | |
| using | IndexAllocatorType = IndexAllocator |
| using | OffsetsContainer = Containers::Vector< Index, Device, typename Base::IndexType, IndexAllocator > |
| template<typename Device_ = Device, typename Index_ = Index, typename IndexAllocator_ = typename Allocators::Default< Device_ >::template Allocator< Index_ >, ElementsOrganization Organization_ = Organization, int WarpSize_ = WarpSize> | |
| using | Self = BiEllpack< Device_, Index_, IndexAllocator_, Organization_, WarpSize_ > |
| Templated type for creating BiEllpack segments with different template parameters. | |
| template<typename Device_ = Device, typename Index_ = Index> | |
| using | ViewTemplate = BiEllpackView< Device_, Index_, Organization, WarpSize > |
| Templated view type. | |
| using | ViewType = BiEllpackView< Device, Index, Organization, WarpSize > |
| Type of segments view. | |
| Public Types inherited from TNL::Algorithms::Segments::BiEllpackBase< Device, Index, DefaultElementsOrganization< Device >::getOrganization(), Backend::getWarpSize() > | |
| using | ConstOffsetsView |
| The type for representing the constant vector view with offsets of the BiEllpack groups. | |
| using | DeviceType |
| The device where the segments are operating. | |
| using | IndexType |
| The type used for indexing of segments elements. | |
| using | OffsetsView |
| The type for representing the vector view with offsets of the BiEllpack groups. | |
| using | SegmentViewType |
| Accessor type for one particular segment. | |
Public Member Functions | |
| BiEllpack ()=default | |
| Constructor with no parameters to create empty segments. | |
| BiEllpack (BiEllpack &&segments) noexcept=default | |
| Move constructor. | |
| BiEllpack (const BiEllpack &segments) | |
| Copy constructor (makes deep copy). | |
| template<typename SizesContainer, std::enable_if_t< IsArrayType< SizesContainer >::value, bool > = true> | |
| BiEllpack (const SizesContainer &segmentsSizes) | |
| Constructor that initializes segments based on their sizes. | |
| template<typename ListIndex> | |
| BiEllpack (const std::initializer_list< ListIndex > &segmentsSizes) | |
| Constructor that initializes segments using an initializer list. | |
| 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. | |
| template<typename SizesHolder> | |
| void | initGroupPointers (const SizesHolder &segmentsSizes) |
| void | load (File &file) |
| Method for loading the segments from a file in a binary form. | |
| BiEllpack & | operator= (BiEllpack &&segments) noexcept(false) |
| Move-assignment operator. | |
| BiEllpack & | operator= (const BiEllpack &segments) |
| Copy-assignment operator (makes a deep copy). | |
| template<typename Device_, typename Index_, typename IndexAllocator_, ElementsOrganization Organization_> | |
| BiEllpack & | operator= (const BiEllpack< Device_, Index_, IndexAllocator_, Organization_, WarpSize > &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 SizesHolder> | |
| void | setSegmentsSizes (const SizesHolder &sizes) |
| Set sizes of particular segments. | |
| Public Member Functions inherited from TNL::Algorithms::Segments::BiEllpackBase< Device, Index, DefaultElementsOrganization< Device >::getOrganization(), Backend::getWarpSize() > | |
| __cuda_callable__ | BiEllpackBase ()=default |
| Default constructor with no parameters to create empty segments view. | |
| void | forAllElements (Function &&function) const |
| void | forAllElementsIf (Condition condition, Function function) const |
| void | forAllSegments (Function &&function) const |
| void | forElements (IndexType begin, IndexType end, Function &&function) const |
| void | forElementsIf (IndexType begin, IndexType end, Condition condition, Function function) const |
| void | forSegments (IndexType begin, IndexType end, Function &&function) const |
| __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 | getGroupPointersView () |
| Returns a view containing the pointers to the beginning of each segment. | |
| __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__ OffsetsView | getSegmentsPermutationView () |
| Returns a view containing the permutation of segments. | |
| __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. | |
| __cuda_callable__ IndexType | getVirtualSegments () const |
| BiEllpackBase & | operator= (const BiEllpackBase &)=delete |
| Copy-assignment operator. | |
| void | printStructure (std::ostream &str) const |
| Prints the structure of the segments to the specified output stream. | |
Protected Member Functions | |
| Index | getStripLength (Index strip) const |
| template<typename SizesHolder> | |
| void | initSegmentsPermutation (const SizesHolder &segmentsSize) |
| template<typename SizesHolder> | |
| void | verifySegmentLengths (const SizesHolder &segmentsSizes) |
| template<typename SizesHolder> | |
| void | verifySegmentPerm (const SizesHolder &segmentsSizes) |
| Protected Member Functions inherited from TNL::Algorithms::Segments::BiEllpackBase< Device, Index, DefaultElementsOrganization< Device >::getOrganization(), Backend::getWarpSize() > | |
| __cuda_callable__ void | bind (IndexType size, IndexType storageSize, OffsetsView segmentsPermutation, OffsetsView groupPointers) |
| Re-initializes the internal attributes of the base class. | |
Protected Attributes | |
| OffsetsContainer | groupPointers |
| OffsetsContainer | segmentsPermutation |
| Protected Attributes inherited from TNL::Algorithms::Segments::BiEllpackBase< Device, Index, DefaultElementsOrganization< Device >::getOrganization(), Backend::getWarpSize() > | |
| OffsetsView | groupPointers |
| OffsetsView | segmentsPermutation |
| IndexType | size |
| IndexType | storageSize |
Additional Inherited Members | |
| Static Public Member Functions inherited from TNL::Algorithms::Segments::BiEllpackBase< Device, Index, DefaultElementsOrganization< Device >::getOrganization(), Backend::getWarpSize() > | |
| static constexpr int | getLogWarpSize () |
| Returns the log2 of the warp size used for the segments. | |
| static constexpr ElementsOrganization | getOrganization () |
| Returns the data layout for the biellpack 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 int | getWarpSize () |
| Returns the warp size used for the segments. | |
| static constexpr bool | havePadding () |
| This function denotes that the biellpack format uses padding elements. | |
Data structure for Bisection Ellpack segments.
Bisection Ellpack segments are inspired by the following paper:
[C. Zheng, S. Gu, T.-X. Gu, B. Yang, X.-P. Liu, BiELL: A bisection ELLPACK-based storage format for optimizing SpMV on GPUs, Journal of Parallel and Distributed Computing, Volume 74, Issue 7, 2014, pp. 2639-2647](https://www.sciencedirect.com/science/article/pii/S0743731514000458).
This format is designed to improve load balancing for segments with unevenly distributed sizes. It uses more meta-information compared to, for example, TNL::Algorithms::Segments::CSR, which can introduce overhead. However, it can be beneficial for reduction operations, particularly for longer segments with significant size variations.
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 elements managed by the segments. |
| IndexAllocator | The allocator used for managing index containers. |
| Organization | The organization of the elements in the segments—either row-major or column-major order. |
| WarpSize | The warp size used for the segments. |
| using TNL::Algorithms::Segments::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::Self = BiEllpack< Device_, Index_, IndexAllocator_, Organization_, WarpSize_ > |
Templated type for creating BiEllpack 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::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::ViewTemplate = BiEllpackView< Device_, Index_, Organization, WarpSize > |
Templated view type.
| Device_ | is alternative device type for the view. |
| Index_ | is alternative index type for the view. |
| TNL::Algorithms::Segments::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::BiEllpack | ( | 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::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::BiEllpack | ( | 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:
| void TNL::Algorithms::Segments::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::load | ( | File & | file | ) |
Method for loading the segments from a file in a binary form.
| file | is the source file. |
| BiEllpack & TNL::Algorithms::Segments::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::operator= | ( | const BiEllpack< Device_, Index_, IndexAllocator_, Organization_, WarpSize > & | 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::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::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::BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >::setSegmentsSizes | ( | const SizesHolder & | sizes | ) |
Set sizes of particular segments.
| SizesContainer | is a container with segments sizes. It can be TNL::Containers::Array or TNL::Containers::Vector for example. |
| sizes | is an instance of the container with segments sizes. |