Loading src/TNL/Containers/Algorithms/ArrayOperations.h +2 −0 Original line number Diff line number Diff line Loading @@ -81,10 +81,12 @@ class ArrayOperations< Devices::Cuda > static void freeMemory( Element* data ); template< typename Element > __cuda_callable__ static void setMemoryElement( Element* data, const Element& value ); template< typename Element > __cuda_callable__ static Element getMemoryElement( const Element* data ); // TODO: does not make sense for CUDA - remove? Loading src/TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h +10 −2 Original line number Diff line number Diff line Loading @@ -60,24 +60,32 @@ freeMemory( Element* data ) } template< typename Element > void __cuda_callable__ void ArrayOperations< Devices::Cuda >:: setMemoryElement( Element* data, const Element& value ) { TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); #ifdef __CUDAARCH__ *data = value; #else ArrayOperations< Devices::Cuda >::setMemory( data, value, 1 ); #endif } template< typename Element > Element __cuda_callable__ Element ArrayOperations< Devices::Cuda >:: getMemoryElement( const Element* data ) { TNL_ASSERT_TRUE( data, "Attempted to get data through a nullptr." ); #ifdef __CUDAARCH__ return *data; #else Element result; ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory< Element, Element, int >( &result, data, 1 ); return result; #endif } template< typename Element, typename Index > Loading src/TNL/Containers/StaticVector.h +18 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,10 @@ class StaticVector : public StaticArray< Size, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Addition operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading Loading @@ -156,6 +160,10 @@ class StaticVector< 1, Real > : public StaticArray< 1, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Addition operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading Loading @@ -257,6 +265,10 @@ class StaticVector< 2, Real > : public StaticArray< 2, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Adding operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading Loading @@ -358,6 +370,11 @@ class StaticVector< 3, Real > : public StaticArray< 3, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Addition operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading src/TNL/Containers/StaticVector1D_impl.h +8 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ StaticVector< 1, Real >& StaticVector< 1, Real >::operator *= ( const Real& c ) return *this; } template< typename Real > __cuda_callable__ StaticVector< 1, Real >& StaticVector< 1, Real >::operator /= ( const Real& c ) { this->data[ 0 ] /= c; return *this; } template< typename Real > __cuda_callable__ StaticVector< 1, Real > StaticVector< 1, Real >::operator + ( const StaticVector& u ) const Loading src/TNL/Containers/StaticVector2D_impl.h +10 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,16 @@ StaticVector< 2, Real >& StaticVector< 2, Real >::operator *= ( const Real& c ) return *this; } template< typename Real > __cuda_callable__ StaticVector< 2, Real >& StaticVector< 2, Real >::operator /= ( const Real& c ) { const RealType d = 1.0 /c; this->data[ 0 ] *= d; this->data[ 1 ] *= d; return *this; } template< typename Real > __cuda_callable__ StaticVector< 2, Real > StaticVector< 2, Real >::operator + ( const StaticVector& u ) const Loading Loading
src/TNL/Containers/Algorithms/ArrayOperations.h +2 −0 Original line number Diff line number Diff line Loading @@ -81,10 +81,12 @@ class ArrayOperations< Devices::Cuda > static void freeMemory( Element* data ); template< typename Element > __cuda_callable__ static void setMemoryElement( Element* data, const Element& value ); template< typename Element > __cuda_callable__ static Element getMemoryElement( const Element* data ); // TODO: does not make sense for CUDA - remove? Loading
src/TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h +10 −2 Original line number Diff line number Diff line Loading @@ -60,24 +60,32 @@ freeMemory( Element* data ) } template< typename Element > void __cuda_callable__ void ArrayOperations< Devices::Cuda >:: setMemoryElement( Element* data, const Element& value ) { TNL_ASSERT_TRUE( data, "Attempted to set data through a nullptr." ); #ifdef __CUDAARCH__ *data = value; #else ArrayOperations< Devices::Cuda >::setMemory( data, value, 1 ); #endif } template< typename Element > Element __cuda_callable__ Element ArrayOperations< Devices::Cuda >:: getMemoryElement( const Element* data ) { TNL_ASSERT_TRUE( data, "Attempted to get data through a nullptr." ); #ifdef __CUDAARCH__ return *data; #else Element result; ArrayOperations< Devices::Host, Devices::Cuda >::copyMemory< Element, Element, int >( &result, data, 1 ); return result; #endif } template< typename Element, typename Index > Loading
src/TNL/Containers/StaticVector.h +18 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,10 @@ class StaticVector : public StaticArray< Size, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Addition operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading Loading @@ -156,6 +160,10 @@ class StaticVector< 1, Real > : public StaticArray< 1, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Addition operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading Loading @@ -257,6 +265,10 @@ class StaticVector< 2, Real > : public StaticArray< 2, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Adding operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading Loading @@ -358,6 +370,11 @@ class StaticVector< 3, Real > : public StaticArray< 3, Real > __cuda_callable__ StaticVector& operator *= ( const Real& c ); //! Division by number __cuda_callable__ StaticVector& operator /= ( const Real& c ); //! Addition operator __cuda_callable__ StaticVector operator + ( const StaticVector& u ) const; Loading
src/TNL/Containers/StaticVector1D_impl.h +8 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ StaticVector< 1, Real >& StaticVector< 1, Real >::operator *= ( const Real& c ) return *this; } template< typename Real > __cuda_callable__ StaticVector< 1, Real >& StaticVector< 1, Real >::operator /= ( const Real& c ) { this->data[ 0 ] /= c; return *this; } template< typename Real > __cuda_callable__ StaticVector< 1, Real > StaticVector< 1, Real >::operator + ( const StaticVector& u ) const Loading
src/TNL/Containers/StaticVector2D_impl.h +10 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,16 @@ StaticVector< 2, Real >& StaticVector< 2, Real >::operator *= ( const Real& c ) return *this; } template< typename Real > __cuda_callable__ StaticVector< 2, Real >& StaticVector< 2, Real >::operator /= ( const Real& c ) { const RealType d = 1.0 /c; this->data[ 0 ] *= d; this->data[ 1 ] *= d; return *this; } template< typename Real > __cuda_callable__ StaticVector< 2, Real > StaticVector< 2, Real >::operator + ( const StaticVector& u ) const Loading