diff --git a/src/TNL/Containers/Algorithms/ArrayAssignment.h b/src/TNL/Containers/Algorithms/ArrayAssignment.h index dbf0f82b95cc380d343755167ab4b268403b353b..78585003da472bde1185a3c3380fcc860ce800c2 100644 --- a/src/TNL/Containers/Algorithms/ArrayAssignment.h +++ b/src/TNL/Containers/Algorithms/ArrayAssignment.h @@ -60,7 +60,7 @@ struct ArrayAssignment< Array, T, true > TNL_ASSERT_EQ( a.getSize(), t.getSize(), "The sizes of the arrays must be equal." ); if( t.getSize() > 0 ) // we allow even assignment of empty arrays ArrayOperations< typename Array::DeviceType, typename T::DeviceType >::template - copyMemory< typename Array::ValueType, typename T::ValueType, typename Array::IndexType > + copy< typename Array::ValueType, typename T::ValueType, typename Array::IndexType > ( a.getArrayData(), t.getArrayData(), t.getSize() ); } }; @@ -81,7 +81,7 @@ struct ArrayAssignment< Array, T, false > { TNL_ASSERT_FALSE( a.empty(), "Cannot assign value to empty array." ); ArrayOperations< typename Array::DeviceType >::template - setMemory< typename Array::ValueType, typename Array::IndexType > + set< typename Array::ValueType, typename Array::IndexType > ( a.getArrayData(), ( typename Array::ValueType ) t, a.getSize() ); } }; diff --git a/src/TNL/Containers/Algorithms/ArrayOperations.h b/src/TNL/Containers/Algorithms/ArrayOperations.h index c7a8fe09424066110ac8a1a5cf652fb48daa4769..219465e18c9aa3d65931e36d29e689a62915571c 100644 --- a/src/TNL/Containers/Algorithms/ArrayOperations.h +++ b/src/TNL/Containers/Algorithms/ArrayOperations.h @@ -21,234 +21,222 @@ namespace Algorithms { template< typename DestinationDevice, typename SourceDevice = DestinationDevice > -class ArrayOperations{}; +struct ArrayOperations; template<> -class ArrayOperations< Devices::Host > +struct ArrayOperations< Devices::Host > { - public: - - template< typename Element > - static void setMemoryElement( Element* data, - const Element& value ); - - template< typename Element > - static Element getMemoryElement( const Element* data ); - - template< typename Element, typename Index > - static void setMemory( Element* data, - const Element& value, - const Index size ); - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static void copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ); - - template< typename DestinationElement, - typename SourceElement > - static void copySTLList( DestinationElement* destination, - const std::list< SourceElement >& source ); - - template< typename Element1, - typename Element2, - typename Index > - static bool compareMemory( const Element1* destination, - const Element2* source, - const Index size ); - - template< typename Element, - typename Index > - static bool containsValue( const Element* data, - const Index size, - const Element& value ); - - template< typename Element, - typename Index > - static bool containsOnlyValue( const Element* data, - const Index size, - const Element& value ); + template< typename Element > + static void setElement( Element* data, + const Element& value ); + + template< typename Element > + static Element getElement( const Element* data ); + + template< typename Element, typename Index > + static void set( Element* data, + const Element& value, + const Index size ); + + template< typename DestinationElement, + typename SourceElement, + typename Index > + static void copy( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename DestinationElement, + typename SourceElement > + static void copySTLList( DestinationElement* destination, + const std::list< SourceElement >& source ); + + template< typename Element1, + typename Element2, + typename Index > + static bool compare( const Element1* destination, + const Element2* source, + const Index size ); + + template< typename Element, + typename Index > + static bool containsValue( const Element* data, + const Index size, + const Element& value ); + + template< typename Element, + typename Index > + static bool containsOnlyValue( const Element* data, + const Index size, + const Element& value ); }; template<> -class ArrayOperations< Devices::Cuda > +struct ArrayOperations< Devices::Cuda > { - public: - - template< typename Element > - static void setMemoryElement( Element* data, - const Element& value ); - - template< typename Element > - static Element getMemoryElement( const Element* data ); - - template< typename Element, typename Index > - static void setMemory( Element* data, - const Element& value, - const Index size ); - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static void copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ); - - template< typename DestinationElement, - typename SourceElement > - static void copySTLList( DestinationElement* destination, - const std::list< SourceElement >& source ); - - template< typename Element1, - typename Element2, - typename Index > - static bool compareMemory( const Element1* destination, - const Element2* source, - const Index size ); - - template< typename Element, - typename Index > - static bool containsValue( const Element* data, - const Index size, - const Element& value ); - - template< typename Element, - typename Index > - static bool containsOnlyValue( const Element* data, - const Index size, - const Element& value ); + template< typename Element > + static void setElement( Element* data, + const Element& value ); + + template< typename Element > + static Element getElement( const Element* data ); + + template< typename Element, typename Index > + static void set( Element* data, + const Element& value, + const Index size ); + + template< typename DestinationElement, + typename SourceElement, + typename Index > + static void copy( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename DestinationElement, + typename SourceElement > + static void copySTLList( DestinationElement* destination, + const std::list< SourceElement >& source ); + + template< typename Element1, + typename Element2, + typename Index > + static bool compare( const Element1* destination, + const Element2* source, + const Index size ); + + template< typename Element, + typename Index > + static bool containsValue( const Element* data, + const Index size, + const Element& value ); + + template< typename Element, + typename Index > + static bool containsOnlyValue( const Element* data, + const Index size, + const Element& value ); }; template<> -class ArrayOperations< Devices::Cuda, Devices::Host > +struct ArrayOperations< Devices::Cuda, Devices::Host > { - public: - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static void copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ); - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static bool compareMemory( const DestinationElement* destination, - const SourceElement* source, - const Index size ); + template< typename DestinationElement, + typename SourceElement, + typename Index > + static void copy( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename DestinationElement, + typename SourceElement, + typename Index > + static bool compare( const DestinationElement* destination, + const SourceElement* source, + const Index size ); }; template<> -class ArrayOperations< Devices::Host, Devices::Cuda > +struct ArrayOperations< Devices::Host, Devices::Cuda > { - public: - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static void copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ); - - template< typename Element1, - typename Element2, - typename Index > - static bool compareMemory( const Element1* destination, - const Element2* source, - const Index size ); + template< typename DestinationElement, + typename SourceElement, + typename Index > + static void copy( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename Element1, + typename Element2, + typename Index > + static bool compare( const Element1* destination, + const Element2* source, + const Index size ); }; template<> -class ArrayOperations< Devices::MIC > +struct ArrayOperations< Devices::MIC > { - public: - - template< typename Element > - static void setMemoryElement( Element* data, - const Element& value ); - - template< typename Element > - static Element getMemoryElement( const Element* data ); - - template< typename Element, typename Index > - static void setMemory( Element* data, - const Element& value, - const Index size ); - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static void copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ); - - template< typename DestinationElement, - typename SourceElement > - static void copySTLList( DestinationElement* destination, - const std::list< SourceElement >& source ); - - template< typename Element1, - typename Element2, - typename Index > - static bool compareMemory( const Element1* destination, - const Element2* source, - const Index size ); - - template< typename Element, - typename Index > - static bool containsValue( const Element* data, - const Index size, - const Element& value ); - - template< typename Element, - typename Index > - static bool containsOnlyValue( const Element* data, - const Index size, - const Element& value ); + template< typename Element > + static void setElement( Element* data, + const Element& value ); + + template< typename Element > + static Element getElement( const Element* data ); + + template< typename Element, typename Index > + static void set( Element* data, + const Element& value, + const Index size ); + + template< typename DestinationElement, + typename SourceElement, + typename Index > + static void copy( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename DestinationElement, + typename SourceElement > + static void copySTLList( DestinationElement* destination, + const std::list< SourceElement >& source ); + + template< typename Element1, + typename Element2, + typename Index > + static bool compare( const Element1* destination, + const Element2* source, + const Index size ); + + template< typename Element, + typename Index > + static bool containsValue( const Element* data, + const Index size, + const Element& value ); + + template< typename Element, + typename Index > + static bool containsOnlyValue( const Element* data, + const Index size, + const Element& value ); }; template<> -class ArrayOperations< Devices::MIC, Devices::Host > +struct ArrayOperations< Devices::MIC, Devices::Host > { public: template< typename DestinationElement, typename SourceElement, typename Index > - static void copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ); + static void copy( DestinationElement* destination, + const SourceElement* source, + const Index size ); template< typename DestinationElement, typename SourceElement, typename Index > - static bool compareMemory( const DestinationElement* destination, - const SourceElement* source, - const Index size ); + static bool compare( const DestinationElement* destination, + const SourceElement* source, + const Index size ); }; template<> -class ArrayOperations< Devices::Host, Devices::MIC > +struct ArrayOperations< Devices::Host, Devices::MIC > { - public: - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static void copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ); - - template< typename DestinationElement, - typename SourceElement, - typename Index > - static bool compareMemory( const DestinationElement* destination, - const SourceElement* source, - const Index size ); + template< typename DestinationElement, + typename SourceElement, + typename Index > + static void copy( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename DestinationElement, + typename SourceElement, + typename Index > + static bool compare( const DestinationElement* destination, + const SourceElement* source, + const Index size ); }; } // namespace Algorithms diff --git a/src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp b/src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp index fe5637c4d9bd2cd7e93e6429cd14b8f664dcc18c..68615a386c84a761e358a22a7076f1eafbf5ad0f 100644 --- a/src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp +++ b/src/TNL/Containers/Algorithms/ArrayOperationsCuda.hpp @@ -27,30 +27,30 @@ namespace Algorithms { template< typename Element > void ArrayOperations< Devices::Cuda >:: -setMemoryElement( Element* data, - const Element& value ) +setElement( Element* data, + const Element& value ) { TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); - ArrayOperations< Devices::Cuda >::setMemory( data, value, 1 ); + ArrayOperations< Devices::Cuda >::set( data, value, 1 ); } template< typename Element > Element ArrayOperations< Devices::Cuda >:: -getMemoryElement( const Element* data ) +getElement( const Element* data ) { TNL_ASSERT_TRUE( data, "Attempted to get data through a nullptr." ); Element result; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory< Element, Element, int >( &result, data, 1 ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy< Element, Element, int >( &result, data, 1 ); return result; } template< typename Element, typename Index > void ArrayOperations< Devices::Cuda >:: -setMemory( Element* data, - const Element& value, - const Index size ) +set( Element* data, + const Element& value, + const Index size ) { TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); auto kernel = [data, value] __cuda_callable__ ( Index i ) @@ -65,9 +65,9 @@ template< typename DestinationElement, typename Index > void ArrayOperations< Devices::Cuda >:: -copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ) +copy( DestinationElement* destination, + const SourceElement* source, + const Index size ) { TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); @@ -111,7 +111,7 @@ copySTLList( DestinationElement* destination, const auto copySize = std::min( size - copiedElements, copy_buffer_size ); for( std::size_t i = 0; i < copySize; i++ ) copy_buffer[ i ] = static_cast< DestinationElement >( * it ++ ); - ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( &destination[ copiedElements ], ©_buffer[ 0 ], copySize ); + ArrayOperations< Devices::Cuda, Devices::Host >::copy( &destination[ copiedElements ], ©_buffer[ 0 ], copySize ); copiedElements += copySize; } } @@ -120,9 +120,9 @@ template< typename Element1, typename Index > bool ArrayOperations< Devices::Cuda >:: -compareMemory( const Element1* destination, - const Element2* source, - const Index size ) +compare( const Element1* destination, + const Element2* source, + const Index size ) { TNL_ASSERT_TRUE( destination, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to compare data through a nullptr." ); @@ -179,9 +179,9 @@ template< typename DestinationElement, typename Index > void ArrayOperations< Devices::Host, Devices::Cuda >:: -copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ) +copy( DestinationElement* destination, + const SourceElement* source, + const Index size ) { TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); @@ -228,9 +228,9 @@ template< typename Element1, typename Index > bool ArrayOperations< Devices::Host, Devices::Cuda >:: -compareMemory( const Element1* destination, - const Element2* source, - const Index size ) +compare( const Element1* destination, + const Element2* source, + const Index size ) { /*** * Here, destination is on host and source is on CUDA device. @@ -250,7 +250,7 @@ compareMemory( const Element1* destination, cudaMemcpyDeviceToHost ) != cudaSuccess ) std::cerr << "Transfer of data from CUDA device to host failed." << std::endl; TNL_CHECK_CUDA_DEVICE; - if( ! ArrayOperations< Devices::Host >::compareMemory( &destination[ compared ], host_buffer.get(), transfer ) ) + if( ! ArrayOperations< Devices::Host >::compare( &destination[ compared ], host_buffer.get(), transfer ) ) return false; compared += transfer; } @@ -268,9 +268,9 @@ template< typename DestinationElement, typename Index > void ArrayOperations< Devices::Cuda, Devices::Host >:: -copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ) +copy( DestinationElement* destination, + const SourceElement* source, + const Index size ) { TNL_ASSERT_TRUE( destination, "Attempted to copy data to a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to copy data from a nullptr." ); @@ -316,14 +316,14 @@ template< typename Element1, typename Index > bool ArrayOperations< Devices::Cuda, Devices::Host >:: -compareMemory( const Element1* hostData, - const Element2* deviceData, - const Index size ) +compare( const Element1* hostData, + const Element2* deviceData, + const Index size ) { 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." ); - return ArrayOperations< Devices::Host, Devices::Cuda >::compareMemory( deviceData, hostData, size ); + return ArrayOperations< Devices::Host, Devices::Cuda >::compare( deviceData, hostData, size ); } } // namespace Algorithms diff --git a/src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp b/src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp index 6f4751d4a31f05914fc5b4afcb48e085d20b060d..a50a10aaf0724368f8e45dc7aa655bec5c737844 100644 --- a/src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp +++ b/src/TNL/Containers/Algorithms/ArrayOperationsHost.hpp @@ -25,8 +25,8 @@ namespace Algorithms { template< typename Element > void ArrayOperations< Devices::Host >:: -setMemoryElement( Element* data, - const Element& value ) +setElement( Element* data, + const Element& value ) { TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); *data = value; @@ -35,7 +35,7 @@ setMemoryElement( Element* data, template< typename Element > Element ArrayOperations< Devices::Host >:: -getMemoryElement( const Element* data ) +getElement( const Element* data ) { TNL_ASSERT_TRUE( data, "Attempted to get data through a nullptr." ); return *data; @@ -44,9 +44,9 @@ getMemoryElement( const Element* data ) template< typename Element, typename Index > void ArrayOperations< Devices::Host >:: -setMemory( Element* data, - const Element& value, - const Index size ) +set( Element* data, + const Element& value, + const Index size ) { TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); auto kernel = [data, value]( Index i ) @@ -61,9 +61,9 @@ template< typename DestinationElement, typename Index > void ArrayOperations< Devices::Host >:: -copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ) +copy( DestinationElement* destination, + const SourceElement* source, + const Index size ) { if( std::is_same< DestinationElement, SourceElement >::value && ( std::is_fundamental< DestinationElement >::value || @@ -108,9 +108,9 @@ template< typename DestinationElement, typename Index > bool ArrayOperations< Devices::Host >:: -compareMemory( const DestinationElement* destination, - const SourceElement* source, - const Index size ) +compare( const DestinationElement* destination, + const SourceElement* source, + const Index size ) { TNL_ASSERT_TRUE( destination, "Attempted to compare data through a nullptr." ); TNL_ASSERT_TRUE( source, "Attempted to compare data through a nullptr." ); diff --git a/src/TNL/Containers/Algorithms/ArrayOperationsMIC.hpp b/src/TNL/Containers/Algorithms/ArrayOperationsMIC.hpp index fc0e7f56b03d7a33c2becce56149ae8e38756e4f..601ce06668dbb71eefd1810dc72f0772740166dc 100644 --- a/src/TNL/Containers/Algorithms/ArrayOperationsMIC.hpp +++ b/src/TNL/Containers/Algorithms/ArrayOperationsMIC.hpp @@ -30,30 +30,30 @@ static constexpr std::size_t MIC_STACK_VAR_LIM = 5*1024*1024; template< typename Element > void ArrayOperations< Devices::MIC >:: -setMemoryElement( Element* data, - const Element& value ) +setElement( Element* data, + const Element& value ) { TNL_ASSERT( data, ); - ArrayOperations< Devices::MIC >::setMemory( data, value, 1 ); + ArrayOperations< Devices::MIC >::set( data, value, 1 ); } template< typename Element > Element ArrayOperations< Devices::MIC >:: -getMemoryElement( const Element* data ) +getElement( const Element* data ) { TNL_ASSERT( data, ); Element result; - ArrayOperations< Devices::Host, Devices::MIC >::copyMemory< Element, Element, int >( &result, data, 1 ); + ArrayOperations< Devices::Host, Devices::MIC >::copy< Element, Element, int >( &result, data, 1 ); return result; } template< typename Element, typename Index > void ArrayOperations< Devices::MIC >:: -setMemory( Element* data, - const Element& value, - const Index size ) +set( Element* data, + const Element& value, + const Index size ) { TNL_ASSERT( data, ); #ifdef HAVE_MIC @@ -76,9 +76,9 @@ template< typename DestinationElement, typename Index > void ArrayOperations< Devices::MIC >:: -copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ) +copy( DestinationElement* destination, + const SourceElement* source, + const Index size ) { TNL_ASSERT( destination, ); TNL_ASSERT( source, ); @@ -116,7 +116,7 @@ template< typename DestinationElement, void ArrayOperations< Devices::MIC >:: copySTLList( DestinationElement* destination, - const std::list< SourceElement >& source ) + const std::list< SourceElement >& source ) { throw Exceptions::NotImplementedError(); } @@ -126,9 +126,9 @@ template< typename Element1, typename Index > bool ArrayOperations< Devices::MIC >:: -compareMemory( const Element1* destination, - const Element2* source, - const Index size ) +compare( const Element1* destination, + const Element2* source, + const Index size ) { TNL_ASSERT( destination, ); TNL_ASSERT( source, ); @@ -218,9 +218,9 @@ template< typename DestinationElement, typename Index > void ArrayOperations< Devices::Host, Devices::MIC >:: -copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ) +copy( DestinationElement* destination, + const SourceElement* source, + const Index size ) { TNL_ASSERT( destination, ); TNL_ASSERT( source, ); @@ -293,9 +293,9 @@ template< typename Element1, typename Index > bool ArrayOperations< Devices::Host, Devices::MIC >:: -compareMemory( const Element1* destination, - const Element2* source, - const Index size ) +compare( const Element1* destination, + const Element2* source, + const Index size ) { /*** * Here, destination is on host and source is on MIC device. @@ -319,7 +319,7 @@ compareMemory( const Element1* destination, { memcpy((void*)&host_buffer,(void*)src_ptr.pointer,transfer*sizeof(Element2)); } - if( ! ArrayOperations< Devices::Host >::compareMemory( &destination[ compared ], (Element2*)&host_buffer, transfer ) ) + if( ! ArrayOperations< Devices::Host >::compare( &destination[ compared ], (Element2*)&host_buffer, transfer ) ) { return false; } @@ -339,9 +339,9 @@ template< typename DestinationElement, typename Index > void ArrayOperations< Devices::MIC, Devices::Host >:: -copyMemory( DestinationElement* destination, - const SourceElement* source, - const Index size ) +copy( DestinationElement* destination, + const SourceElement* source, + const Index size ) { TNL_ASSERT( destination, ); TNL_ASSERT( source, ); @@ -412,14 +412,14 @@ template< typename Element1, typename Index > bool ArrayOperations< Devices::MIC, Devices::Host >:: -compareMemory( const Element1* hostData, - const Element2* deviceData, - const Index size ) +compare( const Element1* hostData, + const Element2* deviceData, + const Index size ) { TNL_ASSERT( hostData, ); TNL_ASSERT( deviceData, ); TNL_ASSERT( size >= 0, std::cerr << "size = " << size ); - return ArrayOperations< Devices::Host, Devices::MIC >::compareMemory( deviceData, hostData, size ); + return ArrayOperations< Devices::Host, Devices::MIC >::compare( deviceData, hostData, size ); } } // namespace Algorithms diff --git a/src/TNL/Containers/Algorithms/CudaReductionKernel.h b/src/TNL/Containers/Algorithms/CudaReductionKernel.h index 21613c497864e26cc7562061fcc85cc4ef38266c..5973747fbfb15cff3df93c072c16dfef4aa344f2 100644 --- a/src/TNL/Containers/Algorithms/CudaReductionKernel.h +++ b/src/TNL/Containers/Algorithms/CudaReductionKernel.h @@ -402,7 +402,7 @@ struct CudaReductionKernelLauncher //// // Copy result on CPU ResultType result; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( &result, output, 1 ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( &result, output, 1 ); return result; } @@ -438,8 +438,8 @@ struct CudaReductionKernelLauncher //// // Copy result on CPU ResultType result; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( &result, output, 1 ); - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( &argument, idxOutput, 1 ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( &result, output, 1 ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( &argument, idxOutput, 1 ); return result; } diff --git a/src/TNL/Containers/Algorithms/Multireduction_impl.h b/src/TNL/Containers/Algorithms/Multireduction_impl.h index a4c5ff26e49df3b289ab3c4e15e86225901ed99c..ebd0ad2562a4795fcea6abeb9287b5063b92c408 100644 --- a/src/TNL/Containers/Algorithms/Multireduction_impl.h +++ b/src/TNL/Containers/Algorithms/Multireduction_impl.h @@ -76,11 +76,11 @@ reduce( Operation& operation, */ if( n * ldInput1 < Multireduction_minGpuDataSize ) { DataType1 hostArray1[ Multireduction_minGpuDataSize ]; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( hostArray1, deviceInput1, n * ldInput1 ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( hostArray1, deviceInput1, n * ldInput1 ); if( deviceInput2 ) { using _DT2 = typename std::conditional< std::is_same< DataType2, void >::value, DataType1, DataType2 >::type; _DT2 hostArray2[ Multireduction_minGpuDataSize ]; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( hostArray2, (_DT2*) deviceInput2, size ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( hostArray2, (_DT2*) deviceInput2, size ); Multireduction< Devices::Host >::reduce( operation, n, size, hostArray1, ldInput1, hostArray2, hostResult ); } else { @@ -117,7 +117,7 @@ reduce( Operation& operation, * Transfer the reduced data from device to host. */ ResultType resultArray[ n * reducedSize ]; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( resultArray, deviceAux1, n * reducedSize ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( resultArray, deviceAux1, n * reducedSize ); #ifdef CUDA_REDUCTION_PROFILING timer.stop(); diff --git a/src/TNL/Containers/Algorithms/Reduction.hpp b/src/TNL/Containers/Algorithms/Reduction.hpp index 21aaf015474032e80cca3b8616de7cb11c37d4e0..818fe963f836617a332188a0c34952ec129ca9f9 100644 --- a/src/TNL/Containers/Algorithms/Reduction.hpp +++ b/src/TNL/Containers/Algorithms/Reduction.hpp @@ -326,7 +326,7 @@ Reduction< Devices::Cuda >:: * Transfer the reduced data from device to host. */ std::unique_ptr< ResultType[] > resultArray{ new ResultType[ reducedSize ] }; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( resultArray.get(), deviceAux1, reducedSize ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( resultArray.get(), deviceAux1, reducedSize ); #ifdef CUDA_REDUCTION_PROFILING timer.stop(); @@ -427,8 +427,8 @@ reduceWithArgument( const Index size, */ std::unique_ptr< ResultType[] > resultArray{ new ResultType[ reducedSize ] }; std::unique_ptr< IndexType[] > indexArray{ new IndexType[ reducedSize ] }; - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( resultArray.get(), deviceAux1, reducedSize ); - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( indexArray.get(), deviceIndexes, reducedSize ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( resultArray.get(), deviceAux1, reducedSize ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy( indexArray.get(), deviceIndexes, reducedSize ); #ifdef CUDA_REDUCTION_PROFILING timer.stop(); diff --git a/src/TNL/Containers/Array.hpp b/src/TNL/Containers/Array.hpp index a667f5a36ca51791f79b65e8eca7e6ef5b7e0997..9807128036998f4a72acd148e871dd1a66669e87 100644 --- a/src/TNL/Containers/Array.hpp +++ b/src/TNL/Containers/Array.hpp @@ -57,7 +57,7 @@ Array( Value* data, : allocator( allocator ) { this->setSize( size ); - Algorithms::ArrayOperations< Device >::copyMemory( this->getData(), data, size ); + Algorithms::ArrayOperations< Device >::copy( this->getData(), data, size ); } template< typename Value, @@ -68,7 +68,7 @@ Array< Value, Device, Index, Allocator >:: Array( const Array< Value, Device, Index, Allocator >& array ) { this->setSize( array.getSize() ); - Algorithms::ArrayOperations< Device >::copyMemory( this->getData(), array.getData(), array.getSize() ); + Algorithms::ArrayOperations< Device >::copy( this->getData(), array.getData(), array.getSize() ); } template< typename Value, @@ -81,7 +81,7 @@ Array( const Array< Value, Device, Index, Allocator >& array, : allocator( allocator ) { this->setSize( array.getSize() ); - Algorithms::ArrayOperations< Device >::copyMemory( this->getData(), array.getData(), array.getSize() ); + Algorithms::ArrayOperations< Device >::copy( this->getData(), array.getData(), array.getSize() ); } template< typename Value, @@ -101,7 +101,7 @@ Array( const Array< Value, Device, Index, Allocator >& array, TNL_ASSERT_LE( begin + size, array.getSize(), "End of array is out of bounds." ); this->setSize( size ); - Algorithms::ArrayOperations< Device >::copyMemory( this->getData(), &array.getData()[ begin ], size ); + Algorithms::ArrayOperations< Device >::copy( this->getData(), &array.getData()[ begin ], size ); } template< typename Value, @@ -118,7 +118,7 @@ Array( const std::initializer_list< InValue >& list, // Here we assume that the underlying array for std::initializer_list is // const T[N] as noted here: // https://en.cppreference.com/w/cpp/utility/initializer_list - Algorithms::ArrayOperations< Device, Devices::Host >::copyMemory( this->getData(), &( *list.begin() ), list.size() ); + Algorithms::ArrayOperations< Device, Devices::Host >::copy( this->getData(), &( *list.begin() ), list.size() ); } template< typename Value, @@ -146,7 +146,7 @@ Array( const std::vector< InValue >& vector, : allocator( allocator ) { this->setSize( vector.size() ); - Algorithms::ArrayOperations< Device, Devices::Host >::copyMemory( this->getData(), vector.data(), vector.size() ); + Algorithms::ArrayOperations< Device, Devices::Host >::copy( this->getData(), vector.data(), vector.size() ); } template< typename Value, @@ -494,7 +494,7 @@ setElement( const Index& i, const Value& x ) { TNL_ASSERT_GE( i, (Index) 0, "Element index must be non-negative." ); TNL_ASSERT_LT( i, this->getSize(), "Element index is out of bounds." ); - return Algorithms::ArrayOperations< Device >::setMemoryElement( &( this->data[ i ] ), x ); + return Algorithms::ArrayOperations< Device >::setElement( &( this->data[ i ] ), x ); } template< typename Value, @@ -507,7 +507,7 @@ getElement( const Index& i ) const { TNL_ASSERT_GE( i, (Index) 0, "Element index must be non-negative." ); TNL_ASSERT_LT( i, this->getSize(), "Element index is out of bounds." ); - return Algorithms::ArrayOperations< Device >::getMemoryElement( & ( this->data[ i ] ) ); + return Algorithms::ArrayOperations< Device >::getElement( & ( this->data[ i ] ) ); } template< typename Value, @@ -551,7 +551,7 @@ operator=( const Array< Value, Device, Index, Allocator >& array ) this->setLike( array ); if( this->getSize() > 0 ) Algorithms::ArrayOperations< Device >:: - copyMemory( this->getData(), + copy( this->getData(), array.getData(), array.getSize() ); return *this; @@ -619,7 +619,7 @@ operator=( const std::vector< InValue >& vector ) { if( this->getSize() != vector.size() ) this->setSize( vector.size() ); - Algorithms::ArrayOperations< Device, Devices::Host >::copyMemory( this->getData(), vector.data(), vector.size() ); + Algorithms::ArrayOperations< Device, Devices::Host >::copy( this->getData(), vector.data(), vector.size() ); return *this; } @@ -637,7 +637,7 @@ operator==( const ArrayT& array ) const if( this->getSize() == 0 ) return true; return Algorithms::ArrayOperations< Device, typename ArrayT::DeviceType >:: - compareMemory( this->getData(), + compare( this->getData(), array.getData(), array.getSize() ); } @@ -667,7 +667,7 @@ setValue( const ValueType& v, TNL_ASSERT_TRUE( this->getData(), "Attempted to set a value of an empty array." ); if( end == 0 ) end = this->getSize(); - Algorithms::ArrayOperations< Device >::setMemory( &this->getData()[ begin ], v, end - begin ); + Algorithms::ArrayOperations< Device >::set( &this->getData()[ begin ], v, end - begin ); } template< typename Value, diff --git a/src/TNL/Containers/ArrayView.hpp b/src/TNL/Containers/ArrayView.hpp index 199704a5a5a9095d56cbd8bde46eeefbfeab05b4..8c70b5c0548c38d2c473edcff4bd877ed2de9409 100644 --- a/src/TNL/Containers/ArrayView.hpp +++ b/src/TNL/Containers/ArrayView.hpp @@ -125,7 +125,7 @@ operator=( const ArrayView& view ) { TNL_ASSERT_EQ( getSize(), view.getSize(), "The sizes of the array views must be equal, views are not resizable." ); if( getSize() > 0 ) - Algorithms::ArrayOperations< Device >::copyMemory( getData(), view.getData(), getSize() ); + Algorithms::ArrayOperations< Device >::copy( getData(), view.getData(), getSize() ); return *this; } @@ -229,7 +229,7 @@ setElement( Index i, Value value ) { TNL_ASSERT_GE( i, 0, "Element index must be non-negative." ); TNL_ASSERT_LT( i, this->getSize(), "Element index is out of bounds." ); - return Algorithms::ArrayOperations< Device >::setMemoryElement( &data[ i ], value ); + return Algorithms::ArrayOperations< Device >::setElement( &data[ i ], value ); } template< typename Value, @@ -241,7 +241,7 @@ getElement( Index i ) const { TNL_ASSERT_GE( i, 0, "Element index must be non-negative." ); TNL_ASSERT_LT( i, this->getSize(), "Element index is out of bounds." ); - return Algorithms::ArrayOperations< Device >::getMemoryElement( &data[ i ] ); + return Algorithms::ArrayOperations< Device >::getElement( &data[ i ] ); } template< typename Value, @@ -282,7 +282,7 @@ operator==( const ArrayT& array ) const if( this->getSize() == 0 ) return true; return Algorithms::ArrayOperations< DeviceType, typename ArrayT::DeviceType >:: - compareMemory( this->getData(), + compare( this->getData(), array.getData(), array.getSize() ); } @@ -308,7 +308,7 @@ setValue( Value value, const Index begin, Index end ) TNL_ASSERT_GT( size, 0, "Attempted to set value to an empty array view." ); if( end == 0 ) end = this->getSize(); - Algorithms::ArrayOperations< Device >::setMemory( &getData()[ begin ], value, end - begin ); + Algorithms::ArrayOperations< Device >::set( &getData()[ begin ], value, end - begin ); } template< typename Value, diff --git a/src/TNL/Containers/VectorViewExpressions.h b/src/TNL/Containers/VectorViewExpressions.h index fc1e7749da6a96e4d9f20deee02e6e62d2097f54..01e0ae1bea7838d965b2f2b35afa384ea8e61b8b 100644 --- a/src/TNL/Containers/VectorViewExpressions.h +++ b/src/TNL/Containers/VectorViewExpressions.h @@ -136,9 +136,9 @@ bool operator==( const Containers::VectorView< Real1, Device1, Index >& a, const if( a.getSize() == 0 ) return true; return Containers::Algorithms::ArrayOperations< Device1, Device2 >:: - compareMemory( a.getData(), - b.getData(), - a.getSize() ); + compare( a.getData(), + b.getData(), + a.getSize() ); } //// @@ -163,9 +163,9 @@ bool operator!=( const Containers::VectorView< Real1, Device1, Index >& a, const if( a.getSize() == 0 ) return true; return !Containers::Algorithms::ArrayOperations< Device1, Device2 >:: - compareMemory( a.getData(), - b.getData(), - a.getSize() ); + compare( a.getData(), + b.getData(), + a.getSize() ); } //// diff --git a/src/TNL/Matrices/MatrixOperations.h b/src/TNL/Matrices/MatrixOperations.h index e3d7ed6e41d64355975b5a5c5e63ed25268b0ed9..07991a573662c7380d6fd2814b0a20db30e7dca8 100644 --- a/src/TNL/Matrices/MatrixOperations.h +++ b/src/TNL/Matrices/MatrixOperations.h @@ -341,7 +341,7 @@ public: // TODO: use static storage, e.g. from the CudaReductionBuffer, to avoid frequent reallocations Containers::Vector< RealType, Devices::Cuda, IndexType > xDevice; xDevice.setSize( n ); - Containers::Algorithms::ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory< RealType, RealType, IndexType >( xDevice.getData(), x, n ); + Containers::Algorithms::ArrayOperations< Devices::Cuda, Devices::Host >::copy< RealType, RealType, IndexType >( xDevice.getData(), x, n ); // desGridSize = blocksPerMultiprocessor * numberOfMultiprocessors const int desGridSize = 32 * Devices::CudaDeviceInfo::getCudaMultiprocessors( Devices::CudaDeviceInfo::getActiveDevice() ); diff --git a/src/TNL/Solvers/Linear/GMRES_impl.h b/src/TNL/Solvers/Linear/GMRES_impl.h index f877172fc285d1a9018168a709fdb0a1d7d74058..06b1295014839a353f1e1d69e285b4628d650984 100644 --- a/src/TNL/Solvers/Linear/GMRES_impl.h +++ b/src/TNL/Solvers/Linear/GMRES_impl.h @@ -460,7 +460,7 @@ hauseholder_apply_trunc( HostView out, // The upper (m+1)x(m+1) submatrix of Y is duplicated in the YL buffer, // which resides on host and is broadcasted from rank 0 to all processes. HostView YL_i( &YL[ i * (restarting_max + 1) ], restarting_max + 1 ); - Containers::Algorithms::ArrayOperations< Devices::Host, DeviceType >::copyMemory( YL_i.getData(), Traits::getLocalVectorView( y_i ).getData(), YL_i.getSize() ); + Containers::Algorithms::ArrayOperations< Devices::Host, DeviceType >::copy( YL_i.getData(), Traits::getLocalVectorView( y_i ).getData(), YL_i.getSize() ); // no-op if the problem is not distributed CommunicatorType::Bcast( YL_i.getData(), YL_i.getSize(), 0, Traits::getCommunicationGroup( *this->matrix ) ); @@ -475,7 +475,7 @@ hauseholder_apply_trunc( HostView out, } if( std::is_same< DeviceType, Devices::Cuda >::value ) { RealType host_z[ i + 1 ]; - Containers::Algorithms::ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory( host_z, Traits::getLocalVectorView( z ).getData(), i + 1 ); + Containers::Algorithms::ArrayOperations< Devices::Host, Devices::Cuda >::copy( host_z, Traits::getLocalVectorView( z ).getData(), i + 1 ); for( int k = 0; k <= i; k++ ) out[ k ] = host_z[ k ] - YL_i[ k ] * aux; } diff --git a/src/UnitTests/AllocatorsTest.h b/src/UnitTests/AllocatorsTest.h index e1d618ea5f814c73cd15163c7ba6ab326c4d42b3..5434a495085d38ad345f0ece4f530aba2184a6ba 100644 --- a/src/UnitTests/AllocatorsTest.h +++ b/src/UnitTests/AllocatorsTest.h @@ -83,7 +83,7 @@ TYPED_TEST( AllocatorsTest, CudaManaged ) ASSERT_NE( data, nullptr ); // set data on the device - Containers::Algorithms::ArrayOperations< Devices::Cuda >::setMemory( data, (ValueType) 0, ARRAY_TEST_SIZE ); + Containers::Algorithms::ArrayOperations< Devices::Cuda >::set( data, (ValueType) 0, ARRAY_TEST_SIZE ); ASSERT_NO_THROW( TNL_CHECK_CUDA_DEVICE ); // check values on the host @@ -103,7 +103,7 @@ TYPED_TEST( AllocatorsTest, Cuda ) ASSERT_NE( data, nullptr ); // set data on the device - Containers::Algorithms::ArrayOperations< Devices::Cuda >::setMemory( data, (ValueType) 0, ARRAY_TEST_SIZE ); + Containers::Algorithms::ArrayOperations< Devices::Cuda >::set( data, (ValueType) 0, ARRAY_TEST_SIZE ); ASSERT_NO_THROW( TNL_CHECK_CUDA_DEVICE ); allocator.deallocate( data, ARRAY_TEST_SIZE ); diff --git a/src/UnitTests/Containers/ArrayOperationsTest.h b/src/UnitTests/Containers/ArrayOperationsTest.h index 749cea3edc486c411ea306f313faeb13cf29a140..4a48261be0401eed2231a007d7e68dfed711cb2b 100644 --- a/src/UnitTests/Containers/ArrayOperationsTest.h +++ b/src/UnitTests/Containers/ArrayOperationsTest.h @@ -48,7 +48,7 @@ TYPED_TEST( ArrayOperationsTest, allocateMemory_host ) allocator.deallocate( data, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, setMemoryElement_host ) +TYPED_TEST( ArrayOperationsTest, setElement_host ) { using ValueType = typename TestFixture::ValueType; using Allocator = Allocators::Host< ValueType >; @@ -56,27 +56,27 @@ TYPED_TEST( ArrayOperationsTest, setMemoryElement_host ) Allocator allocator; ValueType* data = allocator.allocate( ARRAY_TEST_SIZE ); for( int i = 0; i < ARRAY_TEST_SIZE; i++ ) { - ArrayOperations< Devices::Host >::setMemoryElement( data + i, (ValueType) i ); + ArrayOperations< Devices::Host >::setElement( data + i, (ValueType) i ); EXPECT_EQ( data[ i ], i ); - EXPECT_EQ( ArrayOperations< Devices::Host >::getMemoryElement( data + i ), i ); + EXPECT_EQ( ArrayOperations< Devices::Host >::getElement( data + i ), i ); } allocator.deallocate( data, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, setMemory_host ) +TYPED_TEST( ArrayOperationsTest, set_host ) { using ValueType = typename TestFixture::ValueType; using Allocator = Allocators::Host< ValueType >; Allocator allocator; ValueType* data = allocator.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( data, (ValueType) 13, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::set( data, (ValueType) 13, ARRAY_TEST_SIZE ); for( int i = 0; i < ARRAY_TEST_SIZE; i ++ ) EXPECT_EQ( data[ i ], 13 ); allocator.deallocate( data, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, copyMemory_host ) +TYPED_TEST( ArrayOperationsTest, copy_host ) { using ValueType = typename TestFixture::ValueType; using Allocator = Allocators::Host< ValueType >; @@ -84,15 +84,15 @@ TYPED_TEST( ArrayOperationsTest, copyMemory_host ) Allocator allocator; ValueType* data1 = allocator.allocate( ARRAY_TEST_SIZE ); ValueType* data2 = allocator.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( data1, (ValueType) 13, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::copyMemory< ValueType, ValueType >( data2, data1, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::set( data1, (ValueType) 13, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::copy< ValueType, ValueType >( data2, data1, ARRAY_TEST_SIZE ); for( int i = 0; i < ARRAY_TEST_SIZE; i ++ ) EXPECT_EQ( data1[ i ], data2[ i ]); allocator.deallocate( data1, ARRAY_TEST_SIZE ); allocator.deallocate( data2, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, copyMemoryWithConversion_host ) +TYPED_TEST( ArrayOperationsTest, copyWithConversion_host ) { using Allocator1 = Allocators::Host< int >; using Allocator2 = Allocators::Host< float >; @@ -101,15 +101,15 @@ TYPED_TEST( ArrayOperationsTest, copyMemoryWithConversion_host ) Allocator2 allocator2; int* data1 = allocator1.allocate( ARRAY_TEST_SIZE ); float* data2 = allocator2.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( data1, 13, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::copyMemory< float, int >( data2, data1, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::set( data1, 13, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::copy< float, int >( data2, data1, ARRAY_TEST_SIZE ); for( int i = 0; i < ARRAY_TEST_SIZE; i ++ ) EXPECT_EQ( data1[ i ], data2[ i ] ); allocator1.deallocate( data1, ARRAY_TEST_SIZE ); allocator2.deallocate( data2, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, compareMemory_host ) +TYPED_TEST( ArrayOperationsTest, compare_host ) { using ValueType = typename TestFixture::ValueType; using Allocator = Allocators::Host< ValueType >; @@ -117,16 +117,16 @@ TYPED_TEST( ArrayOperationsTest, compareMemory_host ) Allocator allocator; ValueType* data1 = allocator.allocate( ARRAY_TEST_SIZE ); ValueType* data2 = allocator.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( data1, (ValueType) 7, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( data2, (ValueType) 0, ARRAY_TEST_SIZE ); - EXPECT_FALSE( ( ArrayOperations< Devices::Host >::compareMemory< ValueType, ValueType >( data1, data2, ARRAY_TEST_SIZE ) ) ); - ArrayOperations< Devices::Host >::setMemory( data2, (ValueType) 7, ARRAY_TEST_SIZE ); - EXPECT_TRUE( ( ArrayOperations< Devices::Host >::compareMemory< ValueType, ValueType >( data1, data2, ARRAY_TEST_SIZE ) ) ); + ArrayOperations< Devices::Host >::set( data1, (ValueType) 7, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::set( data2, (ValueType) 0, ARRAY_TEST_SIZE ); + EXPECT_FALSE( ( ArrayOperations< Devices::Host >::compare< ValueType, ValueType >( data1, data2, ARRAY_TEST_SIZE ) ) ); + ArrayOperations< Devices::Host >::set( data2, (ValueType) 7, ARRAY_TEST_SIZE ); + EXPECT_TRUE( ( ArrayOperations< Devices::Host >::compare< ValueType, ValueType >( data1, data2, ARRAY_TEST_SIZE ) ) ); allocator.deallocate( data1, ARRAY_TEST_SIZE ); allocator.deallocate( data2, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, compareMemoryWithConversion_host ) +TYPED_TEST( ArrayOperationsTest, compareWithConversion_host ) { using Allocator1 = Allocators::Host< int >; using Allocator2 = Allocators::Host< float >; @@ -135,11 +135,11 @@ TYPED_TEST( ArrayOperationsTest, compareMemoryWithConversion_host ) Allocator2 allocator2; int* data1 = allocator1.allocate( ARRAY_TEST_SIZE ); float* data2 = allocator2.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( data1, 7, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( data2, (float) 0.0, ARRAY_TEST_SIZE ); - EXPECT_FALSE( ( ArrayOperations< Devices::Host >::compareMemory< int, float >( data1, data2, ARRAY_TEST_SIZE ) ) ); - ArrayOperations< Devices::Host >::setMemory( data2, (float) 7.0, ARRAY_TEST_SIZE ); - EXPECT_TRUE( ( ArrayOperations< Devices::Host >::compareMemory< int, float >( data1, data2, ARRAY_TEST_SIZE ) ) ); + ArrayOperations< Devices::Host >::set( data1, 7, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::set( data2, (float) 0.0, ARRAY_TEST_SIZE ); + EXPECT_FALSE( ( ArrayOperations< Devices::Host >::compare< int, float >( data1, data2, ARRAY_TEST_SIZE ) ) ); + ArrayOperations< Devices::Host >::set( data2, (float) 7.0, ARRAY_TEST_SIZE ); + EXPECT_TRUE( ( ArrayOperations< Devices::Host >::compare< int, float >( data1, data2, ARRAY_TEST_SIZE ) ) ); allocator1.deallocate( data1, ARRAY_TEST_SIZE ); allocator2.deallocate( data2, ARRAY_TEST_SIZE ); } @@ -198,7 +198,7 @@ TYPED_TEST( ArrayOperationsTest, allocateMemory_cuda ) ASSERT_NO_THROW( TNL_CHECK_CUDA_DEVICE ); } -TYPED_TEST( ArrayOperationsTest, setMemoryElement_cuda ) +TYPED_TEST( ArrayOperationsTest, setElement_cuda ) { using ValueType = typename TestFixture::ValueType; using Allocator = Allocators::Cuda< ValueType >; @@ -208,21 +208,21 @@ TYPED_TEST( ArrayOperationsTest, setMemoryElement_cuda ) ASSERT_NO_THROW( TNL_CHECK_CUDA_DEVICE ); for( int i = 0; i < ARRAY_TEST_SIZE; i++ ) - ArrayOperations< Devices::Cuda >::setMemoryElement( &data[ i ], (ValueType) i ); + ArrayOperations< Devices::Cuda >::setElement( &data[ i ], (ValueType) i ); for( int i = 0; i < ARRAY_TEST_SIZE; i++ ) { ValueType d; ASSERT_EQ( cudaMemcpy( &d, &data[ i ], sizeof( ValueType ), cudaMemcpyDeviceToHost ), cudaSuccess ); EXPECT_EQ( d, i ); - EXPECT_EQ( ArrayOperations< Devices::Cuda >::getMemoryElement( &data[ i ] ), i ); + EXPECT_EQ( ArrayOperations< Devices::Cuda >::getElement( &data[ i ] ), i ); } allocator.deallocate( data, ARRAY_TEST_SIZE ); ASSERT_NO_THROW( TNL_CHECK_CUDA_DEVICE ); } -TYPED_TEST( ArrayOperationsTest, setMemory_cuda ) +TYPED_TEST( ArrayOperationsTest, set_cuda ) { using ValueType = typename TestFixture::ValueType; using HostAllocator = Allocators::Host< ValueType >; @@ -232,10 +232,10 @@ TYPED_TEST( ArrayOperationsTest, setMemory_cuda ) CudaAllocator cudaAllocator; ValueType* hostData = hostAllocator.allocate( ARRAY_TEST_SIZE ); ValueType* deviceData = cudaAllocator.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( hostData, (ValueType) 0, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::setMemory( deviceData, (ValueType) 13, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::set( hostData, (ValueType) 0, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::set( deviceData, (ValueType) 13, ARRAY_TEST_SIZE ); ASSERT_NO_THROW( TNL_CHECK_CUDA_DEVICE ); - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory< ValueType, ValueType >( hostData, deviceData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy< ValueType, ValueType >( hostData, deviceData, ARRAY_TEST_SIZE ); ASSERT_NO_THROW( TNL_CHECK_CUDA_DEVICE ); for( int i = 0; i < ARRAY_TEST_SIZE; i++ ) EXPECT_EQ( hostData[ i ], 13 ); @@ -243,7 +243,7 @@ TYPED_TEST( ArrayOperationsTest, setMemory_cuda ) cudaAllocator.deallocate( deviceData, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, copyMemory_cuda ) +TYPED_TEST( ArrayOperationsTest, copy_cuda ) { using ValueType = typename TestFixture::ValueType; using HostAllocator = Allocators::Host< ValueType >; @@ -255,18 +255,18 @@ TYPED_TEST( ArrayOperationsTest, copyMemory_cuda ) ValueType* hostData2 = hostAllocator.allocate( ARRAY_TEST_SIZE ); ValueType* deviceData = cudaAllocator.allocate( ARRAY_TEST_SIZE ); ValueType* deviceData2 = cudaAllocator.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( hostData, (ValueType) 13, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory< ValueType >( deviceData, hostData, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::copyMemory< ValueType, ValueType >( deviceData2, deviceData, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory< ValueType, ValueType >( hostData2, deviceData2, ARRAY_TEST_SIZE ); - EXPECT_TRUE( ( ArrayOperations< Devices::Host >::compareMemory< ValueType, ValueType >( hostData, hostData2, ARRAY_TEST_SIZE) ) ); + ArrayOperations< Devices::Host >::set( hostData, (ValueType) 13, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda, Devices::Host >::copy< ValueType >( deviceData, hostData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::copy< ValueType, ValueType >( deviceData2, deviceData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy< ValueType, ValueType >( hostData2, deviceData2, ARRAY_TEST_SIZE ); + EXPECT_TRUE( ( ArrayOperations< Devices::Host >::compare< ValueType, ValueType >( hostData, hostData2, ARRAY_TEST_SIZE) ) ); hostAllocator.deallocate( hostData, ARRAY_TEST_SIZE ); hostAllocator.deallocate( hostData2, ARRAY_TEST_SIZE ); cudaAllocator.deallocate( deviceData, ARRAY_TEST_SIZE ); cudaAllocator.deallocate( deviceData2, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, copyMemoryWithConversions_cuda ) +TYPED_TEST( ArrayOperationsTest, copyWithConversions_cuda ) { using HostAllocator1 = Allocators::Host< int >; using HostAllocator2 = Allocators::Host< double >; @@ -281,10 +281,10 @@ TYPED_TEST( ArrayOperationsTest, copyMemoryWithConversions_cuda ) double* hostData2 = hostAllocator2.allocate( ARRAY_TEST_SIZE ); long* deviceData = cudaAllocator1.allocate( ARRAY_TEST_SIZE ); float* deviceData2 = cudaAllocator2.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( hostData, 13, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory< long, int >( deviceData, hostData, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::copyMemory< float, long >( deviceData2, deviceData, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory< double, float >( hostData2, deviceData2, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host >::set( hostData, 13, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda, Devices::Host >::copy< long, int >( deviceData, hostData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::copy< float, long >( deviceData2, deviceData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Host, Devices::Cuda >::copy< double, float >( hostData2, deviceData2, ARRAY_TEST_SIZE ); for( int i = 0; i < ARRAY_TEST_SIZE; i ++ ) EXPECT_EQ( hostData[ i ], hostData2[ i ] ); hostAllocator1.deallocate( hostData, ARRAY_TEST_SIZE ); @@ -293,7 +293,7 @@ TYPED_TEST( ArrayOperationsTest, copyMemoryWithConversions_cuda ) cudaAllocator2.deallocate( deviceData2, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, compareMemory_cuda ) +TYPED_TEST( ArrayOperationsTest, compare_cuda ) { using ValueType = typename TestFixture::ValueType; using HostAllocator = Allocators::Host< ValueType >; @@ -305,25 +305,25 @@ TYPED_TEST( ArrayOperationsTest, compareMemory_cuda ) ValueType* deviceData = cudaAllocator.allocate( ARRAY_TEST_SIZE ); ValueType* deviceData2 = cudaAllocator.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( hostData, (ValueType) 7, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::setMemory( deviceData, (ValueType) 8, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::setMemory( deviceData2, (ValueType) 9, ARRAY_TEST_SIZE ); - EXPECT_FALSE(( ArrayOperations< Devices::Host, Devices::Cuda >::compareMemory< ValueType, ValueType >( hostData, deviceData, ARRAY_TEST_SIZE ) )); - EXPECT_FALSE(( ArrayOperations< Devices::Cuda, Devices::Host >::compareMemory< ValueType, ValueType >( deviceData, hostData, ARRAY_TEST_SIZE ) )); - EXPECT_FALSE(( ArrayOperations< Devices::Cuda >::compareMemory< ValueType, ValueType >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); + ArrayOperations< Devices::Host >::set( hostData, (ValueType) 7, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::set( deviceData, (ValueType) 8, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::set( deviceData2, (ValueType) 9, ARRAY_TEST_SIZE ); + EXPECT_FALSE(( ArrayOperations< Devices::Host, Devices::Cuda >::compare< ValueType, ValueType >( hostData, deviceData, ARRAY_TEST_SIZE ) )); + EXPECT_FALSE(( ArrayOperations< Devices::Cuda, Devices::Host >::compare< ValueType, ValueType >( deviceData, hostData, ARRAY_TEST_SIZE ) )); + EXPECT_FALSE(( ArrayOperations< Devices::Cuda >::compare< ValueType, ValueType >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); - ArrayOperations< Devices::Cuda >::setMemory( deviceData, (ValueType) 7, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::setMemory( deviceData2, (ValueType) 7, ARRAY_TEST_SIZE ); - EXPECT_TRUE(( ArrayOperations< Devices::Host, Devices::Cuda >::compareMemory< ValueType, ValueType >( hostData, deviceData, ARRAY_TEST_SIZE ) )); - EXPECT_TRUE(( ArrayOperations< Devices::Cuda, Devices::Host >::compareMemory< ValueType, ValueType >( deviceData, hostData, ARRAY_TEST_SIZE ) )); - EXPECT_TRUE(( ArrayOperations< Devices::Cuda >::compareMemory< ValueType, ValueType >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); + ArrayOperations< Devices::Cuda >::set( deviceData, (ValueType) 7, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::set( deviceData2, (ValueType) 7, ARRAY_TEST_SIZE ); + EXPECT_TRUE(( ArrayOperations< Devices::Host, Devices::Cuda >::compare< ValueType, ValueType >( hostData, deviceData, ARRAY_TEST_SIZE ) )); + EXPECT_TRUE(( ArrayOperations< Devices::Cuda, Devices::Host >::compare< ValueType, ValueType >( deviceData, hostData, ARRAY_TEST_SIZE ) )); + EXPECT_TRUE(( ArrayOperations< Devices::Cuda >::compare< ValueType, ValueType >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); hostAllocator.deallocate( hostData, ARRAY_TEST_SIZE ); cudaAllocator.deallocate( deviceData, ARRAY_TEST_SIZE ); cudaAllocator.deallocate( deviceData2, ARRAY_TEST_SIZE ); } -TYPED_TEST( ArrayOperationsTest, compareMemoryWithConversions_cuda ) +TYPED_TEST( ArrayOperationsTest, compareWithConversions_cuda ) { using HostAllocator = Allocators::Host< int >; using CudaAllocator1 = Allocators::Cuda< float >; @@ -336,18 +336,18 @@ TYPED_TEST( ArrayOperationsTest, compareMemoryWithConversions_cuda ) float* deviceData = cudaAllocator1.allocate( ARRAY_TEST_SIZE ); double* deviceData2 = cudaAllocator2.allocate( ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Host >::setMemory( hostData, 7, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::setMemory( deviceData, (float) 8, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::setMemory( deviceData2, (double) 9, ARRAY_TEST_SIZE ); - EXPECT_FALSE(( ArrayOperations< Devices::Host, Devices::Cuda >::compareMemory< int, float >( hostData, deviceData, ARRAY_TEST_SIZE ) )); - EXPECT_FALSE(( ArrayOperations< Devices::Cuda, Devices::Host >::compareMemory< float, int >( deviceData, hostData, ARRAY_TEST_SIZE ) )); - EXPECT_FALSE(( ArrayOperations< Devices::Cuda >::compareMemory< float, double >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); + ArrayOperations< Devices::Host >::set( hostData, 7, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::set( deviceData, (float) 8, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::set( deviceData2, (double) 9, ARRAY_TEST_SIZE ); + EXPECT_FALSE(( ArrayOperations< Devices::Host, Devices::Cuda >::compare< int, float >( hostData, deviceData, ARRAY_TEST_SIZE ) )); + EXPECT_FALSE(( ArrayOperations< Devices::Cuda, Devices::Host >::compare< float, int >( deviceData, hostData, ARRAY_TEST_SIZE ) )); + EXPECT_FALSE(( ArrayOperations< Devices::Cuda >::compare< float, double >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); - ArrayOperations< Devices::Cuda >::setMemory( deviceData, (float) 7, ARRAY_TEST_SIZE ); - ArrayOperations< Devices::Cuda >::setMemory( deviceData2, (double) 7, ARRAY_TEST_SIZE ); - EXPECT_TRUE(( ArrayOperations< Devices::Host, Devices::Cuda >::compareMemory< int, float >( hostData, deviceData, ARRAY_TEST_SIZE ) )); - EXPECT_TRUE(( ArrayOperations< Devices::Cuda, Devices::Host >::compareMemory< float, int >( deviceData, hostData, ARRAY_TEST_SIZE ) )); - EXPECT_TRUE(( ArrayOperations< Devices::Cuda >::compareMemory< float, double >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); + ArrayOperations< Devices::Cuda >::set( deviceData, (float) 7, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda >::set( deviceData2, (double) 7, ARRAY_TEST_SIZE ); + EXPECT_TRUE(( ArrayOperations< Devices::Host, Devices::Cuda >::compare< int, float >( hostData, deviceData, ARRAY_TEST_SIZE ) )); + EXPECT_TRUE(( ArrayOperations< Devices::Cuda, Devices::Host >::compare< float, int >( deviceData, hostData, ARRAY_TEST_SIZE ) )); + EXPECT_TRUE(( ArrayOperations< Devices::Cuda >::compare< float, double >( deviceData, deviceData2, ARRAY_TEST_SIZE ) )); hostAllocator.deallocate( hostData, ARRAY_TEST_SIZE ); cudaAllocator1.deallocate( deviceData, ARRAY_TEST_SIZE ); @@ -367,7 +367,7 @@ TYPED_TEST( ArrayOperationsTest, containsValue_cuda ) for( int i = 0; i < ARRAY_TEST_SIZE; i++ ) hostData[ i ] = i % 10; - ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( deviceData, hostData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda, Devices::Host >::copy( deviceData, hostData, ARRAY_TEST_SIZE ); for( int i = 0; i < 10; i++ ) EXPECT_TRUE( ( ArrayOperations< Devices::Cuda >::containsValue( deviceData, ARRAY_TEST_SIZE, (ValueType) i ) ) ); @@ -391,14 +391,14 @@ TYPED_TEST( ArrayOperationsTest, containsOnlyValue_cuda ) for( int i = 0; i < ARRAY_TEST_SIZE; i++ ) hostData[ i ] = i % 10; - ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( deviceData, hostData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda, Devices::Host >::copy( deviceData, hostData, ARRAY_TEST_SIZE ); for( int i = 0; i < 20; i++ ) EXPECT_FALSE( ( ArrayOperations< Devices::Cuda >::containsOnlyValue( deviceData, ARRAY_TEST_SIZE, (ValueType) i ) ) ); for( int i = 0; i < ARRAY_TEST_SIZE; i++ ) hostData[ i ] = 10; - ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( deviceData, hostData, ARRAY_TEST_SIZE ); + ArrayOperations< Devices::Cuda, Devices::Host >::copy( deviceData, hostData, ARRAY_TEST_SIZE ); EXPECT_TRUE( ( ArrayOperations< Devices::Cuda >::containsOnlyValue( deviceData, ARRAY_TEST_SIZE, (ValueType) 10 ) ) );