Commit 8f29cea1 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added copy-constructors and operators to multimaps

parent 19591600
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -29,7 +29,13 @@ class EllpackIndexMultimap
      using ConstValuesAccessorType    = EllpackIndexMultimapValues< const IndexType, DeviceType, LocalIndexType >;
      using ValuesAllocationVectorType = Containers::Vector< LocalIndexType, DeviceType, IndexType >;

      EllpackIndexMultimap();
      EllpackIndexMultimap() = default;

      template< typename Device_ >
      EllpackIndexMultimap( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other );

      template< typename Device_ >
      EllpackIndexMultimap& operator=( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other );

      static String getType();

@@ -37,14 +43,20 @@ class EllpackIndexMultimap

      void setKeysRange( const IndexType& keysRange );

      __cuda_callable__
      const IndexType getKeysRange() const;

      bool allocate( const LocalIndexType& maxValuesCount );

      bool allocate( const ValuesAllocationVectorType& valuesCounts );

      template< typename Device_ >
      bool setLike( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other );

      __cuda_callable__
      ValuesAccessorType getValues( const IndexType& inputIndex );

      __cuda_callable__
      ConstValuesAccessorType getValues( const IndexType& inputIndex ) const;

      bool operator==( const EllpackIndexMultimap< Index, Device, LocalIndex >& other ) const;
@@ -63,8 +75,12 @@ class EllpackIndexMultimap
      Containers::Vector< IndexType, DeviceType, IndexType > values;
      Containers::Vector< LocalIndexType, DeviceType, IndexType > valuesCounts;

      IndexType keysRange;
      LocalIndexType maxValuesCount;
      IndexType keysRange = 0;
      LocalIndexType maxValuesCount = 0;

      // friend class is needed for templated assignment operators
      template< typename Index_, typename Device_, typename LocalIndex_ >
      friend class EllpackIndexMultimap;
};

template< typename Index,
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ class EllpackIndexMultimapValues
                                                         typename std::add_const< LocalIndexType >::type,
                                                         LocalIndexType >::type;

      __cuda_callable__
      EllpackIndexMultimapValues( IndexType* values,
                                  ValuesCountType* valuesCounts,
                                  const IndexType& input,
+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ bind( const EllpackIndexMultimapValues& other )
template< typename Index,
          typename Device,
          typename LocalIndex >
__cuda_callable__
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
EllpackIndexMultimapValues( IndexType* values,
                            ValuesCountType* valuesCounts,
+38 −2
Original line number Diff line number Diff line
@@ -17,10 +17,26 @@ namespace TNL {
template< typename Index,
          typename Device,
          typename LocalIndex >
   template< typename Device_ >
EllpackIndexMultimap< Index, Device, LocalIndex >::
EllpackIndexMultimap()
: keysRange( 0 ), maxValuesCount( 0 )
EllpackIndexMultimap( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other )
{
   operator=( other );
}

template< typename Index,
          typename Device,
          typename LocalIndex >
   template< typename Device_ >
EllpackIndexMultimap< Index, Device, LocalIndex >&
EllpackIndexMultimap< Index, Device, LocalIndex >::
operator=( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other )
{
   values = other.values;
   valuesCounts = other.valuesCounts;
   keysRange = other.keysRange;
   maxValuesCount = other.maxValuesCount;
   return *this;
}

template< typename Index,
@@ -63,6 +79,7 @@ setKeysRange( const IndexType& keysRange )
template< typename Index,
          typename Device,
          typename LocalIndex >
__cuda_callable__
const Index
EllpackIndexMultimap< Index, Device, LocalIndex >::
getKeysRange() const
@@ -113,6 +130,24 @@ allocate( const ValuesAllocationVectorType& valuesCounts )
template< typename Index,
          typename Device,
          typename LocalIndex >
   template< typename Device_ >
bool
EllpackIndexMultimap< Index, Device, LocalIndex >::
setLike( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other )
{
   if( ! values.setLike( other.values ) )
      return false;
   if( ! valuesCounts.setLike( other.valuesCounts ) )
      return false;
   keysRange = other.keysRange;
   maxValuesCount = other.keysRange;
   return true;
}

template< typename Index,
          typename Device,
          typename LocalIndex >
__cuda_callable__
typename EllpackIndexMultimap< Index, Device, LocalIndex >::ValuesAccessorType
EllpackIndexMultimap< Index, Device, LocalIndex >::
getValues( const IndexType& inputIndex )
@@ -133,6 +168,7 @@ getValues( const IndexType& inputIndex )
template< typename Index,
          typename Device,
          typename LocalIndex >
__cuda_callable__
typename EllpackIndexMultimap< Index, Device, LocalIndex >::ConstValuesAccessorType
EllpackIndexMultimap< Index, Device, LocalIndex >::
getValues( const IndexType& inputIndex ) const
+18 −2
Original line number Diff line number Diff line
@@ -29,7 +29,13 @@ class StaticEllpackIndexMultimap
      using ValuesAccessorType         = StaticEllpackIndexMultimapValues< ValuesCount, IndexType, DeviceType, LocalIndexType >;
      using ConstValuesAccessorType    = StaticEllpackIndexMultimapValues< ValuesCount, const IndexType, DeviceType, LocalIndexType >;

      StaticEllpackIndexMultimap();
      StaticEllpackIndexMultimap() = default;

      template< typename Device_ >
      StaticEllpackIndexMultimap( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other );

      template< typename Device_ >
      StaticEllpackIndexMultimap& operator=( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other );

      static String getType();

@@ -37,12 +43,18 @@ class StaticEllpackIndexMultimap

      void setKeysRange( const IndexType& keysRange );

      __cuda_callable__
      const IndexType getKeysRange() const;

      bool allocate();

      template< typename Device_ >
      bool setLike( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other );

      __cuda_callable__
      ValuesAccessorType getValues( const IndexType& inputIndex );

      __cuda_callable__
      ConstValuesAccessorType getValues( const IndexType& inputIndex ) const;

      bool operator==( const StaticEllpackIndexMultimap& other ) const;
@@ -60,7 +72,11 @@ class StaticEllpackIndexMultimap
   protected:
      Containers::Vector< IndexType, DeviceType, IndexType > values;

      IndexType keysRange;
      IndexType keysRange = 0;

      // friend class is needed for templated assignment operators
      template< int ValuesCount_, typename Index_, typename Device_, typename LocalIndex_ >
      friend class StaticEllpackIndexMultimap;
};

template< int ValuesCount,
Loading