From 8c2f2c26fdb76be3f95e18277f5e1ea2d2f10c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Sat, 10 Apr 2021 11:30:44 +0200 Subject: [PATCH] Fixing const views for segments. --- src/TNL/Algorithms/Segments/BiEllpack.h | 2 +- src/TNL/Algorithms/Segments/BiEllpackView.h | 2 +- src/TNL/Algorithms/Segments/ChunkedEllpack.h | 5 +++-- src/TNL/Algorithms/Segments/ChunkedEllpack.hpp | 8 ++++---- src/TNL/Algorithms/Segments/ChunkedEllpackView.h | 4 ++-- src/TNL/Algorithms/Segments/detail/BiEllpack.h | 2 +- src/TNL/Algorithms/Segments/detail/ChunkedEllpack.h | 4 ++-- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/TNL/Algorithms/Segments/BiEllpack.h b/src/TNL/Algorithms/Segments/BiEllpack.h index 48aa4e6be6..ee202d25ce 100644 --- a/src/TNL/Algorithms/Segments/BiEllpack.h +++ b/src/TNL/Algorithms/Segments/BiEllpack.h @@ -190,7 +190,7 @@ template <typename Device, typename IndexAllocator, ElementsOrganization Organization, int WarpSize > -std::ostream& operator<<( std::ostream& str, const BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >& segments ) { return printSegments( str, segments ); } +std::ostream& operator<<( std::ostream& str, const BiEllpack< Device, Index, IndexAllocator, Organization, WarpSize >& segments ) { return printSegments( segments, str ); } } // namespace Segments diff --git a/src/TNL/Algorithms/Segments/BiEllpackView.h b/src/TNL/Algorithms/Segments/BiEllpackView.h index c37ed6d730..c0ae1559e8 100644 --- a/src/TNL/Algorithms/Segments/BiEllpackView.h +++ b/src/TNL/Algorithms/Segments/BiEllpackView.h @@ -32,7 +32,7 @@ class BiEllpackView using DeviceType = Device; using IndexType = std::remove_const_t< Index >; - using OffsetsView = typename Containers::VectorView< IndexType, DeviceType, IndexType >; + using OffsetsView = typename Containers::VectorView< Index, DeviceType, IndexType >; using ConstOffsetsView = typename OffsetsView::ConstViewType; using ViewType = BiEllpackView; template< typename Device_, typename Index_ > diff --git a/src/TNL/Algorithms/Segments/ChunkedEllpack.h b/src/TNL/Algorithms/Segments/ChunkedEllpack.h index d5d459a005..5b0916d201 100644 --- a/src/TNL/Algorithms/Segments/ChunkedEllpack.h +++ b/src/TNL/Algorithms/Segments/ChunkedEllpack.h @@ -14,6 +14,7 @@ #include <TNL/Containers/Vector.h> #include <TNL/Algorithms/Segments/ChunkedEllpackView.h> #include <TNL/Algorithms/Segments/SegmentView.h> +#include <TNL/Algorithms/Segments/SegmentsPrinting.h> namespace TNL { namespace Algorithms { @@ -34,7 +35,7 @@ class ChunkedEllpack using ViewType = ChunkedEllpackView< Device, Index, Organization >; template< typename Device_, typename Index_ > using ViewTemplate = ChunkedEllpackView< Device_, Index_, Organization >; - using ConstViewType = ChunkedEllpackView< Device, std::add_const_t< IndexType >, Organization >; + using ConstViewType = typename ViewType::ConstViewType; using SegmentViewType = typename ViewType::SegmentViewType; using ChunkedEllpackSliceInfoType = typename ViewType::ChunkedEllpackSliceInfoType; // detail::ChunkedEllpackSliceInfo< IndexType >; //TODO: using ChunkedEllpackSliceInfoAllocator = typename IndexAllocatorType::retype< ChunkedEllpackSliceInfoType >; @@ -176,7 +177,7 @@ template <typename Device, typename Index, typename IndexAllocator, ElementsOrganization Organization > -std::ostream& operator<<( std::ostream& str, const ChunkedEllpack< Device, Index, IndexAllocator, Organization >& segments ) { return printSegments( str, segments ); } +std::ostream& operator<<( std::ostream& str, const ChunkedEllpack< Device, Index, IndexAllocator, Organization >& segments ) { return printSegments( segments, str ); } } // namespace Segments diff --git a/src/TNL/Algorithms/Segments/ChunkedEllpack.hpp b/src/TNL/Algorithms/Segments/ChunkedEllpack.hpp index 8992d09515..82ddd7d8ed 100644 --- a/src/TNL/Algorithms/Segments/ChunkedEllpack.hpp +++ b/src/TNL/Algorithms/Segments/ChunkedEllpack.hpp @@ -348,10 +348,10 @@ template< typename Device, auto ChunkedEllpack< Device, Index, IndexAllocator, Organization >:: getSegmentSize( const IndexType segmentIdx ) const -> IndexType { - return detail::ChunkedEllpack< IndexType, DeviceType, Organization >::getSegmentSize( - rowToSliceMapping.getView(), - slices.getView(), - rowToChunkMapping.getView(), + return details::ChunkedEllpack< IndexType, DeviceType, Organization >::getSegmentSize( + rowToSliceMapping.getConstView(), + slices.getConstView(), + rowToChunkMapping.getConstView(), segmentIdx ); } diff --git a/src/TNL/Algorithms/Segments/ChunkedEllpackView.h b/src/TNL/Algorithms/Segments/ChunkedEllpackView.h index 123bc1cb92..a20d5a41a6 100644 --- a/src/TNL/Algorithms/Segments/ChunkedEllpackView.h +++ b/src/TNL/Algorithms/Segments/ChunkedEllpackView.h @@ -32,7 +32,7 @@ class ChunkedEllpackView using DeviceType = Device; using IndexType = std::remove_const_t< Index >; - using OffsetsView = typename Containers::VectorView< IndexType, DeviceType, IndexType >; + using OffsetsView = typename Containers::VectorView< Index, DeviceType, IndexType >; using ConstOffsetsView = typename OffsetsView::ConstViewType; using ViewType = ChunkedEllpackView; template< typename Device_, typename Index_ > @@ -41,7 +41,7 @@ class ChunkedEllpackView using SegmentViewType = ChunkedEllpackSegmentView< IndexType, Organization >; using ChunkedEllpackSliceInfoType = detail::ChunkedEllpackSliceInfo< IndexType >; using ChunkedEllpackSliceInfoAllocator = typename Allocators::Default< Device >::template Allocator< ChunkedEllpackSliceInfoType >; - using ChunkedEllpackSliceInfoContainer = Containers::Array< ChunkedEllpackSliceInfoType, DeviceType, IndexType, ChunkedEllpackSliceInfoAllocator >; + using ChunkedEllpackSliceInfoContainer = Containers::Array< typename TNL::copy_const< ChunkedEllpackSliceInfoType >::template from< Index >::type, DeviceType, IndexType, ChunkedEllpackSliceInfoAllocator >; using ChunkedEllpackSliceInfoContainerView = typename ChunkedEllpackSliceInfoContainer::ViewType; static constexpr bool havePadding() { return true; }; diff --git a/src/TNL/Algorithms/Segments/detail/BiEllpack.h b/src/TNL/Algorithms/Segments/detail/BiEllpack.h index 43c42e43c8..db64d392d9 100644 --- a/src/TNL/Algorithms/Segments/detail/BiEllpack.h +++ b/src/TNL/Algorithms/Segments/detail/BiEllpack.h @@ -32,7 +32,7 @@ class BiEllpack using IndexType = Index; static constexpr bool getOrganization() { return Organization; } using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType >; - using OffsetsHolderView = typename OffsetsContainer::ViewType; + using OffsetsHolderView = typename OffsetsContainer::ConstViewType; using ConstOffsetsHolderView = typename OffsetsHolderView::ConstViewType; using SegmentsSizes = OffsetsContainer; using SegmentViewType = BiEllpackSegmentView< IndexType, Organization >; diff --git a/src/TNL/Algorithms/Segments/detail/ChunkedEllpack.h b/src/TNL/Algorithms/Segments/detail/ChunkedEllpack.h index 3e279b02ba..d9a6c30f21 100644 --- a/src/TNL/Algorithms/Segments/detail/ChunkedEllpack.h +++ b/src/TNL/Algorithms/Segments/detail/ChunkedEllpack.h @@ -63,12 +63,12 @@ class ChunkedEllpack using IndexType = Index; static constexpr ElementsOrganization getOrganization() { return Organization; } using OffsetsContainer = Containers::Vector< IndexType, DeviceType, IndexType >; - using OffsetsHolderView = typename OffsetsContainer::ViewType; + using OffsetsHolderView = typename OffsetsContainer::ConstViewType; 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; + using ChunkedEllpackSliceInfoContainerView = typename ChunkedEllpackSliceInfoContainer::ConstViewType; using SegmentViewType = ChunkedEllpackSegmentView< IndexType, Organization >; __cuda_callable__ static -- GitLab