Commit 7218a64d authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Tomáš Oberhuber
Browse files

Replacing CSRSegmentView and EllpackSegment view with one general but specialized SegmentView.

parent 8758a8e6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@

#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Segments/CSRView.h>
#include <TNL/Containers/Segments/CSRSegmentView.h>
#include <TNL/Containers/Segments/SegmentView.h>

namespace TNL {
   namespace Containers {
@@ -35,7 +35,7 @@ class CSR
      using ViewTemplate = CSRView< Device_, Index_ >;
      using ViewType = CSRView< Device, Index >;
      using ConstViewType = CSRView< Device, std::add_const_t< Index > >;
      using SegmentViewType = CSRSegmentView< IndexType >;
      using SegmentViewType = SegmentView< IndexType, true >;

      CSR();

+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ auto
CSR< Device, Index, IndexAllocator >::
getSegmentView( const IndexType segmentIdx ) const -> SegmentViewType
{
   return SegmentView( offsets[ segmentIdx ], offsets[ segmentIdx + 1 ] - offsets[ segmentIdx ] );
   return SegmentViewType( offsets[ segmentIdx ], offsets[ segmentIdx + 1 ] - offsets[ segmentIdx ] );
}

template< typename Device,
+0 −47
Original line number Diff line number Diff line
/***************************************************************************
                          CSRSegmentView.h -  description
                             -------------------
    begin                : Dec 28, 2019
    copyright            : (C) 2019 by Tomas Oberhuber
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/* See Copyright Notice in tnl/Copyright */

#pragma once

namespace TNL {
   namespace Containers {
      namespace Segments {

template< typename Index >
class CSRSegmentView
{
   public:

      using IndexType = Index;

      __cuda_callable__
      CSRSegmentView( const IndexType offset, const IndexType size )
      : segmentOffset( offset ), segmentSize( size ){};

      __cuda_callable__
      IndexType getSize() const
      {
         return this->segmentSize;
      };

      __cuda_callable__
      IndexType getGlobalIndex( const IndexType localIndex ) const
      {
         TNL_ASSERT_LT( localIndex, segmentSize, "Local index exceeds segment bounds." );
         return segmentOffset + localIndex;
      };

      protected:

         IndexType segmentOffset, segmentSize;
};
      } //namespace Segments
   } //namespace Containers
} //namespace TNL
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
#include <type_traits>

#include <TNL/Containers/Vector.h>
#include <TNL/Containers/Segments/CSRSegmentView.h>
#include <TNL/Containers/Segments/SegmentView.h>

namespace TNL {
   namespace Containers {
@@ -33,7 +33,7 @@ class CSRView
      template< typename Device_, typename Index_ >
      using ViewTemplate = CSRView< Device_, Index_ >;
      using ConstViewType = CSRView< Device, std::add_const_t< Index > >;
      using SegmentViewType = CSRSegmentView< IndexType >;
      using SegmentViewType = SegmentView< IndexType >;

      __cuda_callable__
      CSRView();
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ auto
CSRView< Device, Index >::
getSegmentView( const IndexType segmentIdx ) const -> SegmentViewType
{
   return SegmentViewType( offsets[ segmentIdx ], offsets[ segmentIdx + 1 ] - offsets[ segmentIdx ] );
   return SegmentViewType( offsets[ segmentIdx ], offsets[ segmentIdx + 1 ] - offsets[ segmentIdx ], 1 );
}

template< typename Device,
Loading