Loading src/TNL/Algorithms/Segments/BiEllpack.h +8 −8 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class BiEllpack public: using DeviceType = Device; using IndexType = std::remove_const_t<Index>; using OffsetsHolder = Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocator>; using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocator>; static constexpr ElementsOrganization getOrganization() { return Organization; } using ViewType = BiEllpackView< Device, Index, Organization, WarpSize >; template <typename Device_, typename Index_> Loading Loading @@ -73,7 +73,7 @@ class BiEllpack /** * \brief Set sizes of particular segments. */ template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void setSegmentsSizes(const SizesHolder &sizes); void reset(); Loading Loading @@ -138,11 +138,11 @@ class BiEllpack void printStructure(std::ostream &str) const; // TODO: nvcc needs this public because of lambda function used inside template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void performRowBubbleSort(const SizesHolder &segmentsSize); // TODO: the same as above template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void computeColumnSizes(const SizesHolder &segmentsSizes); protected: Loading @@ -150,10 +150,10 @@ class BiEllpack static constexpr int getLogWarpSize() { return std::log2(WarpSize); }; template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void verifyRowPerm(const SizesHolder &segmentsSizes); template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void verifyRowLengths(const SizesHolder &segmentsSizes); IndexType getStripLength(const IndexType stripIdx) const; Loading @@ -164,9 +164,9 @@ class BiEllpack IndexType virtualRows = 0; OffsetsHolder rowPermArray; OffsetsContainer rowPermArray; OffsetsHolder groupPointers; OffsetsContainer groupPointers; // TODO: Replace later __cuda_callable__ Index power(const IndexType number, const IndexType exponent) const Loading src/TNL/Algorithms/Segments/CSR.h +103 −11 Original line number Diff line number Diff line Loading @@ -26,10 +26,16 @@ namespace TNL { * * See \ref TNL::Algorithms::Segments for more details about segments. * * \tparam Device * \tparam Index * \tparam CSRScalarKernel< Index, Device > * \tparam Allocator< Index > * \tparam Device is type of device where the segments will be operating. * \tparam Index is type for indexing of the elements managed by the segments. * \tparam Kernel is type of kernel used for parallel operations with segments. * It can be any of the following: * \ref TNL::Containers::Segments::Kernels::CSRAdaptiveKernel, * \ref TNL::Containers::Segments::Kernels::CSRHybridKernel, * \ref TNL::Containers::Segments::Kernels::CSRScalarKernel, * \ref TNL::Containers::Segments::Kernels::CSRVectorKernel * * \tparam IndexAllocator is allocator for supporting index containers. */ template< typename Device, typename Index, Loading @@ -39,31 +45,117 @@ class CSR { public: /** * \brief The device where the segments are operating. */ using DeviceType = Device; /** * \brief The type used for indexing of segments elements. */ using IndexType = std::remove_const_t< Index >; /** * \brief Type of kernel used for reduction operations. */ using KernelType = Kernel; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; using SegmentsSizes = OffsetsHolder; /** * \brief Type of container storing offsets of particular rows. */ using OffsetsContainer = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; /** * \brief Templated view type. * * \tparam Device_ is alternative device type for the view. * \tparam Index_ is alternative index type for the view. */ template< typename Device_, typename Index_ > using ViewTemplate = CSRView< Device_, Index_, KernelType >; /** * \brief Type of segments view.1 */ using ViewType = CSRView< Device, Index, KernelType >; /** * \brief Type of constant segments view. */ using ConstViewType = CSRView< Device, std::add_const_t< IndexType >, KernelType >; /** * \brief Accessor type fro one particular segment. */ using SegmentViewType = SegmentView< IndexType, RowMajorOrder >; static constexpr ElementsOrganization getOrganization() { return ColumnMajorOrder; } /** * \brief This functions says that CSR format is always organised in row-major order. */ static constexpr ElementsOrganization getOrganization() { return RowMajorOrder; } /** * \brief This function says that CSR format does not use padding elements. */ static constexpr bool havePadding() { return false; }; /** * \brief Construct with no parameters to create empty segments. */ CSR(); /** * \brief Construct with segments sizes. * * The number of segments is given by the size of \e segmentsSizes. Particular elements * of this container define sizes of particular segments. * * \tparam SizesContainer is a type of container for segments sizes. * \param sizes is an instance of the container with the segments sizes. * * See the following example: * * \includelineno Algorithms/Segments/SegmentsExample_CSR_constructor_1.cpp * * The result looks as follows: * * \include SegmentsExample_CSR_constructor_1.out */ template< typename SizesContainer > CSR( const SizesContainer& sizes ); CSR( const SizesContainer& segmentsSizes ); /** * \brief Construct with segments sizes in initializer list.. * * The number of segments is given by the size of \e segmentsSizes. Particular elements * of this initializer list define sizes of particular segments. * * \tparam ListIndex is a type of indexes of the initializer list. * \param sizes is an instance of the container with the segments sizes. * * See the following example: * * \includelineno Algorithms/Segments/SegmentsExample_constructor_2.cpp * * The result looks as follows: * * \include SegmentsExample_constructor_1.out */ template< typename ListIndex > CSR( const std::initializer_list< ListIndex >& segmentsSizes ); /** * \brief Copy constructor. * * \param segments are the source segments. */ CSR( const CSR& segments ); /** * \brief Move constructor. * * \param segments are the source segments. */ CSR( const CSR&& segments ); static String getSerializationType(); Loading Loading @@ -112,9 +204,9 @@ class CSR __cuda_callable__ SegmentViewType getSegmentView( const IndexType segmentIdx ) const; const OffsetsHolder& getOffsets() const; const OffsetsContainer& getOffsets() const; OffsetsHolder& getOffsets(); OffsetsContainer& getOffsets(); /*** * \brief Go over all segments and for each segment element call Loading Loading @@ -154,7 +246,7 @@ class CSR protected: OffsetsHolder offsets; OffsetsContainer offsets; KernelType kernel; }; Loading src/TNL/Algorithms/Segments/CSR.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ template< typename Device, typename IndexAllocator > auto CSR< Device, Index, Kernel, IndexAllocator >:: getOffsets() const -> const OffsetsHolder& getOffsets() const -> const OffsetsContainer& { return this->offsets; } Loading @@ -230,7 +230,7 @@ template< typename Device, typename IndexAllocator > auto CSR< Device, Index, Kernel, IndexAllocator >:: getOffsets() -> OffsetsHolder& getOffsets() -> OffsetsContainer& { return this->offsets; } Loading src/TNL/Algorithms/Segments/ChunkedEllpack.h +6 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class ChunkedEllpack using DeviceType = Device; using IndexType = std::remove_const_t< Index >; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; using OffsetsContainer = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; static constexpr ElementsOrganization getOrganization() { return Organization; } using ViewType = ChunkedEllpackView< Device, Index, Organization >; template< typename Device_, typename Index_ > Loading Loading @@ -72,7 +72,7 @@ class ChunkedEllpack /** * \brief Set sizes of particular segments. */ template< typename SizesHolder = OffsetsHolder > template< typename SizesHolder = OffsetsContainer > void setSegmentsSizes( const SizesHolder& sizes ); void reset(); Loading Loading @@ -150,19 +150,19 @@ class ChunkedEllpack * For each segment, this keeps index of the slice which contains the * segment. */ OffsetsHolder rowToSliceMapping; OffsetsContainer rowToSliceMapping; /** * For each row, this keeps index of the first chunk within a slice. */ OffsetsHolder rowToChunkMapping; OffsetsContainer rowToChunkMapping; OffsetsHolder chunksToSegmentsMapping; OffsetsContainer chunksToSegmentsMapping; /** * Keeps index of the first segment index. */ OffsetsHolder rowPointers; OffsetsContainer rowPointers; ChunkedEllpackSliceInfoContainer slices; Loading src/TNL/Algorithms/Segments/Ellpack.h +3 −3 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ class Ellpack using IndexType = std::remove_const_t< Index >; static constexpr int getAlignment() { return Alignment; } static constexpr ElementsOrganization getOrganization() { return Organization; } using OffsetsHolder = Containers::Vector< IndexType, DeviceType, IndexType >; using SegmentsSizes = OffsetsHolder; using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType >; using SegmentsSizes = OffsetsContainer; template< typename Device_, typename Index_ > using ViewTemplate = EllpackView< Device_, Index_, Organization, Alignment >; using ViewType = EllpackView< Device, Index, Organization, Alignment >; Loading Loading @@ -66,7 +66,7 @@ class Ellpack /** * \brief Set sizes of particular segments. */ template< typename SizesHolder = OffsetsHolder > template< typename SizesHolder = OffsetsContainer > void setSegmentsSizes( const SizesHolder& sizes ); void setSegmentsSizes( const IndexType segmentsCount, const IndexType segmentSize ); Loading Loading
src/TNL/Algorithms/Segments/BiEllpack.h +8 −8 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class BiEllpack public: using DeviceType = Device; using IndexType = std::remove_const_t<Index>; using OffsetsHolder = Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocator>; using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType, IndexAllocator>; static constexpr ElementsOrganization getOrganization() { return Organization; } using ViewType = BiEllpackView< Device, Index, Organization, WarpSize >; template <typename Device_, typename Index_> Loading Loading @@ -73,7 +73,7 @@ class BiEllpack /** * \brief Set sizes of particular segments. */ template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void setSegmentsSizes(const SizesHolder &sizes); void reset(); Loading Loading @@ -138,11 +138,11 @@ class BiEllpack void printStructure(std::ostream &str) const; // TODO: nvcc needs this public because of lambda function used inside template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void performRowBubbleSort(const SizesHolder &segmentsSize); // TODO: the same as above template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void computeColumnSizes(const SizesHolder &segmentsSizes); protected: Loading @@ -150,10 +150,10 @@ class BiEllpack static constexpr int getLogWarpSize() { return std::log2(WarpSize); }; template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void verifyRowPerm(const SizesHolder &segmentsSizes); template <typename SizesHolder = OffsetsHolder> template <typename SizesHolder = OffsetsContainer> void verifyRowLengths(const SizesHolder &segmentsSizes); IndexType getStripLength(const IndexType stripIdx) const; Loading @@ -164,9 +164,9 @@ class BiEllpack IndexType virtualRows = 0; OffsetsHolder rowPermArray; OffsetsContainer rowPermArray; OffsetsHolder groupPointers; OffsetsContainer groupPointers; // TODO: Replace later __cuda_callable__ Index power(const IndexType number, const IndexType exponent) const Loading
src/TNL/Algorithms/Segments/CSR.h +103 −11 Original line number Diff line number Diff line Loading @@ -26,10 +26,16 @@ namespace TNL { * * See \ref TNL::Algorithms::Segments for more details about segments. * * \tparam Device * \tparam Index * \tparam CSRScalarKernel< Index, Device > * \tparam Allocator< Index > * \tparam Device is type of device where the segments will be operating. * \tparam Index is type for indexing of the elements managed by the segments. * \tparam Kernel is type of kernel used for parallel operations with segments. * It can be any of the following: * \ref TNL::Containers::Segments::Kernels::CSRAdaptiveKernel, * \ref TNL::Containers::Segments::Kernels::CSRHybridKernel, * \ref TNL::Containers::Segments::Kernels::CSRScalarKernel, * \ref TNL::Containers::Segments::Kernels::CSRVectorKernel * * \tparam IndexAllocator is allocator for supporting index containers. */ template< typename Device, typename Index, Loading @@ -39,31 +45,117 @@ class CSR { public: /** * \brief The device where the segments are operating. */ using DeviceType = Device; /** * \brief The type used for indexing of segments elements. */ using IndexType = std::remove_const_t< Index >; /** * \brief Type of kernel used for reduction operations. */ using KernelType = Kernel; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; using SegmentsSizes = OffsetsHolder; /** * \brief Type of container storing offsets of particular rows. */ using OffsetsContainer = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; /** * \brief Templated view type. * * \tparam Device_ is alternative device type for the view. * \tparam Index_ is alternative index type for the view. */ template< typename Device_, typename Index_ > using ViewTemplate = CSRView< Device_, Index_, KernelType >; /** * \brief Type of segments view.1 */ using ViewType = CSRView< Device, Index, KernelType >; /** * \brief Type of constant segments view. */ using ConstViewType = CSRView< Device, std::add_const_t< IndexType >, KernelType >; /** * \brief Accessor type fro one particular segment. */ using SegmentViewType = SegmentView< IndexType, RowMajorOrder >; static constexpr ElementsOrganization getOrganization() { return ColumnMajorOrder; } /** * \brief This functions says that CSR format is always organised in row-major order. */ static constexpr ElementsOrganization getOrganization() { return RowMajorOrder; } /** * \brief This function says that CSR format does not use padding elements. */ static constexpr bool havePadding() { return false; }; /** * \brief Construct with no parameters to create empty segments. */ CSR(); /** * \brief Construct with segments sizes. * * The number of segments is given by the size of \e segmentsSizes. Particular elements * of this container define sizes of particular segments. * * \tparam SizesContainer is a type of container for segments sizes. * \param sizes is an instance of the container with the segments sizes. * * See the following example: * * \includelineno Algorithms/Segments/SegmentsExample_CSR_constructor_1.cpp * * The result looks as follows: * * \include SegmentsExample_CSR_constructor_1.out */ template< typename SizesContainer > CSR( const SizesContainer& sizes ); CSR( const SizesContainer& segmentsSizes ); /** * \brief Construct with segments sizes in initializer list.. * * The number of segments is given by the size of \e segmentsSizes. Particular elements * of this initializer list define sizes of particular segments. * * \tparam ListIndex is a type of indexes of the initializer list. * \param sizes is an instance of the container with the segments sizes. * * See the following example: * * \includelineno Algorithms/Segments/SegmentsExample_constructor_2.cpp * * The result looks as follows: * * \include SegmentsExample_constructor_1.out */ template< typename ListIndex > CSR( const std::initializer_list< ListIndex >& segmentsSizes ); /** * \brief Copy constructor. * * \param segments are the source segments. */ CSR( const CSR& segments ); /** * \brief Move constructor. * * \param segments are the source segments. */ CSR( const CSR&& segments ); static String getSerializationType(); Loading Loading @@ -112,9 +204,9 @@ class CSR __cuda_callable__ SegmentViewType getSegmentView( const IndexType segmentIdx ) const; const OffsetsHolder& getOffsets() const; const OffsetsContainer& getOffsets() const; OffsetsHolder& getOffsets(); OffsetsContainer& getOffsets(); /*** * \brief Go over all segments and for each segment element call Loading Loading @@ -154,7 +246,7 @@ class CSR protected: OffsetsHolder offsets; OffsetsContainer offsets; KernelType kernel; }; Loading
src/TNL/Algorithms/Segments/CSR.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ template< typename Device, typename IndexAllocator > auto CSR< Device, Index, Kernel, IndexAllocator >:: getOffsets() const -> const OffsetsHolder& getOffsets() const -> const OffsetsContainer& { return this->offsets; } Loading @@ -230,7 +230,7 @@ template< typename Device, typename IndexAllocator > auto CSR< Device, Index, Kernel, IndexAllocator >:: getOffsets() -> OffsetsHolder& getOffsets() -> OffsetsContainer& { return this->offsets; } Loading
src/TNL/Algorithms/Segments/ChunkedEllpack.h +6 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class ChunkedEllpack using DeviceType = Device; using IndexType = std::remove_const_t< Index >; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; using OffsetsContainer = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; static constexpr ElementsOrganization getOrganization() { return Organization; } using ViewType = ChunkedEllpackView< Device, Index, Organization >; template< typename Device_, typename Index_ > Loading Loading @@ -72,7 +72,7 @@ class ChunkedEllpack /** * \brief Set sizes of particular segments. */ template< typename SizesHolder = OffsetsHolder > template< typename SizesHolder = OffsetsContainer > void setSegmentsSizes( const SizesHolder& sizes ); void reset(); Loading Loading @@ -150,19 +150,19 @@ class ChunkedEllpack * For each segment, this keeps index of the slice which contains the * segment. */ OffsetsHolder rowToSliceMapping; OffsetsContainer rowToSliceMapping; /** * For each row, this keeps index of the first chunk within a slice. */ OffsetsHolder rowToChunkMapping; OffsetsContainer rowToChunkMapping; OffsetsHolder chunksToSegmentsMapping; OffsetsContainer chunksToSegmentsMapping; /** * Keeps index of the first segment index. */ OffsetsHolder rowPointers; OffsetsContainer rowPointers; ChunkedEllpackSliceInfoContainer slices; Loading
src/TNL/Algorithms/Segments/Ellpack.h +3 −3 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ class Ellpack using IndexType = std::remove_const_t< Index >; static constexpr int getAlignment() { return Alignment; } static constexpr ElementsOrganization getOrganization() { return Organization; } using OffsetsHolder = Containers::Vector< IndexType, DeviceType, IndexType >; using SegmentsSizes = OffsetsHolder; using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType >; using SegmentsSizes = OffsetsContainer; template< typename Device_, typename Index_ > using ViewTemplate = EllpackView< Device_, Index_, Organization, Alignment >; using ViewType = EllpackView< Device, Index, Organization, Alignment >; Loading Loading @@ -66,7 +66,7 @@ class Ellpack /** * \brief Set sizes of particular segments. */ template< typename SizesHolder = OffsetsHolder > template< typename SizesHolder = OffsetsContainer > void setSegmentsSizes( const SizesHolder& sizes ); void setSegmentsSizes( const IndexType segmentsCount, const IndexType segmentSize ); Loading