Skip to content
Snippets Groups Projects
StaticEllpackIndexMultimapValues.h 3.51 KiB
Newer Older
/***************************************************************************
                          StaticEllpackIndexMultimapValues.h  -  description
                             -------------------
    begin                : Sep 10, 2015
    copyright            : (C) 2015 by Tomas Oberhuber et al.
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/* See Copyright Notice in tnl/Copyright */

#pragma once

#include <type_traits>
#include <ostream>

#include <TNL/Devices/Cuda.h>

namespace TNL {
namespace Containers {
namespace Multimaps {

template< int ValuesCount,
          typename Index,
          typename Device,
          typename LocalIndex,
          int step >
class StaticEllpackIndexMultimap;

template< int ValuesCount,
          typename Index,
          typename Device,
          typename LocalIndex,
          int step >
class StaticEllpackIndexMultimapValues
{
   public:
      using DeviceType     = Device;
      using IndexType      = Index;
      using LocalIndexType = LocalIndex;
      using NetworkType    = StaticEllpackIndexMultimap< ValuesCount, IndexType, DeviceType, LocalIndexType, step >;
      StaticEllpackIndexMultimapValues();

      StaticEllpackIndexMultimapValues( StaticEllpackIndexMultimapValues&& other );

      StaticEllpackIndexMultimapValues& operator=( const StaticEllpackIndexMultimapValues& other );

      // converting assignment, needed for 'const int' -> 'int' etc.
      template< typename Index_, typename LocalIndex_, int step_ >
      __cuda_callable__
      StaticEllpackIndexMultimapValues& operator=( const StaticEllpackIndexMultimapValues< ValuesCount, Index_, Device, LocalIndex_, step_ >& other );
      StaticEllpackIndexMultimapValues& operator=( StaticEllpackIndexMultimapValues&& other );

      void bind( const StaticEllpackIndexMultimapValues& other );

      constexpr LocalIndexType getSize() const;

      constexpr LocalIndexType getAllocatedSize() const;

      void setValue( const LocalIndexType& portIndex,
                     const IndexType& value );

      IndexType getValue( const LocalIndexType& portIndex ) const;

      IndexType& operator[]( const LocalIndexType& portIndex );

      const IndexType& operator[]( const LocalIndexType& portIndex ) const;

      bool operator==( const StaticEllpackIndexMultimapValues& other ) const;

      bool operator!=( const StaticEllpackIndexMultimapValues& other ) const;

      void print( std::ostream& str ) const;

   protected:
      StaticEllpackIndexMultimapValues( IndexType* values );

      IndexType* values;

      friend StaticEllpackIndexMultimap< ValuesCount, IndexType, DeviceType, LocalIndexType, step >;
      friend StaticEllpackIndexMultimap< ValuesCount, typename std::remove_const< IndexType >::type, DeviceType, LocalIndexType, step >;
};

template< int ValuesCount,
          typename Index,
          typename Device,
          typename LocalIndex,
          int step >
std::ostream& operator << ( std::ostream& str, const StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex, step >& ports );
} // namespace Multimaps
} // namespace Containers
} // namespace TNL

#include <TNL/Containers/Multimaps/StaticEllpackIndexMultimapValues.hpp>