Skip to content
Snippets Groups Projects
EllpackIndexMultimapValues.h 3.9 KiB
Newer Older
/***************************************************************************
                          EllpackIndexMultimapValues.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 <TNL/Devices/Cuda.h>

namespace TNL {
namespace Containers {
namespace Multimaps {
template< typename Index,
          typename LocalIndex,
          int SliceSize >
class EllpackIndexMultimap;

template< typename Index,
          typename Device,
          typename LocalIndex,
          int step = 1 >
class EllpackIndexMultimapValues
      using DeviceType     = Device;
      using IndexType      = Index;
      using LocalIndexType = LocalIndex;
      using NetworkType    = EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType, step >;
      EllpackIndexMultimapValues();
      EllpackIndexMultimapValues( EllpackIndexMultimapValues&& other );
      EllpackIndexMultimapValues& operator=( const EllpackIndexMultimapValues& );
      // converting assignment, needed for 'const int' -> 'int' etc.
      template< typename Index_, typename LocalIndex_, int step_ >
      __cuda_callable__
      EllpackIndexMultimapValues& operator=( const EllpackIndexMultimapValues< Index_, Device, LocalIndex_, step_ >& other );

      EllpackIndexMultimapValues& operator=( EllpackIndexMultimapValues&& other );
      void bind( const EllpackIndexMultimapValues& other );
      void setSize( const LocalIndexType& portsCount );
      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 EllpackIndexMultimapValues& other ) const;
      bool operator!=( const EllpackIndexMultimapValues& other ) const;
      void print( std::ostream& str ) const;
   protected:
      using ValuesCountType = typename std::conditional< std::is_const< IndexType >::value,
                                                         std::add_const_t< LocalIndexType >,
      EllpackIndexMultimapValues( IndexType* values,
                                  ValuesCountType* valuesCount,
                                  const LocalIndexType& allocatedSize );
      // TODO: this is useless for a const-accessor (without setSize etc.)
      friend EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType, step >;
      friend EllpackIndexMultimap< typename std::remove_const< IndexType >::type, DeviceType, LocalIndexType, step >;
          typename LocalIndex,
          int step >
std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& ports );
} // namespace Multimaps
} // namespace Containers
} // namespace TNL
#include <TNL/Containers/Multimaps/EllpackIndexMultimapValues.hpp>