Skip to content
Snippets Groups Projects
Commit c4969701 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Jakub Klinkovský
Browse files

Renaming OffsetsHolder to OffsetsContainer.

parent 31bfdd99
No related branches found
No related tags found
1 merge request!105TO/matrices-adaptive-csr
......@@ -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_>
......@@ -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();
......@@ -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:
......@@ -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;
......@@ -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
......
......@@ -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,
......@@ -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();
......@@ -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
......@@ -154,7 +246,7 @@ class CSR
protected:
OffsetsHolder offsets;
OffsetsContainer offsets;
KernelType kernel;
};
......
......@@ -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;
}
......@@ -230,7 +230,7 @@ template< typename Device,
typename IndexAllocator >
auto
CSR< Device, Index, Kernel, IndexAllocator >::
getOffsets() -> OffsetsHolder&
getOffsets() -> OffsetsContainer&
{
return this->offsets;
}
......
......@@ -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_ >
......@@ -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();
......@@ -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;
......
......@@ -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 >;
......@@ -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 );
......
......@@ -34,8 +34,8 @@ class EllpackView
using IndexType = std::remove_const_t< Index >;
static constexpr int getAlignment() { return Alignment; }
static constexpr bool 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;
......
......@@ -30,7 +30,7 @@ class SlicedEllpack
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 int getSliceSize() { return SliceSize; }
static constexpr ElementsOrganization getOrganization() { return Organization; }
using ViewType = SlicedEllpackView< Device, Index, Organization, SliceSize >;
......@@ -64,7 +64,7 @@ class SlicedEllpack
/**
* \brief Set sizes of particular segments.
*/
template< typename SizesHolder = OffsetsHolder >
template< typename SizesHolder = OffsetsContainer >
void setSegmentsSizes( const SizesHolder& sizes );
void reset();
......@@ -131,7 +131,7 @@ class SlicedEllpack
IndexType size, alignedSize, segmentsCount;
OffsetsHolder sliceOffsets, sliceSegmentSizes;
OffsetsContainer sliceOffsets, sliceSegmentSizes;
};
template <typename Device,
......
......@@ -31,10 +31,10 @@ class BiEllpack
using DeviceType = Device;
using IndexType = Index;
static constexpr bool getOrganization() { return Organization; }
using OffsetsHolder = Containers::Vector< IndexType, DeviceType, IndexType >;
using OffsetsHolderView = typename OffsetsHolder::ViewType;
using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType >;
using OffsetsHolderView = typename OffsetsContainer::ViewType;
using ConstOffsetsHolderView = typename OffsetsHolderView::ConstViewType;
using SegmentsSizes = OffsetsHolder;
using SegmentsSizes = OffsetsContainer;
using SegmentViewType = BiEllpackSegmentView< IndexType, Organization >;
static constexpr int getWarpSize() { return WarpSize; };
......
......@@ -62,10 +62,10 @@ class ChunkedEllpack
using DeviceType = Device;
using IndexType = Index;
static constexpr ElementsOrganization getOrganization() { return Organization; }
using OffsetsHolder = Containers::Vector< IndexType, DeviceType, IndexType >;
using OffsetsHolderView = typename OffsetsHolder::ViewType;
using SegmentsSizes = OffsetsHolder;
using ChunkedEllpackSliceInfoType = detail::ChunkedEllpackSliceInfo< IndexType >;
using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType >;
using OffsetsHolderView = typename OffsetsContainer::ViewType;
using SegmentsSizes = OffsetsContainer;
using ChunkedEllpackSliceInfoType = details::ChunkedEllpackSliceInfo< IndexType >;
using ChunkedEllpackSliceInfoAllocator = typename Allocators::Default< Device >::template Allocator< ChunkedEllpackSliceInfoType >;
using ChunkedEllpackSliceInfoContainer = Containers::Array< ChunkedEllpackSliceInfoType, DeviceType, IndexType, ChunkedEllpackSliceInfoAllocator >;
using ChunkedEllpackSliceInfoContainerView = typename ChunkedEllpackSliceInfoContainer::ViewType;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment