Loading src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp +9 −3 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ set( Element* data, const Element& value, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); auto kernel = [data, value] __cuda_callable__ ( Index i ) { Loading @@ -70,6 +71,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); if( std::is_same< DestinationElement, SourceElement >::value ) Loading Loading @@ -127,6 +129,7 @@ compare( const Element1* destination, const Element2* source, const Index size ) { if( size == 0 ) return true; TNL_ASSERT_TRUE( destination, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to compare data through a nullptr." ); Loading @@ -144,10 +147,10 @@ containsValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, (Index) 0, "" ); if( size == 0 ) return false; auto fetch = [=] __cuda_callable__ ( Index i ) -> bool { return ( data[ i ] == value ); }; auto reduction = [=] __cuda_callable__ ( bool& a, const bool& b ) { a |= b; }; auto volatileReduction = [=] __cuda_callable__ ( volatile bool& a, volatile bool& b ) { a |= b; }; Loading @@ -162,11 +165,10 @@ containsOnlyValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); if( size == 0 ) return false; if( size == 0 ) return false; auto fetch = [=] __cuda_callable__ ( Index i ) -> bool { return ( data[ i ] == value ); }; auto reduction = [=] __cuda_callable__ ( bool& a, const bool& b ) { a &= b; }; auto volatileReduction = [=] __cuda_callable__ ( volatile bool& a, volatile bool& b ) { a &= b; }; Loading @@ -186,6 +188,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); #ifdef HAVE_CUDA Loading Loading @@ -235,6 +238,7 @@ compare( const Element1* destination, const Element2* source, const Index size ) { if( size == 0 ) return true; /*** * Here, destination is on host and source is on CUDA device. */ Loading Loading @@ -275,6 +279,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); TNL_ASSERT_GE( size, (Index) 0, "Array size must be non-negative." ); Loading Loading @@ -323,6 +328,7 @@ compare( const Element1* hostData, const Element2* deviceData, const Index size ) { if( size == 0 ) return true; TNL_ASSERT_TRUE( hostData, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( deviceData, "Attempted to compare data through a nullptr." ); TNL_ASSERT_GE( size, (Index) 0, "Array size must be non-negative." ); Loading src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp +5 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ set( Element* data, const Element& value, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); auto kernel = [data, value]( Index i ) { Loading @@ -66,6 +67,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; if( std::is_same< DestinationElement, SourceElement >::value && ( std::is_fundamental< DestinationElement >::value || std::is_pointer< DestinationElement >::value ) ) Loading Loading @@ -118,6 +120,7 @@ compare( const DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return true; TNL_ASSERT_TRUE( destination, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to compare data through a nullptr." ); if( std::is_same< DestinationElement, SourceElement >::value && Loading @@ -142,6 +145,7 @@ containsValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); Loading @@ -159,11 +163,10 @@ containsOnlyValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); if( size == 0 ) return false; for( Index i = 0; i < size; i++ ) if( ! ( data[ i ] == value ) ) return false; Loading src/UnitTests/Containers/ArrayTest.h +5 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,11 @@ TYPED_TEST( ArrayTest, constructors ) { using ArrayType = typename TestFixture::ArrayType; ArrayType empty_u; ArrayType empty_v( empty_u ); EXPECT_EQ( empty_u.getSize(), 0 ); EXPECT_EQ( empty_v.getSize(), 0 ); ArrayType u; EXPECT_EQ( u.getSize(), 0 ); u.setSize( 10 ); Loading Loading
src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp +9 −3 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ set( Element* data, const Element& value, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); auto kernel = [data, value] __cuda_callable__ ( Index i ) { Loading @@ -70,6 +71,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); if( std::is_same< DestinationElement, SourceElement >::value ) Loading Loading @@ -127,6 +129,7 @@ compare( const Element1* destination, const Element2* source, const Index size ) { if( size == 0 ) return true; TNL_ASSERT_TRUE( destination, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to compare data through a nullptr." ); Loading @@ -144,10 +147,10 @@ containsValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, (Index) 0, "" ); if( size == 0 ) return false; auto fetch = [=] __cuda_callable__ ( Index i ) -> bool { return ( data[ i ] == value ); }; auto reduction = [=] __cuda_callable__ ( bool& a, const bool& b ) { a |= b; }; auto volatileReduction = [=] __cuda_callable__ ( volatile bool& a, volatile bool& b ) { a |= b; }; Loading @@ -162,11 +165,10 @@ containsOnlyValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); if( size == 0 ) return false; if( size == 0 ) return false; auto fetch = [=] __cuda_callable__ ( Index i ) -> bool { return ( data[ i ] == value ); }; auto reduction = [=] __cuda_callable__ ( bool& a, const bool& b ) { a &= b; }; auto volatileReduction = [=] __cuda_callable__ ( volatile bool& a, volatile bool& b ) { a &= b; }; Loading @@ -186,6 +188,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); #ifdef HAVE_CUDA Loading Loading @@ -235,6 +238,7 @@ compare( const Element1* destination, const Element2* source, const Index size ) { if( size == 0 ) return true; /*** * Here, destination is on host and source is on CUDA device. */ Loading Loading @@ -275,6 +279,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); TNL_ASSERT_GE( size, (Index) 0, "Array size must be non-negative." ); Loading Loading @@ -323,6 +328,7 @@ compare( const Element1* hostData, const Element2* deviceData, const Index size ) { if( size == 0 ) return true; TNL_ASSERT_TRUE( hostData, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( deviceData, "Attempted to compare data through a nullptr." ); TNL_ASSERT_GE( size, (Index) 0, "Array size must be non-negative." ); Loading
src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp +5 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ set( Element* data, const Element& value, const Index size ) { if( size == 0 ) return; TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); auto kernel = [data, value]( Index i ) { Loading @@ -66,6 +67,7 @@ copy( DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return; if( std::is_same< DestinationElement, SourceElement >::value && ( std::is_fundamental< DestinationElement >::value || std::is_pointer< DestinationElement >::value ) ) Loading Loading @@ -118,6 +120,7 @@ compare( const DestinationElement* destination, const SourceElement* source, const Index size ) { if( size == 0 ) return true; TNL_ASSERT_TRUE( destination, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to compare data through a nullptr." ); if( std::is_same< DestinationElement, SourceElement >::value && Loading @@ -142,6 +145,7 @@ containsValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); Loading @@ -159,11 +163,10 @@ containsOnlyValue( const Element* data, const Index size, const Element& value ) { if( size == 0 ) return false; TNL_ASSERT_TRUE( data, "Attempted to check data through a nullptr." ); TNL_ASSERT_GE( size, 0, "" ); if( size == 0 ) return false; for( Index i = 0; i < size; i++ ) if( ! ( data[ i ] == value ) ) return false; Loading
src/UnitTests/Containers/ArrayTest.h +5 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,11 @@ TYPED_TEST( ArrayTest, constructors ) { using ArrayType = typename TestFixture::ArrayType; ArrayType empty_u; ArrayType empty_v( empty_u ); EXPECT_EQ( empty_u.getSize(), 0 ); EXPECT_EQ( empty_v.getSize(), 0 ); ArrayType u; EXPECT_EQ( u.getSize(), 0 ); u.setSize( 10 ); Loading