Loading src/TNL/Experimental/Multimaps/EllpackIndexMultimap.h +28 −11 Original line number Diff line number Diff line Loading @@ -15,9 +15,22 @@ namespace TNL { template< typename Device > struct EllpackIndexMultimapSliceSizeGetter { static constexpr int SliceSize = 1; }; template<> struct EllpackIndexMultimapSliceSizeGetter< Devices::Cuda > { static constexpr int SliceSize = 32; }; template< typename Index = int, typename Device = Devices::Host, typename LocalIndex = Index > typename LocalIndex = Index, int SliceSize = EllpackIndexMultimapSliceSizeGetter< Device >::SliceSize > class EllpackIndexMultimap : public virtual Object { Loading @@ -25,17 +38,17 @@ class EllpackIndexMultimap using DeviceType = Device; using IndexType = Index; using LocalIndexType = LocalIndex; using ValuesAccessorType = EllpackIndexMultimapValues< IndexType, DeviceType, LocalIndexType >; using ConstValuesAccessorType = EllpackIndexMultimapValues< const IndexType, DeviceType, LocalIndexType >; using ValuesAccessorType = EllpackIndexMultimapValues< IndexType, DeviceType, LocalIndexType, SliceSize >; using ConstValuesAccessorType = EllpackIndexMultimapValues< const IndexType, DeviceType, LocalIndexType, SliceSize >; using ValuesAllocationVectorType = Containers::Vector< LocalIndexType, DeviceType, IndexType >; EllpackIndexMultimap() = default; template< typename Device_ > EllpackIndexMultimap( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other ); EllpackIndexMultimap( const EllpackIndexMultimap< Index, Device_, LocalIndex, SliceSize >& other ); template< typename Device_ > EllpackIndexMultimap& operator=( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other ); EllpackIndexMultimap& operator=( const EllpackIndexMultimap< Index, Device_, LocalIndex, SliceSize >& other ); static String getType(); Loading @@ -50,8 +63,8 @@ class EllpackIndexMultimap bool allocate( const ValuesAllocationVectorType& valuesCounts ); template< typename Device_ > bool setLike( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other ); template< typename Device_, int SliceSize_ > bool setLike( const EllpackIndexMultimap< Index, Device_, LocalIndex, SliceSize_ >& other ); __cuda_callable__ ValuesAccessorType getValues( const IndexType& inputIndex ); Loading @@ -59,7 +72,7 @@ class EllpackIndexMultimap __cuda_callable__ ConstValuesAccessorType getValues( const IndexType& inputIndex ) const; bool operator==( const EllpackIndexMultimap< Index, Device, LocalIndex >& other ) const; bool operator==( const EllpackIndexMultimap& other ) const; bool save( File& file ) const; Loading @@ -78,15 +91,19 @@ class EllpackIndexMultimap IndexType keysRange = 0; LocalIndexType maxValuesCount = 0; __cuda_callable__ IndexType getAllocationKeysRange( IndexType keysRange ) const; // friend class is needed for templated assignment operators template< typename Index_, typename Device_, typename LocalIndex_ > template< typename Index_, typename Device_, typename LocalIndex_, int SliceSize_ > friend class EllpackIndexMultimap; }; template< typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimap< Index, Device, LocalIndex >& multimap ); typename LocalIndex, int SliceSize > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimap< Index, Device, LocalIndex, SliceSize >& multimap ); } // namespace TNL Loading src/TNL/Experimental/Multimaps/EllpackIndexMultimapValues.h +11 −9 Original line number Diff line number Diff line Loading @@ -19,19 +19,21 @@ namespace TNL { template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int SliceSize > class EllpackIndexMultimap; template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step = 1 > class EllpackIndexMultimapValues { public: using DeviceType = Device; using IndexType = Index; using LocalIndexType = LocalIndex; using NetworkType = EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType >; using NetworkType = EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType, step >; __cuda_callable__ EllpackIndexMultimapValues(); Loading Loading @@ -85,8 +87,7 @@ class EllpackIndexMultimapValues __cuda_callable__ EllpackIndexMultimapValues( IndexType* values, ValuesCountType* valuesCounts, const IndexType& input, ValuesCountType* valuesCount, const LocalIndexType& allocatedSize ); IndexType* values; Loading @@ -96,14 +97,15 @@ class EllpackIndexMultimapValues // TODO: this is useless for a const-accessor (without setSize etc.) LocalIndexType allocatedSize; friend EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType >; friend EllpackIndexMultimap< typename std::remove_const< IndexType >::type, DeviceType, LocalIndexType >; friend EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType, step >; friend EllpackIndexMultimap< typename std::remove_const< IndexType >::type, DeviceType, LocalIndexType, step >; }; template< typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex >& ports ); typename LocalIndex, int step > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& ports ); } // namespace TNL Loading src/TNL/Experimental/Multimaps/EllpackIndexMultimapValues_impl.h +68 −54 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ namespace TNL { template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: EllpackIndexMultimapValues() : values( nullptr ), valuesCount( nullptr ), allocatedSize( 0 ) { Loading @@ -28,9 +29,10 @@ EllpackIndexMultimapValues() template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: EllpackIndexMultimapValues( EllpackIndexMultimapValues&& other ) : values( other.values ), valuesCount( other.valuesCount ), allocatedSize( other.allocatedSize ) { Loading @@ -41,10 +43,25 @@ EllpackIndexMultimapValues( EllpackIndexMultimapValues&& other ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: EllpackIndexMultimapValues( IndexType* values, ValuesCountType* valuesCount, const LocalIndexType& allocatedSize ) : values( values ), valuesCount( valuesCount ), allocatedSize( allocatedSize ) { TNL_ASSERT( *(this->valuesCount) <= allocatedSize, ); } template< typename Index, typename Device, typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator=( const EllpackIndexMultimapValues& other ) { TNL_ASSERT( this->getSize() == other.getSize(), ); Loading @@ -57,10 +74,11 @@ operator=( const EllpackIndexMultimapValues& other ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator=( EllpackIndexMultimapValues&& other ) { this->values = other.values; Loading @@ -74,10 +92,11 @@ operator=( EllpackIndexMultimapValues&& other ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ void EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: bind( const EllpackIndexMultimapValues& other ) { this->values = other.values; Loading @@ -87,26 +106,11 @@ bind( const EllpackIndexMultimapValues& other ) template< typename Index, typename Device, typename LocalIndex > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues( IndexType* values, ValuesCountType* valuesCounts, const IndexType& input, const LocalIndexType& allocatedSize ) { this->values = &values[ input * allocatedSize ]; this->valuesCount = &valuesCounts[ input ]; this->allocatedSize = allocatedSize; TNL_ASSERT( *(this->valuesCount) <= allocatedSize, ); } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ bool EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: setSize( const LocalIndexType& size ) { if( ! this->valuesCount || size > this->allocatedSize ) Loading @@ -117,10 +121,11 @@ setSize( const LocalIndexType& size ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ LocalIndex EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: getSize() const { if( ! valuesCount ) Loading @@ -130,10 +135,11 @@ getSize() const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ LocalIndex EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: getAllocatedSize() const { return this->allocatedSize; Loading @@ -141,10 +147,11 @@ getAllocatedSize() const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ void EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: setValue( const LocalIndexType& portIndex, const IndexType& value ) { Loading @@ -152,60 +159,64 @@ setValue( const LocalIndexType& portIndex, std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); this->values[ portIndex ] = value; this->values[ portIndex * step ] = value; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ Index EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: getValue( const LocalIndexType& portIndex ) const { TNL_ASSERT( portIndex < this->getSize(), std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); return this->values[ portIndex ]; return this->values[ portIndex * step ]; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ Index& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator[]( const LocalIndexType& portIndex ) { TNL_ASSERT( portIndex < this->getSize(), std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); return this->values[ portIndex ]; return this->values[ portIndex * step ]; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ const Index& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator[]( const LocalIndexType& portIndex ) const { TNL_ASSERT( portIndex < this->getSize(), std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); return this->values[ portIndex ]; return this->values[ portIndex * step ]; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ bool EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator==( const EllpackIndexMultimapValues& other ) const { if( this->getSize() != other.getSize() ) Loading @@ -218,10 +229,11 @@ operator==( const EllpackIndexMultimapValues& other ) const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ bool EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator!=( const EllpackIndexMultimapValues& other ) const { return ! ( *this == other ); Loading @@ -229,9 +241,10 @@ operator!=( const EllpackIndexMultimapValues& other ) const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > void EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: print( std::ostream& str ) const { str << "[ "; Loading @@ -246,8 +259,9 @@ print( std::ostream& str ) const template< typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex >& ports ) typename LocalIndex, int step > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& ports ) { ports.print( str ); return str; Loading src/TNL/Experimental/Multimaps/EllpackIndexMultimap_impl.h +88 −50 File changed.Preview size limit exceeded, changes collapsed. Show changes src/TNL/Experimental/Multimaps/StaticEllpackIndexMultimap.h +26 −9 Original line number Diff line number Diff line Loading @@ -15,10 +15,23 @@ namespace TNL { template< typename Device > struct StaticEllpackIndexMultimapSliceSizeGetter { static constexpr int SliceSize = 1; }; template<> struct StaticEllpackIndexMultimapSliceSizeGetter< Devices::Cuda > { static constexpr int SliceSize = 32; }; template< int ValuesCount, typename Index = int, typename Device = Devices::Host, typename LocalIndex = Index > typename LocalIndex = Index, int SliceSize = StaticEllpackIndexMultimapSliceSizeGetter< Device >::SliceSize > class StaticEllpackIndexMultimap : public virtual Object { Loading @@ -26,16 +39,16 @@ class StaticEllpackIndexMultimap using DeviceType = Device; using IndexType = Index; using LocalIndexType = LocalIndex; using ValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, IndexType, DeviceType, LocalIndexType >; using ConstValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, const IndexType, DeviceType, LocalIndexType >; using ValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, IndexType, DeviceType, LocalIndexType, SliceSize >; using ConstValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, const IndexType, DeviceType, LocalIndexType, SliceSize >; StaticEllpackIndexMultimap() = default; template< typename Device_ > StaticEllpackIndexMultimap( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other ); StaticEllpackIndexMultimap( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex, SliceSize >& other ); template< typename Device_ > StaticEllpackIndexMultimap& operator=( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other ); StaticEllpackIndexMultimap& operator=( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex, SliceSize >& other ); static String getType(); Loading @@ -49,7 +62,7 @@ class StaticEllpackIndexMultimap bool allocate(); template< typename Device_ > bool setLike( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other ); bool setLike( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex, SliceSize >& other ); __cuda_callable__ ValuesAccessorType getValues( const IndexType& inputIndex ); Loading @@ -74,16 +87,20 @@ class StaticEllpackIndexMultimap IndexType keysRange = 0; __cuda_callable__ IndexType getAllocationKeysRange( IndexType keysRange ) const; // friend class is needed for templated assignment operators template< int ValuesCount_, typename Index_, typename Device_, typename LocalIndex_ > template< int ValuesCount_, typename Index_, typename Device_, typename LocalIndex_, int SliceSize_ > friend class StaticEllpackIndexMultimap; }; template< int ValuesCount, typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >& multimap ); typename LocalIndex, int SliceSize > std::ostream& operator << ( std::ostream& str, const StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex, SliceSize >& multimap ); } // namespace TNL Loading Loading
src/TNL/Experimental/Multimaps/EllpackIndexMultimap.h +28 −11 Original line number Diff line number Diff line Loading @@ -15,9 +15,22 @@ namespace TNL { template< typename Device > struct EllpackIndexMultimapSliceSizeGetter { static constexpr int SliceSize = 1; }; template<> struct EllpackIndexMultimapSliceSizeGetter< Devices::Cuda > { static constexpr int SliceSize = 32; }; template< typename Index = int, typename Device = Devices::Host, typename LocalIndex = Index > typename LocalIndex = Index, int SliceSize = EllpackIndexMultimapSliceSizeGetter< Device >::SliceSize > class EllpackIndexMultimap : public virtual Object { Loading @@ -25,17 +38,17 @@ class EllpackIndexMultimap using DeviceType = Device; using IndexType = Index; using LocalIndexType = LocalIndex; using ValuesAccessorType = EllpackIndexMultimapValues< IndexType, DeviceType, LocalIndexType >; using ConstValuesAccessorType = EllpackIndexMultimapValues< const IndexType, DeviceType, LocalIndexType >; using ValuesAccessorType = EllpackIndexMultimapValues< IndexType, DeviceType, LocalIndexType, SliceSize >; using ConstValuesAccessorType = EllpackIndexMultimapValues< const IndexType, DeviceType, LocalIndexType, SliceSize >; using ValuesAllocationVectorType = Containers::Vector< LocalIndexType, DeviceType, IndexType >; EllpackIndexMultimap() = default; template< typename Device_ > EllpackIndexMultimap( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other ); EllpackIndexMultimap( const EllpackIndexMultimap< Index, Device_, LocalIndex, SliceSize >& other ); template< typename Device_ > EllpackIndexMultimap& operator=( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other ); EllpackIndexMultimap& operator=( const EllpackIndexMultimap< Index, Device_, LocalIndex, SliceSize >& other ); static String getType(); Loading @@ -50,8 +63,8 @@ class EllpackIndexMultimap bool allocate( const ValuesAllocationVectorType& valuesCounts ); template< typename Device_ > bool setLike( const EllpackIndexMultimap< Index, Device_, LocalIndex >& other ); template< typename Device_, int SliceSize_ > bool setLike( const EllpackIndexMultimap< Index, Device_, LocalIndex, SliceSize_ >& other ); __cuda_callable__ ValuesAccessorType getValues( const IndexType& inputIndex ); Loading @@ -59,7 +72,7 @@ class EllpackIndexMultimap __cuda_callable__ ConstValuesAccessorType getValues( const IndexType& inputIndex ) const; bool operator==( const EllpackIndexMultimap< Index, Device, LocalIndex >& other ) const; bool operator==( const EllpackIndexMultimap& other ) const; bool save( File& file ) const; Loading @@ -78,15 +91,19 @@ class EllpackIndexMultimap IndexType keysRange = 0; LocalIndexType maxValuesCount = 0; __cuda_callable__ IndexType getAllocationKeysRange( IndexType keysRange ) const; // friend class is needed for templated assignment operators template< typename Index_, typename Device_, typename LocalIndex_ > template< typename Index_, typename Device_, typename LocalIndex_, int SliceSize_ > friend class EllpackIndexMultimap; }; template< typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimap< Index, Device, LocalIndex >& multimap ); typename LocalIndex, int SliceSize > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimap< Index, Device, LocalIndex, SliceSize >& multimap ); } // namespace TNL Loading
src/TNL/Experimental/Multimaps/EllpackIndexMultimapValues.h +11 −9 Original line number Diff line number Diff line Loading @@ -19,19 +19,21 @@ namespace TNL { template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int SliceSize > class EllpackIndexMultimap; template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step = 1 > class EllpackIndexMultimapValues { public: using DeviceType = Device; using IndexType = Index; using LocalIndexType = LocalIndex; using NetworkType = EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType >; using NetworkType = EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType, step >; __cuda_callable__ EllpackIndexMultimapValues(); Loading Loading @@ -85,8 +87,7 @@ class EllpackIndexMultimapValues __cuda_callable__ EllpackIndexMultimapValues( IndexType* values, ValuesCountType* valuesCounts, const IndexType& input, ValuesCountType* valuesCount, const LocalIndexType& allocatedSize ); IndexType* values; Loading @@ -96,14 +97,15 @@ class EllpackIndexMultimapValues // TODO: this is useless for a const-accessor (without setSize etc.) LocalIndexType allocatedSize; friend EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType >; friend EllpackIndexMultimap< typename std::remove_const< IndexType >::type, DeviceType, LocalIndexType >; friend EllpackIndexMultimap< IndexType, DeviceType, LocalIndexType, step >; friend EllpackIndexMultimap< typename std::remove_const< IndexType >::type, DeviceType, LocalIndexType, step >; }; template< typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex >& ports ); typename LocalIndex, int step > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& ports ); } // namespace TNL Loading
src/TNL/Experimental/Multimaps/EllpackIndexMultimapValues_impl.h +68 −54 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ namespace TNL { template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: EllpackIndexMultimapValues() : values( nullptr ), valuesCount( nullptr ), allocatedSize( 0 ) { Loading @@ -28,9 +29,10 @@ EllpackIndexMultimapValues() template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: EllpackIndexMultimapValues( EllpackIndexMultimapValues&& other ) : values( other.values ), valuesCount( other.valuesCount ), allocatedSize( other.allocatedSize ) { Loading @@ -41,10 +43,25 @@ EllpackIndexMultimapValues( EllpackIndexMultimapValues&& other ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: EllpackIndexMultimapValues( IndexType* values, ValuesCountType* valuesCount, const LocalIndexType& allocatedSize ) : values( values ), valuesCount( valuesCount ), allocatedSize( allocatedSize ) { TNL_ASSERT( *(this->valuesCount) <= allocatedSize, ); } template< typename Index, typename Device, typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator=( const EllpackIndexMultimapValues& other ) { TNL_ASSERT( this->getSize() == other.getSize(), ); Loading @@ -57,10 +74,11 @@ operator=( const EllpackIndexMultimapValues& other ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator=( EllpackIndexMultimapValues&& other ) { this->values = other.values; Loading @@ -74,10 +92,11 @@ operator=( EllpackIndexMultimapValues&& other ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ void EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: bind( const EllpackIndexMultimapValues& other ) { this->values = other.values; Loading @@ -87,26 +106,11 @@ bind( const EllpackIndexMultimapValues& other ) template< typename Index, typename Device, typename LocalIndex > __cuda_callable__ EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues( IndexType* values, ValuesCountType* valuesCounts, const IndexType& input, const LocalIndexType& allocatedSize ) { this->values = &values[ input * allocatedSize ]; this->valuesCount = &valuesCounts[ input ]; this->allocatedSize = allocatedSize; TNL_ASSERT( *(this->valuesCount) <= allocatedSize, ); } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ bool EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: setSize( const LocalIndexType& size ) { if( ! this->valuesCount || size > this->allocatedSize ) Loading @@ -117,10 +121,11 @@ setSize( const LocalIndexType& size ) template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ LocalIndex EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: getSize() const { if( ! valuesCount ) Loading @@ -130,10 +135,11 @@ getSize() const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ LocalIndex EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: getAllocatedSize() const { return this->allocatedSize; Loading @@ -141,10 +147,11 @@ getAllocatedSize() const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ void EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: setValue( const LocalIndexType& portIndex, const IndexType& value ) { Loading @@ -152,60 +159,64 @@ setValue( const LocalIndexType& portIndex, std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); this->values[ portIndex ] = value; this->values[ portIndex * step ] = value; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ Index EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: getValue( const LocalIndexType& portIndex ) const { TNL_ASSERT( portIndex < this->getSize(), std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); return this->values[ portIndex ]; return this->values[ portIndex * step ]; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ Index& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator[]( const LocalIndexType& portIndex ) { TNL_ASSERT( portIndex < this->getSize(), std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); return this->values[ portIndex ]; return this->values[ portIndex * step ]; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ const Index& EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator[]( const LocalIndexType& portIndex ) const { TNL_ASSERT( portIndex < this->getSize(), std::cerr << " portIndex = " << portIndex << " getSize() = " << this->getSize() << std::endl ); return this->values[ portIndex ]; return this->values[ portIndex * step ]; } template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ bool EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator==( const EllpackIndexMultimapValues& other ) const { if( this->getSize() != other.getSize() ) Loading @@ -218,10 +229,11 @@ operator==( const EllpackIndexMultimapValues& other ) const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > __cuda_callable__ bool EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: operator!=( const EllpackIndexMultimapValues& other ) const { return ! ( *this == other ); Loading @@ -229,9 +241,10 @@ operator!=( const EllpackIndexMultimapValues& other ) const template< typename Index, typename Device, typename LocalIndex > typename LocalIndex, int step > void EllpackIndexMultimapValues< Index, Device, LocalIndex >:: EllpackIndexMultimapValues< Index, Device, LocalIndex, step >:: print( std::ostream& str ) const { str << "[ "; Loading @@ -246,8 +259,9 @@ print( std::ostream& str ) const template< typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex >& ports ) typename LocalIndex, int step > std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex, step >& ports ) { ports.print( str ); return str; Loading
src/TNL/Experimental/Multimaps/EllpackIndexMultimap_impl.h +88 −50 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/TNL/Experimental/Multimaps/StaticEllpackIndexMultimap.h +26 −9 Original line number Diff line number Diff line Loading @@ -15,10 +15,23 @@ namespace TNL { template< typename Device > struct StaticEllpackIndexMultimapSliceSizeGetter { static constexpr int SliceSize = 1; }; template<> struct StaticEllpackIndexMultimapSliceSizeGetter< Devices::Cuda > { static constexpr int SliceSize = 32; }; template< int ValuesCount, typename Index = int, typename Device = Devices::Host, typename LocalIndex = Index > typename LocalIndex = Index, int SliceSize = StaticEllpackIndexMultimapSliceSizeGetter< Device >::SliceSize > class StaticEllpackIndexMultimap : public virtual Object { Loading @@ -26,16 +39,16 @@ class StaticEllpackIndexMultimap using DeviceType = Device; using IndexType = Index; using LocalIndexType = LocalIndex; using ValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, IndexType, DeviceType, LocalIndexType >; using ConstValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, const IndexType, DeviceType, LocalIndexType >; using ValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, IndexType, DeviceType, LocalIndexType, SliceSize >; using ConstValuesAccessorType = StaticEllpackIndexMultimapValues< ValuesCount, const IndexType, DeviceType, LocalIndexType, SliceSize >; StaticEllpackIndexMultimap() = default; template< typename Device_ > StaticEllpackIndexMultimap( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other ); StaticEllpackIndexMultimap( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex, SliceSize >& other ); template< typename Device_ > StaticEllpackIndexMultimap& operator=( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other ); StaticEllpackIndexMultimap& operator=( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex, SliceSize >& other ); static String getType(); Loading @@ -49,7 +62,7 @@ class StaticEllpackIndexMultimap bool allocate(); template< typename Device_ > bool setLike( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex >& other ); bool setLike( const StaticEllpackIndexMultimap< ValuesCount, Index, Device_, LocalIndex, SliceSize >& other ); __cuda_callable__ ValuesAccessorType getValues( const IndexType& inputIndex ); Loading @@ -74,16 +87,20 @@ class StaticEllpackIndexMultimap IndexType keysRange = 0; __cuda_callable__ IndexType getAllocationKeysRange( IndexType keysRange ) const; // friend class is needed for templated assignment operators template< int ValuesCount_, typename Index_, typename Device_, typename LocalIndex_ > template< int ValuesCount_, typename Index_, typename Device_, typename LocalIndex_, int SliceSize_ > friend class StaticEllpackIndexMultimap; }; template< int ValuesCount, typename Index, typename Device, typename LocalIndex > std::ostream& operator << ( std::ostream& str, const StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >& multimap ); typename LocalIndex, int SliceSize > std::ostream& operator << ( std::ostream& str, const StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex, SliceSize >& multimap ); } // namespace TNL Loading