Loading src/TNL/Containers/Segments/CSR.h +4 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ class CSR public: using DeviceType = Device; using IndexType = Index; using OffsetsHolder = Containers::Vector< IndexType, DeviceType, typename std::remove_const< IndexType >::type, IndexAllocator >; using IndexType = std::remove_const_t< Index >; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; using SegmentsSizes = OffsetsHolder; template< typename Device_, typename Index_ > using ViewTemplate = CSRView< Device_, Index_ >; using ViewType = CSRView< Device, Index >; using ConstViewType = CSRView< Device, std::add_const_t< Index > >; using ConstViewType = CSRView< Device, std::add_const_t< IndexType > >; using SegmentViewType = SegmentView< IndexType, true >; CSR(); Loading @@ -57,7 +57,7 @@ class CSR ViewType getView(); ConstViewType getConstView() const; const ConstViewType getConstView() const; /** * \brief Number segments. Loading src/TNL/Containers/Segments/CSR.hpp +15 −46 Original line number Diff line number Diff line Loading @@ -98,9 +98,9 @@ getView() template< typename Device, typename Index, typename IndexAllocator > typename CSR< Device, Index, IndexAllocator >::ConstViewType auto CSR< Device, Index, IndexAllocator >:: getConstView() const getConstView() const -> const ConstViewType { return ConstViewType( this->offsets.getConstView() ); } Loading @@ -108,10 +108,8 @@ getConstView() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getSegmentsCount() const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getSegmentsCount() const -> IndexType { return this->offsets.getSize() - 1; } Loading @@ -119,10 +117,8 @@ getSegmentsCount() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getSegmentSize( const IndexType segmentIdx ) const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getSegmentSize( const IndexType segmentIdx ) const -> IndexType { return details::CSR< Device, Index >::getSegmentSize( this->offsets, segmentIdx ); } Loading @@ -130,10 +126,8 @@ getSegmentSize( const IndexType segmentIdx ) const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getSize() const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getSize() const -> IndexType { return this->getStorageSize(); } Loading @@ -141,10 +135,8 @@ getSize() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getStorageSize() const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getStorageSize() const -> IndexType { return details::CSR< Device, Index >::getStorageSize( this->offsets ); } Loading @@ -152,10 +144,8 @@ getStorageSize() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const -> IndexType { if( ! std::is_same< DeviceType, Devices::Host >::value ) { Loading Loading @@ -197,16 +187,7 @@ void CSR< Device, Index, IndexAllocator >:: forSegments( IndexType first, IndexType last, Function& f, Args... args ) const { const auto offsetsView = this->offsets.getConstView(); auto l = [=] __cuda_callable__ ( const IndexType segmentIdx, Args... args ) mutable { const IndexType begin = offsetsView[ segmentIdx ]; const IndexType end = offsetsView[ segmentIdx + 1 ]; IndexType localIdx( 0 ); for( IndexType globalIdx = begin; globalIdx < end; globalIdx++ ) if( ! f( segmentIdx, localIdx++, globalIdx, args... ) ) break; }; Algorithms::ParallelFor< Device >::exec( first, last, l, args... ); this->getConstView().forSegments( first, last, f, args... ); } template< typename Device, Loading @@ -228,19 +209,7 @@ void CSR< Device, Index, IndexAllocator >:: segmentsReduction( IndexType first, IndexType last, Fetch& fetch, Reduction& reduction, ResultKeeper& keeper, const Real& zero, Args... args ) const { using RealType = decltype( fetch( IndexType(), IndexType(), IndexType(), std::declval< bool& >(), args... ) ); const auto offsetsView = this->offsets.getConstView(); auto l = [=] __cuda_callable__ ( const IndexType i, Args... args ) mutable { const IndexType begin = offsetsView[ i ]; const IndexType end = offsetsView[ i + 1 ]; RealType aux( zero ); bool compute( true ); IndexType localIdx( 0 ); for( IndexType j = begin; j < end && compute; j++ ) reduction( aux, fetch( i, localIdx++, j, compute, args... ) ); keeper( i, aux ); }; Algorithms::ParallelFor< Device >::exec( first, last, l, args... ); this->getConstView().segmentsReduction( first, last, fetch, reduction, keeper, zero, args... ); } template< typename Device, Loading src/TNL/Containers/Segments/CSRView.h +4 −4 Original line number Diff line number Diff line Loading @@ -26,9 +26,9 @@ class CSRView public: using DeviceType = Device; using IndexType = Index; using OffsetsView = typename Containers::VectorView< IndexType, DeviceType, typename std::remove_const< IndexType >::type >; using ConstOffsetsView = typename Containers::Vector< IndexType, DeviceType, typename std::remove_const< IndexType >::type >::ConstViewType; using IndexType = std::remove_const_t< Index >; using OffsetsView = typename Containers::VectorView< Index, DeviceType, IndexType >; using ConstOffsetsView = typename Containers::Vector< Index, DeviceType,IndexType >::ConstViewType; using ViewType = CSRView; template< typename Device_, typename Index_ > using ViewTemplate = CSRView< Device_, Index_ >; Loading Loading @@ -58,7 +58,7 @@ class CSRView ViewType getView(); __cuda_callable__ ConstViewType getConstView() const; const ConstViewType getConstView() const; /** * \brief Number segments. Loading src/TNL/Containers/Segments/CSRView.hpp +12 −22 Original line number Diff line number Diff line Loading @@ -96,59 +96,49 @@ getView() template< typename Device, typename Index > __cuda_callable__ typename CSRView< Device, Index >::ConstViewType auto CSRView< Device, Index >:: getConstView() const getConstView() const -> const ConstViewType { return ConstViewType( this->offsets.getConstView() ); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getSegmentsCount() const __cuda_callable__ auto CSRView< Device, Index >:: getSegmentsCount() const -> IndexType { return this->offsets.getSize() - 1; } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getSegmentSize( const IndexType segmentIdx ) const __cuda_callable__ auto CSRView< Device, Index >:: getSegmentSize( const IndexType segmentIdx ) const -> IndexType { return details::CSR< Device, Index >::getSegmentSize( this->offsets, segmentIdx ); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getSize() const __cuda_callable__ auto CSRView< Device, Index >:: getSize() const -> IndexType { return this->getStorageSize(); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getStorageSize() const __cuda_callable__ auto CSRView< Device, Index >:: getStorageSize() const -> IndexType { return details::CSR< Device, Index >::getStorageSize( this->offsets ); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const __cuda_callable__ auto CSRView< Device, Index >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const -> IndexType { if( ! std::is_same< DeviceType, Devices::Host >::value ) { Loading src/TNL/Containers/Segments/ChunkedEllpack.h +4 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ class ChunkedEllpack public: using DeviceType = Device; using IndexType = Index; using OffsetsHolder = Containers::Vector< IndexType, DeviceType, typename std::remove_const< IndexType >::type, IndexAllocator >; using IndexType = std::remove_const_t< Index >; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; static constexpr bool getRowMajorOrder() { return RowMajorOrder; } using ViewType = ChunkedEllpackView< Device, Index, RowMajorOrder >; template< typename Device_, typename Index_ > using ViewTemplate = ChunkedEllpackView< Device_, Index_, RowMajorOrder >; using ConstViewType = ChunkedEllpackView< Device, std::add_const_t< Index >, RowMajorOrder >; using ConstViewType = ChunkedEllpackView< Device, std::add_const_t< IndexType >, RowMajorOrder >; using SegmentViewType = ChunkedEllpackSegmentView< IndexType, RowMajorOrder >; using ChunkedEllpackSliceInfoType = details::ChunkedEllpackSliceInfo< IndexType >; //TODO: using ChunkedEllpackSliceInfoAllocator = typename IndexAllocatorType::retype< ChunkedEllpackSliceInfoType >; Loading @@ -55,7 +55,7 @@ class ChunkedEllpack ViewType getView(); ConstViewType getConstView() const; const ConstViewType getConstView() const; /** * \brief Set sizes of particular segments. Loading Loading
src/TNL/Containers/Segments/CSR.h +4 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ class CSR public: using DeviceType = Device; using IndexType = Index; using OffsetsHolder = Containers::Vector< IndexType, DeviceType, typename std::remove_const< IndexType >::type, IndexAllocator >; using IndexType = std::remove_const_t< Index >; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; using SegmentsSizes = OffsetsHolder; template< typename Device_, typename Index_ > using ViewTemplate = CSRView< Device_, Index_ >; using ViewType = CSRView< Device, Index >; using ConstViewType = CSRView< Device, std::add_const_t< Index > >; using ConstViewType = CSRView< Device, std::add_const_t< IndexType > >; using SegmentViewType = SegmentView< IndexType, true >; CSR(); Loading @@ -57,7 +57,7 @@ class CSR ViewType getView(); ConstViewType getConstView() const; const ConstViewType getConstView() const; /** * \brief Number segments. Loading
src/TNL/Containers/Segments/CSR.hpp +15 −46 Original line number Diff line number Diff line Loading @@ -98,9 +98,9 @@ getView() template< typename Device, typename Index, typename IndexAllocator > typename CSR< Device, Index, IndexAllocator >::ConstViewType auto CSR< Device, Index, IndexAllocator >:: getConstView() const getConstView() const -> const ConstViewType { return ConstViewType( this->offsets.getConstView() ); } Loading @@ -108,10 +108,8 @@ getConstView() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getSegmentsCount() const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getSegmentsCount() const -> IndexType { return this->offsets.getSize() - 1; } Loading @@ -119,10 +117,8 @@ getSegmentsCount() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getSegmentSize( const IndexType segmentIdx ) const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getSegmentSize( const IndexType segmentIdx ) const -> IndexType { return details::CSR< Device, Index >::getSegmentSize( this->offsets, segmentIdx ); } Loading @@ -130,10 +126,8 @@ getSegmentSize( const IndexType segmentIdx ) const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getSize() const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getSize() const -> IndexType { return this->getStorageSize(); } Loading @@ -141,10 +135,8 @@ getSize() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getStorageSize() const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getStorageSize() const -> IndexType { return details::CSR< Device, Index >::getStorageSize( this->offsets ); } Loading @@ -152,10 +144,8 @@ getStorageSize() const template< typename Device, typename Index, typename IndexAllocator > __cuda_callable__ Index CSR< Device, Index, IndexAllocator >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const __cuda_callable__ auto CSR< Device, Index, IndexAllocator >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const -> IndexType { if( ! std::is_same< DeviceType, Devices::Host >::value ) { Loading Loading @@ -197,16 +187,7 @@ void CSR< Device, Index, IndexAllocator >:: forSegments( IndexType first, IndexType last, Function& f, Args... args ) const { const auto offsetsView = this->offsets.getConstView(); auto l = [=] __cuda_callable__ ( const IndexType segmentIdx, Args... args ) mutable { const IndexType begin = offsetsView[ segmentIdx ]; const IndexType end = offsetsView[ segmentIdx + 1 ]; IndexType localIdx( 0 ); for( IndexType globalIdx = begin; globalIdx < end; globalIdx++ ) if( ! f( segmentIdx, localIdx++, globalIdx, args... ) ) break; }; Algorithms::ParallelFor< Device >::exec( first, last, l, args... ); this->getConstView().forSegments( first, last, f, args... ); } template< typename Device, Loading @@ -228,19 +209,7 @@ void CSR< Device, Index, IndexAllocator >:: segmentsReduction( IndexType first, IndexType last, Fetch& fetch, Reduction& reduction, ResultKeeper& keeper, const Real& zero, Args... args ) const { using RealType = decltype( fetch( IndexType(), IndexType(), IndexType(), std::declval< bool& >(), args... ) ); const auto offsetsView = this->offsets.getConstView(); auto l = [=] __cuda_callable__ ( const IndexType i, Args... args ) mutable { const IndexType begin = offsetsView[ i ]; const IndexType end = offsetsView[ i + 1 ]; RealType aux( zero ); bool compute( true ); IndexType localIdx( 0 ); for( IndexType j = begin; j < end && compute; j++ ) reduction( aux, fetch( i, localIdx++, j, compute, args... ) ); keeper( i, aux ); }; Algorithms::ParallelFor< Device >::exec( first, last, l, args... ); this->getConstView().segmentsReduction( first, last, fetch, reduction, keeper, zero, args... ); } template< typename Device, Loading
src/TNL/Containers/Segments/CSRView.h +4 −4 Original line number Diff line number Diff line Loading @@ -26,9 +26,9 @@ class CSRView public: using DeviceType = Device; using IndexType = Index; using OffsetsView = typename Containers::VectorView< IndexType, DeviceType, typename std::remove_const< IndexType >::type >; using ConstOffsetsView = typename Containers::Vector< IndexType, DeviceType, typename std::remove_const< IndexType >::type >::ConstViewType; using IndexType = std::remove_const_t< Index >; using OffsetsView = typename Containers::VectorView< Index, DeviceType, IndexType >; using ConstOffsetsView = typename Containers::Vector< Index, DeviceType,IndexType >::ConstViewType; using ViewType = CSRView; template< typename Device_, typename Index_ > using ViewTemplate = CSRView< Device_, Index_ >; Loading Loading @@ -58,7 +58,7 @@ class CSRView ViewType getView(); __cuda_callable__ ConstViewType getConstView() const; const ConstViewType getConstView() const; /** * \brief Number segments. Loading
src/TNL/Containers/Segments/CSRView.hpp +12 −22 Original line number Diff line number Diff line Loading @@ -96,59 +96,49 @@ getView() template< typename Device, typename Index > __cuda_callable__ typename CSRView< Device, Index >::ConstViewType auto CSRView< Device, Index >:: getConstView() const getConstView() const -> const ConstViewType { return ConstViewType( this->offsets.getConstView() ); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getSegmentsCount() const __cuda_callable__ auto CSRView< Device, Index >:: getSegmentsCount() const -> IndexType { return this->offsets.getSize() - 1; } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getSegmentSize( const IndexType segmentIdx ) const __cuda_callable__ auto CSRView< Device, Index >:: getSegmentSize( const IndexType segmentIdx ) const -> IndexType { return details::CSR< Device, Index >::getSegmentSize( this->offsets, segmentIdx ); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getSize() const __cuda_callable__ auto CSRView< Device, Index >:: getSize() const -> IndexType { return this->getStorageSize(); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getStorageSize() const __cuda_callable__ auto CSRView< Device, Index >:: getStorageSize() const -> IndexType { return details::CSR< Device, Index >::getStorageSize( this->offsets ); } template< typename Device, typename Index > __cuda_callable__ Index CSRView< Device, Index >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const __cuda_callable__ auto CSRView< Device, Index >:: getGlobalIndex( const Index segmentIdx, const Index localIdx ) const -> IndexType { if( ! std::is_same< DeviceType, Devices::Host >::value ) { Loading
src/TNL/Containers/Segments/ChunkedEllpack.h +4 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ class ChunkedEllpack public: using DeviceType = Device; using IndexType = Index; using OffsetsHolder = Containers::Vector< IndexType, DeviceType, typename std::remove_const< IndexType >::type, IndexAllocator >; using IndexType = std::remove_const_t< Index >; using OffsetsHolder = Containers::Vector< Index, DeviceType, IndexType, IndexAllocator >; static constexpr bool getRowMajorOrder() { return RowMajorOrder; } using ViewType = ChunkedEllpackView< Device, Index, RowMajorOrder >; template< typename Device_, typename Index_ > using ViewTemplate = ChunkedEllpackView< Device_, Index_, RowMajorOrder >; using ConstViewType = ChunkedEllpackView< Device, std::add_const_t< Index >, RowMajorOrder >; using ConstViewType = ChunkedEllpackView< Device, std::add_const_t< IndexType >, RowMajorOrder >; using SegmentViewType = ChunkedEllpackSegmentView< IndexType, RowMajorOrder >; using ChunkedEllpackSliceInfoType = details::ChunkedEllpackSliceInfo< IndexType >; //TODO: using ChunkedEllpackSliceInfoAllocator = typename IndexAllocatorType::retype< ChunkedEllpackSliceInfoType >; Loading @@ -55,7 +55,7 @@ class ChunkedEllpack ViewType getView(); ConstViewType getConstView() const; const ConstViewType getConstView() const; /** * \brief Set sizes of particular segments. Loading