Loading src/TNL/Containers/DistributedArrayView.h +19 −21 Original line number Diff line number Diff line Loading @@ -79,27 +79,6 @@ public: template< typename Value_ > void bind( Value_* data, IndexType localSize ); /** * \brief Returns a modifiable view of the array view. */ ViewType getView(); /** * \brief Returns a non-modifiable view of the array view. */ ConstViewType getConstView() const; // Copy-assignment does deep copy, just like regular array, but the sizes // must match (i.e. copy-assignment cannot resize). DistributedArrayView& operator=( const DistributedArrayView& view ); template< typename Array, typename..., typename = std::enable_if_t< HasSubscriptOperator<Array>::value > > DistributedArrayView& operator=( const Array& array ); const LocalRangeType& getLocalRange() const; CommunicationGroup getCommunicationGroup() const; Loading @@ -115,6 +94,16 @@ public: * Usual ArrayView methods follow below. */ /** * \brief Returns a modifiable view of the array view. */ ViewType getView(); /** * \brief Returns a non-modifiable view of the array view. */ ConstViewType getConstView() const; // Resets the array view to the empty state. void reset(); Loading Loading @@ -143,6 +132,15 @@ public: __cuda_callable__ const ValueType& operator[]( IndexType i ) const; // Copy-assignment does deep copy, just like regular array, but the sizes // must match (i.e. copy-assignment cannot resize). DistributedArrayView& operator=( const DistributedArrayView& view ); template< typename Array, typename..., typename = std::enable_if_t< HasSubscriptOperator<Array>::value > > DistributedArrayView& operator=( const Array& array ); // Comparison operators template< typename Array > bool operator==( const Array& array ) const; Loading src/TNL/Containers/DistributedArrayView.hpp +53 −55 Original line number Diff line number Diff line Loading @@ -75,61 +75,6 @@ bind( Value_* data, IndexType localSize ) localData.bind( data, localSize ); } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ViewType DistributedArrayView< Value, Device, Index, Communicator >:: getView() { return *this; } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ConstViewType DistributedArrayView< Value, Device, Index, Communicator >:: getConstView() const { return *this; } template< typename Value, typename Device, typename Index, typename Communicator > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const DistributedArrayView& view ) { TNL_ASSERT_EQ( getSize(), view.getSize(), "The sizes of the array views must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), view.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), view.getCommunicationGroup(), "The communication groups of the array views must be equal." ); localData = view.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, typename Communicator > template< typename Array, typename..., typename > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const Array& array ) { TNL_ASSERT_EQ( getSize(), array.getSize(), "The global sizes must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), array.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), array.getCommunicationGroup(), "The communication groups must be equal." ); localData = array.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, Loading Loading @@ -197,6 +142,28 @@ copyFromGlobal( ConstLocalViewType globalArray ) } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ViewType DistributedArrayView< Value, Device, Index, Communicator >:: getView() { return *this; } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ConstViewType DistributedArrayView< Value, Device, Index, Communicator >:: getConstView() const { return *this; } template< typename Value, typename Device, typename Index, Loading Loading @@ -296,6 +263,37 @@ operator[]( IndexType i ) const return localData[ li ]; } template< typename Value, typename Device, typename Index, typename Communicator > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const DistributedArrayView& view ) { TNL_ASSERT_EQ( getSize(), view.getSize(), "The sizes of the array views must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), view.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), view.getCommunicationGroup(), "The communication groups of the array views must be equal." ); localData = view.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, typename Communicator > template< typename Array, typename..., typename > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const Array& array ) { TNL_ASSERT_EQ( getSize(), array.getSize(), "The global sizes must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), array.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), array.getCommunicationGroup(), "The communication groups must be equal." ); localData = array.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, Loading Loading
src/TNL/Containers/DistributedArrayView.h +19 −21 Original line number Diff line number Diff line Loading @@ -79,27 +79,6 @@ public: template< typename Value_ > void bind( Value_* data, IndexType localSize ); /** * \brief Returns a modifiable view of the array view. */ ViewType getView(); /** * \brief Returns a non-modifiable view of the array view. */ ConstViewType getConstView() const; // Copy-assignment does deep copy, just like regular array, but the sizes // must match (i.e. copy-assignment cannot resize). DistributedArrayView& operator=( const DistributedArrayView& view ); template< typename Array, typename..., typename = std::enable_if_t< HasSubscriptOperator<Array>::value > > DistributedArrayView& operator=( const Array& array ); const LocalRangeType& getLocalRange() const; CommunicationGroup getCommunicationGroup() const; Loading @@ -115,6 +94,16 @@ public: * Usual ArrayView methods follow below. */ /** * \brief Returns a modifiable view of the array view. */ ViewType getView(); /** * \brief Returns a non-modifiable view of the array view. */ ConstViewType getConstView() const; // Resets the array view to the empty state. void reset(); Loading Loading @@ -143,6 +132,15 @@ public: __cuda_callable__ const ValueType& operator[]( IndexType i ) const; // Copy-assignment does deep copy, just like regular array, but the sizes // must match (i.e. copy-assignment cannot resize). DistributedArrayView& operator=( const DistributedArrayView& view ); template< typename Array, typename..., typename = std::enable_if_t< HasSubscriptOperator<Array>::value > > DistributedArrayView& operator=( const Array& array ); // Comparison operators template< typename Array > bool operator==( const Array& array ) const; Loading
src/TNL/Containers/DistributedArrayView.hpp +53 −55 Original line number Diff line number Diff line Loading @@ -75,61 +75,6 @@ bind( Value_* data, IndexType localSize ) localData.bind( data, localSize ); } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ViewType DistributedArrayView< Value, Device, Index, Communicator >:: getView() { return *this; } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ConstViewType DistributedArrayView< Value, Device, Index, Communicator >:: getConstView() const { return *this; } template< typename Value, typename Device, typename Index, typename Communicator > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const DistributedArrayView& view ) { TNL_ASSERT_EQ( getSize(), view.getSize(), "The sizes of the array views must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), view.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), view.getCommunicationGroup(), "The communication groups of the array views must be equal." ); localData = view.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, typename Communicator > template< typename Array, typename..., typename > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const Array& array ) { TNL_ASSERT_EQ( getSize(), array.getSize(), "The global sizes must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), array.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), array.getCommunicationGroup(), "The communication groups must be equal." ); localData = array.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, Loading Loading @@ -197,6 +142,28 @@ copyFromGlobal( ConstLocalViewType globalArray ) } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ViewType DistributedArrayView< Value, Device, Index, Communicator >:: getView() { return *this; } template< typename Value, typename Device, typename Index, typename Communicator > typename DistributedArrayView< Value, Device, Index, Communicator >::ConstViewType DistributedArrayView< Value, Device, Index, Communicator >:: getConstView() const { return *this; } template< typename Value, typename Device, typename Index, Loading Loading @@ -296,6 +263,37 @@ operator[]( IndexType i ) const return localData[ li ]; } template< typename Value, typename Device, typename Index, typename Communicator > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const DistributedArrayView& view ) { TNL_ASSERT_EQ( getSize(), view.getSize(), "The sizes of the array views must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), view.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), view.getCommunicationGroup(), "The communication groups of the array views must be equal." ); localData = view.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, typename Communicator > template< typename Array, typename..., typename > DistributedArrayView< Value, Device, Index, Communicator >& DistributedArrayView< Value, Device, Index, Communicator >:: operator=( const Array& array ) { TNL_ASSERT_EQ( getSize(), array.getSize(), "The global sizes must be equal, views are not resizable." ); TNL_ASSERT_EQ( getLocalRange(), array.getLocalRange(), "The local ranges must be equal, views are not resizable." ); TNL_ASSERT_EQ( getCommunicationGroup(), array.getCommunicationGroup(), "The communication groups must be equal." ); localData = array.getConstLocalView(); return *this; } template< typename Value, typename Device, typename Index, Loading