Loading src/TNL/Containers/DistributedNDArray.h +24 −8 Original line number Diff line number Diff line Loading @@ -258,13 +258,13 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalInternal( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds ); __ndarray_impl::ExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, ends, f ); Loading @@ -274,18 +274,34 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalBoundary( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType skipBegins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType skipEnds; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( localBegins, skipBegins, skipEnds, localEnds, f ); } // iterate over elements of overlaps (if all overlaps are 0, it has no effect) template< typename Device2 = DeviceType, typename Func > void forOverlaps( Func f ) const { // subtract overlaps from dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesSubtractOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::subtract( begins, localBegins ); // add overlaps to dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesAddOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::add( ends, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, localBegins, localEnds, ends, f ); } // extra methods Loading src/TNL/Containers/DistributedNDArrayView.h +24 −8 Original line number Diff line number Diff line Loading @@ -287,13 +287,13 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalInternal( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds ); __ndarray_impl::ExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, ends, f ); Loading @@ -303,18 +303,34 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalBoundary( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType skipBegins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType skipEnds; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( localBegins, skipBegins, skipEnds, localEnds, f ); } // iterate over elements of overlaps (if all overlaps are 0, it has no effect) template< typename Device2 = DeviceType, typename Func > void forOverlaps( Func f ) const { // subtract overlaps from dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesSubtractOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::subtract( begins, localBegins ); // add overlaps to dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesAddOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::add( ends, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, localBegins, localEnds, ends, f ); } protected: NDArrayView localView; CommunicationGroup group = Communicator::NullGroup; Loading src/TNL/Containers/ndarray/SizesHolder.h +1 −2 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public: void setSize( LevelTag, Index newSize ) { TNL_ASSERT( newSize == 0, ); TNL_ASSERT_EQ( newSize, 0, "Dynamic size for a static dimension must be 0." ); } __cuda_callable__ Loading @@ -60,7 +60,6 @@ public: void setSize( LevelTag, Index size ) { TNL_ASSERT( size >= 0, ); this->size = size; } Loading src/TNL/Containers/ndarray/SizesHolderHelpers.h +77 −37 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ void assertIndicesInBounds( const SizesHolder& sizes, Index&& i, IndexTypes&&... // shouldn't be declared when compiling without assertions constexpr std::size_t level = SizesHolder::getDimension() - sizeof...(indices) - 1; const auto size = sizes.template getSize< level >(); TNL_ASSERT_LT( i, size, "Input error - some index is out of bounds." ); TNL_ASSERT_LT( i, (Index) size, "Input error - some index is out of bounds." ); #endif assertIndicesInBounds( sizes, std::forward< IndexTypes >( indices )... ); } Loading Loading @@ -156,14 +156,14 @@ void assertIndicesInRange( const SizesHolder1& begins, const SizesHolder2& ends, constexpr std::size_t level = SizesHolder1::getDimension() - sizeof...(indices) - 1; const auto begin = begins.template getSize< level >(); const auto end = ends.template getSize< level >(); TNL_ASSERT_LE( begin - get<level>( overlaps ), i, "Input error - some index is below the lower bound." ); TNL_ASSERT_LT( i, end + get<level>( overlaps ), "Input error - some index is above the upper bound." ); TNL_ASSERT_LE( begin - (decltype(begin)) get<level>( overlaps ), i, "Input error - some index is below the lower bound." ); TNL_ASSERT_LT( i, end + (decltype(end)) get<level>( overlaps ), "Input error - some index is above the upper bound." ); #endif assertIndicesInRange( begins, ends, overlaps, std::forward< IndexTypes >( indices )... ); } // helper for the forInternal method // helper for the forInternal and forBoundary methods (NDArray and DistributedNDArray) template< std::size_t ConstValue, typename TargetHolder, typename SourceHolder, Loading @@ -172,15 +172,10 @@ template< std::size_t ConstValue, struct SetSizesSubtractHelper { static void subtract( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() - ConstValue * ! get< level >( Overlaps{} ) ); else target.template setSize< level >( source.template getSize< level >() - ConstValue * !! get< level >( Overlaps{} ) ); } SetSizesSubtractHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, level - 1 >::subtract( target, source ); } }; Loading @@ -192,20 +187,15 @@ template< std::size_t ConstValue, struct SetSizesSubtractHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, 0 > { static void subtract( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() - ConstValue * ! get< 0 >( Overlaps{} ) ); else target.template setSize< 0 >( source.template getSize< 0 >() - ConstValue * !! get< 0 >( Overlaps{} ) ); } } }; // helper for the forInternal method (DistributedNDArray) // helper for the forInternal and forBoundary methods (DistributedNDArray) template< std::size_t ConstValue, typename TargetHolder, typename SourceHolder, Loading @@ -214,15 +204,10 @@ template< std::size_t ConstValue, struct SetSizesAddHelper { static void add( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() + ConstValue * ! get< level >( Overlaps{} ) ); else target.template setSize< level >( source.template getSize< level >() + ConstValue * !! get< level >( Overlaps{} ) ); } SetSizesAddHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, level - 1 >::add( target, source ); } }; Loading @@ -234,15 +219,70 @@ template< std::size_t ConstValue, struct SetSizesAddHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, 0 > { static void add( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() + ConstValue * ! get< 0 >( Overlaps{} ) ); else target.template setSize< 0 >( source.template getSize< 0 >() + ConstValue * !! get< 0 >( Overlaps{} ) ); } }; // helper for the forLocalInternal, forLocalBoundary and forOverlaps methods (DistributedNDArray) template< typename TargetHolder, typename SourceHolder, typename Overlaps = make_constant_index_sequence< TargetHolder::getDimension(), 0 >, std::size_t level = TargetHolder::getDimension() - 1 > struct SetSizesSubtractOverlapsHelper { static void subtract( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() - get< level >( Overlaps{} ) ); SetSizesSubtractOverlapsHelper< TargetHolder, SourceHolder, Overlaps, level - 1 >::subtract( target, source ); } }; template< typename TargetHolder, typename SourceHolder, typename Overlaps > struct SetSizesSubtractOverlapsHelper< TargetHolder, SourceHolder, Overlaps, 0 > { static void subtract( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() - get< 0 >( Overlaps{} ) ); } }; // helper for the forLocalInternal, forLocalBoundary and forOverlaps methods (DistributedNDArray) template< typename TargetHolder, typename SourceHolder, typename Overlaps = make_constant_index_sequence< TargetHolder::getDimension(), 0 >, std::size_t level = TargetHolder::getDimension() - 1 > struct SetSizesAddOverlapsHelper { static void add( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() + get< level >( Overlaps{} ) ); SetSizesAddOverlapsHelper< TargetHolder, SourceHolder, Overlaps, level - 1 >::add( target, source ); } }; template< typename TargetHolder, typename SourceHolder, typename Overlaps > struct SetSizesAddOverlapsHelper< TargetHolder, SourceHolder, Overlaps, 0 > { static void add( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() + get< 0 >( Overlaps{} ) ); } }; Loading src/UnitTests/Containers/ndarray/CMakeLists.txt +11 −0 Original line number Diff line number Diff line Loading @@ -30,12 +30,23 @@ if( ${BUILD_MPI} ) CUDA_ADD_EXECUTABLE( DistributedNDArrayTest DistributedNDArrayTest.cu OPTIONS ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayTest ${GTEST_BOTH_LIBRARIES} ) CUDA_ADD_EXECUTABLE( DistributedNDArrayOverlapsTest DistributedNDArrayOverlapsTest.cu OPTIONS ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayOverlapsTest ${GTEST_BOTH_LIBRARIES} ) else() ADD_EXECUTABLE( DistributedNDArrayTest DistributedNDArrayTest.cpp ) TARGET_COMPILE_OPTIONS( DistributedNDArrayTest PRIVATE ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayTest ${GTEST_BOTH_LIBRARIES} ) ADD_EXECUTABLE( DistributedNDArrayOverlapsTest DistributedNDArrayOverlapsTest.cpp ) TARGET_COMPILE_OPTIONS( DistributedNDArrayOverlapsTest PRIVATE ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayOverlapsTest ${GTEST_BOTH_LIBRARIES} ) endif() SET( mpi_test_parameters -np 4 -H localhost:4 "${EXECUTABLE_OUTPUT_PATH}/DistributedNDArrayTest${CMAKE_EXECUTABLE_SUFFIX}" ) ADD_TEST( NAME DistributedNDArrayTest COMMAND "mpirun" ${mpi_test_parameters}) SET( mpi_test_parameters -np 4 -H localhost:4 "${EXECUTABLE_OUTPUT_PATH}/DistributedNDArrayOverlapsTest${CMAKE_EXECUTABLE_SUFFIX}" ) ADD_TEST( NAME DistributedNDArrayOverlapsTest COMMAND "mpirun" ${mpi_test_parameters}) endif() Loading
src/TNL/Containers/DistributedNDArray.h +24 −8 Original line number Diff line number Diff line Loading @@ -258,13 +258,13 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalInternal( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds ); __ndarray_impl::ExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, ends, f ); Loading @@ -274,18 +274,34 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalBoundary( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType skipBegins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType skipEnds; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( localBegins, skipBegins, skipEnds, localEnds, f ); } // iterate over elements of overlaps (if all overlaps are 0, it has no effect) template< typename Device2 = DeviceType, typename Func > void forOverlaps( Func f ) const { // subtract overlaps from dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesSubtractOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::subtract( begins, localBegins ); // add overlaps to dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesAddOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::add( ends, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, localBegins, localEnds, ends, f ); } // extra methods Loading
src/TNL/Containers/DistributedNDArrayView.h +24 −8 Original line number Diff line number Diff line Loading @@ -287,13 +287,13 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalInternal( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( begins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( ends, localEnds ); __ndarray_impl::ExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, ends, f ); Loading @@ -303,18 +303,34 @@ public: template< typename Device2 = DeviceType, typename Func > void forLocalBoundary( Func f ) const { // add dynamic sizes // add overlaps to dynamic sizes LocalBeginsType skipBegins; __ndarray_impl::SetSizesAddHelper< 1, LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins, false ); __ndarray_impl::SetSizesAddOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::add( skipBegins, localBegins ); // subtract dynamic sizes // subtract overlaps from dynamic sizes SizesHolderType skipEnds; __ndarray_impl::SetSizesSubtractHelper< 1, SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds, false ); __ndarray_impl::SetSizesSubtractOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::subtract( skipEnds, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( localBegins, skipBegins, skipEnds, localEnds, f ); } // iterate over elements of overlaps (if all overlaps are 0, it has no effect) template< typename Device2 = DeviceType, typename Func > void forOverlaps( Func f ) const { // subtract overlaps from dynamic sizes LocalBeginsType begins; __ndarray_impl::SetSizesSubtractOverlapsHelper< LocalBeginsType, SizesHolderType, Overlaps >::subtract( begins, localBegins ); // add overlaps to dynamic sizes SizesHolderType ends; __ndarray_impl::SetSizesAddOverlapsHelper< SizesHolderType, SizesHolderType, Overlaps >::add( ends, localEnds ); __ndarray_impl::BoundaryExecutorDispatcher< PermutationType, Device2 > dispatch; dispatch( begins, localBegins, localEnds, ends, f ); } protected: NDArrayView localView; CommunicationGroup group = Communicator::NullGroup; Loading
src/TNL/Containers/ndarray/SizesHolder.h +1 −2 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public: void setSize( LevelTag, Index newSize ) { TNL_ASSERT( newSize == 0, ); TNL_ASSERT_EQ( newSize, 0, "Dynamic size for a static dimension must be 0." ); } __cuda_callable__ Loading @@ -60,7 +60,6 @@ public: void setSize( LevelTag, Index size ) { TNL_ASSERT( size >= 0, ); this->size = size; } Loading
src/TNL/Containers/ndarray/SizesHolderHelpers.h +77 −37 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ void assertIndicesInBounds( const SizesHolder& sizes, Index&& i, IndexTypes&&... // shouldn't be declared when compiling without assertions constexpr std::size_t level = SizesHolder::getDimension() - sizeof...(indices) - 1; const auto size = sizes.template getSize< level >(); TNL_ASSERT_LT( i, size, "Input error - some index is out of bounds." ); TNL_ASSERT_LT( i, (Index) size, "Input error - some index is out of bounds." ); #endif assertIndicesInBounds( sizes, std::forward< IndexTypes >( indices )... ); } Loading Loading @@ -156,14 +156,14 @@ void assertIndicesInRange( const SizesHolder1& begins, const SizesHolder2& ends, constexpr std::size_t level = SizesHolder1::getDimension() - sizeof...(indices) - 1; const auto begin = begins.template getSize< level >(); const auto end = ends.template getSize< level >(); TNL_ASSERT_LE( begin - get<level>( overlaps ), i, "Input error - some index is below the lower bound." ); TNL_ASSERT_LT( i, end + get<level>( overlaps ), "Input error - some index is above the upper bound." ); TNL_ASSERT_LE( begin - (decltype(begin)) get<level>( overlaps ), i, "Input error - some index is below the lower bound." ); TNL_ASSERT_LT( i, end + (decltype(end)) get<level>( overlaps ), "Input error - some index is above the upper bound." ); #endif assertIndicesInRange( begins, ends, overlaps, std::forward< IndexTypes >( indices )... ); } // helper for the forInternal method // helper for the forInternal and forBoundary methods (NDArray and DistributedNDArray) template< std::size_t ConstValue, typename TargetHolder, typename SourceHolder, Loading @@ -172,15 +172,10 @@ template< std::size_t ConstValue, struct SetSizesSubtractHelper { static void subtract( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() - ConstValue * ! get< level >( Overlaps{} ) ); else target.template setSize< level >( source.template getSize< level >() - ConstValue * !! get< level >( Overlaps{} ) ); } SetSizesSubtractHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, level - 1 >::subtract( target, source ); } }; Loading @@ -192,20 +187,15 @@ template< std::size_t ConstValue, struct SetSizesSubtractHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, 0 > { static void subtract( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() - ConstValue * ! get< 0 >( Overlaps{} ) ); else target.template setSize< 0 >( source.template getSize< 0 >() - ConstValue * !! get< 0 >( Overlaps{} ) ); } } }; // helper for the forInternal method (DistributedNDArray) // helper for the forInternal and forBoundary methods (DistributedNDArray) template< std::size_t ConstValue, typename TargetHolder, typename SourceHolder, Loading @@ -214,15 +204,10 @@ template< std::size_t ConstValue, struct SetSizesAddHelper { static void add( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() + ConstValue * ! get< level >( Overlaps{} ) ); else target.template setSize< level >( source.template getSize< level >() + ConstValue * !! get< level >( Overlaps{} ) ); } SetSizesAddHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, level - 1 >::add( target, source ); } }; Loading @@ -234,15 +219,70 @@ template< std::size_t ConstValue, struct SetSizesAddHelper< ConstValue, TargetHolder, SourceHolder, Overlaps, 0 > { static void add( TargetHolder& target, const SourceHolder& source, bool negateOverlaps = true ) const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) { if( negateOverlaps ) if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() + ConstValue * ! get< 0 >( Overlaps{} ) ); else target.template setSize< 0 >( source.template getSize< 0 >() + ConstValue * !! get< 0 >( Overlaps{} ) ); } }; // helper for the forLocalInternal, forLocalBoundary and forOverlaps methods (DistributedNDArray) template< typename TargetHolder, typename SourceHolder, typename Overlaps = make_constant_index_sequence< TargetHolder::getDimension(), 0 >, std::size_t level = TargetHolder::getDimension() - 1 > struct SetSizesSubtractOverlapsHelper { static void subtract( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() - get< level >( Overlaps{} ) ); SetSizesSubtractOverlapsHelper< TargetHolder, SourceHolder, Overlaps, level - 1 >::subtract( target, source ); } }; template< typename TargetHolder, typename SourceHolder, typename Overlaps > struct SetSizesSubtractOverlapsHelper< TargetHolder, SourceHolder, Overlaps, 0 > { static void subtract( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() - get< 0 >( Overlaps{} ) ); } }; // helper for the forLocalInternal, forLocalBoundary and forOverlaps methods (DistributedNDArray) template< typename TargetHolder, typename SourceHolder, typename Overlaps = make_constant_index_sequence< TargetHolder::getDimension(), 0 >, std::size_t level = TargetHolder::getDimension() - 1 > struct SetSizesAddOverlapsHelper { static void add( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< level >() == 0 ) target.template setSize< level >( source.template getSize< level >() + get< level >( Overlaps{} ) ); SetSizesAddOverlapsHelper< TargetHolder, SourceHolder, Overlaps, level - 1 >::add( target, source ); } }; template< typename TargetHolder, typename SourceHolder, typename Overlaps > struct SetSizesAddOverlapsHelper< TargetHolder, SourceHolder, Overlaps, 0 > { static void add( TargetHolder& target, const SourceHolder& source ) { if( source.template getStaticSize< 0 >() == 0 ) target.template setSize< 0 >( source.template getSize< 0 >() + get< 0 >( Overlaps{} ) ); } }; Loading
src/UnitTests/Containers/ndarray/CMakeLists.txt +11 −0 Original line number Diff line number Diff line Loading @@ -30,12 +30,23 @@ if( ${BUILD_MPI} ) CUDA_ADD_EXECUTABLE( DistributedNDArrayTest DistributedNDArrayTest.cu OPTIONS ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayTest ${GTEST_BOTH_LIBRARIES} ) CUDA_ADD_EXECUTABLE( DistributedNDArrayOverlapsTest DistributedNDArrayOverlapsTest.cu OPTIONS ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayOverlapsTest ${GTEST_BOTH_LIBRARIES} ) else() ADD_EXECUTABLE( DistributedNDArrayTest DistributedNDArrayTest.cpp ) TARGET_COMPILE_OPTIONS( DistributedNDArrayTest PRIVATE ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayTest ${GTEST_BOTH_LIBRARIES} ) ADD_EXECUTABLE( DistributedNDArrayOverlapsTest DistributedNDArrayOverlapsTest.cpp ) TARGET_COMPILE_OPTIONS( DistributedNDArrayOverlapsTest PRIVATE ${CXX_TESTS_FLAGS} ) TARGET_LINK_LIBRARIES( DistributedNDArrayOverlapsTest ${GTEST_BOTH_LIBRARIES} ) endif() SET( mpi_test_parameters -np 4 -H localhost:4 "${EXECUTABLE_OUTPUT_PATH}/DistributedNDArrayTest${CMAKE_EXECUTABLE_SUFFIX}" ) ADD_TEST( NAME DistributedNDArrayTest COMMAND "mpirun" ${mpi_test_parameters}) SET( mpi_test_parameters -np 4 -H localhost:4 "${EXECUTABLE_OUTPUT_PATH}/DistributedNDArrayOverlapsTest${CMAKE_EXECUTABLE_SUFFIX}" ) ADD_TEST( NAME DistributedNDArrayOverlapsTest COMMAND "mpirun" ${mpi_test_parameters}) endif()