Loading src/TNL/Containers/DistributedArray.h +6 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,12 @@ public: void forElements( IndexType begin, IndexType end, Function&& f ) const; void loadFromGlobalFile( const String& fileName, bool allowCasting = false ); void loadFromGlobalFile( File& file, bool allowCasting = false ); protected: ViewType view; LocalArrayType localData; Loading src/TNL/Containers/DistributedArray.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -316,5 +316,19 @@ DistributedArray< Value, Device, Index, Allocator >::forElements( IndexType begi view.forElements( begin, end, f ); } template< typename Value, typename Device, typename Index, typename Allocator > void DistributedArray< Value, Device, Index, Allocator >::loadFromGlobalFile( const String& fileName, bool allowCasting ) { view.loadFromGlobalFile( fileName, allowCasting ); } template< typename Value, typename Device, typename Index, typename Allocator > void DistributedArray< Value, Device, Index, Allocator >::loadFromGlobalFile( File& file, bool allowCasting ) { view.loadFromGlobalFile( file, allowCasting ); } } // namespace Containers } // namespace TNL src/TNL/Containers/DistributedArrayView.h +6 −0 Original line number Diff line number Diff line Loading @@ -253,6 +253,12 @@ public: void forElements( IndexType begin, IndexType end, Function&& f ) const; void loadFromGlobalFile( const String& fileName, bool allowCasting = false ); void loadFromGlobalFile( File& file, bool allowCasting = false ); protected: LocalRangeType localRange; IndexType ghosts = 0; Loading src/TNL/Containers/DistributedArrayView.hpp +30 −0 Original line number Diff line number Diff line Loading @@ -377,5 +377,35 @@ DistributedArrayView< Value, Device, Index >::forElements( IndexType begin, Inde localData.forElements( localBegin, localEnd, local_f ); } template< typename Value, typename Device, typename Index > void DistributedArrayView< Value, Device, Index >::loadFromGlobalFile( const String& fileName, bool allowCasting ) { File file( fileName, std::ios_base::in ); loadFromGlobalFile( file, allowCasting ); } template< typename Value, typename Device, typename Index > void DistributedArrayView< Value, Device, Index >::loadFromGlobalFile( File& file, bool allowCasting ) { using IO = detail::ArrayIO< Value, Index, typename Allocators::Default< Device >::template Allocator< Value > >; const std::string type = getObjectType( file ); const auto parsedType = parseObjectType( type ); if( ! allowCasting && type != IO::getSerializationType() ) throw Exceptions::FileDeserializationError( file.getFileName(), "object type does not match (expected " + IO::getSerializationType() + ", found " + type + ")." ); std::size_t elementsInFile; file.load( &elementsInFile ); if( allowCasting ) IO::loadSubrange( file, elementsInFile, localRange.getBegin(), localData.getData(), localData.getSize(), parsedType[ 1 ] ); else IO::loadSubrange( file, elementsInFile, localRange.getBegin(), localData.getData(), localData.getSize() ); } } // namespace Containers } // namespace TNL Loading
src/TNL/Containers/DistributedArray.h +6 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,12 @@ public: void forElements( IndexType begin, IndexType end, Function&& f ) const; void loadFromGlobalFile( const String& fileName, bool allowCasting = false ); void loadFromGlobalFile( File& file, bool allowCasting = false ); protected: ViewType view; LocalArrayType localData; Loading
src/TNL/Containers/DistributedArray.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -316,5 +316,19 @@ DistributedArray< Value, Device, Index, Allocator >::forElements( IndexType begi view.forElements( begin, end, f ); } template< typename Value, typename Device, typename Index, typename Allocator > void DistributedArray< Value, Device, Index, Allocator >::loadFromGlobalFile( const String& fileName, bool allowCasting ) { view.loadFromGlobalFile( fileName, allowCasting ); } template< typename Value, typename Device, typename Index, typename Allocator > void DistributedArray< Value, Device, Index, Allocator >::loadFromGlobalFile( File& file, bool allowCasting ) { view.loadFromGlobalFile( file, allowCasting ); } } // namespace Containers } // namespace TNL
src/TNL/Containers/DistributedArrayView.h +6 −0 Original line number Diff line number Diff line Loading @@ -253,6 +253,12 @@ public: void forElements( IndexType begin, IndexType end, Function&& f ) const; void loadFromGlobalFile( const String& fileName, bool allowCasting = false ); void loadFromGlobalFile( File& file, bool allowCasting = false ); protected: LocalRangeType localRange; IndexType ghosts = 0; Loading
src/TNL/Containers/DistributedArrayView.hpp +30 −0 Original line number Diff line number Diff line Loading @@ -377,5 +377,35 @@ DistributedArrayView< Value, Device, Index >::forElements( IndexType begin, Inde localData.forElements( localBegin, localEnd, local_f ); } template< typename Value, typename Device, typename Index > void DistributedArrayView< Value, Device, Index >::loadFromGlobalFile( const String& fileName, bool allowCasting ) { File file( fileName, std::ios_base::in ); loadFromGlobalFile( file, allowCasting ); } template< typename Value, typename Device, typename Index > void DistributedArrayView< Value, Device, Index >::loadFromGlobalFile( File& file, bool allowCasting ) { using IO = detail::ArrayIO< Value, Index, typename Allocators::Default< Device >::template Allocator< Value > >; const std::string type = getObjectType( file ); const auto parsedType = parseObjectType( type ); if( ! allowCasting && type != IO::getSerializationType() ) throw Exceptions::FileDeserializationError( file.getFileName(), "object type does not match (expected " + IO::getSerializationType() + ", found " + type + ")." ); std::size_t elementsInFile; file.load( &elementsInFile ); if( allowCasting ) IO::loadSubrange( file, elementsInFile, localRange.getBegin(), localData.getData(), localData.getSize(), parsedType[ 1 ] ); else IO::loadSubrange( file, elementsInFile, localRange.getBegin(), localData.getData(), localData.getSize() ); } } // namespace Containers } // namespace TNL