Loading src/core/tnlCuda.h +18 −3 Original line number Diff line number Diff line Loading @@ -79,9 +79,12 @@ class tnlCuda abort(); } template< typename Element, typename Index, typename Device > static bool memcpy( Element* destination, const Element* source, template< typename DestinationElement, typename SourceElement, typename Index, typename Device > static bool memcpy( DestinationElement* destination, const SourceElement* source, const Index size ) { switch( Device :: getDevice() ) Loading @@ -94,6 +97,18 @@ class tnlCuda return true; } template< typename Element, typename Index, typename Device > static bool memcpy( Element* destination, const Element* source, const Index size ) { return tnlCuda :: memcpy< Element, Element, Index, Device > ( destination, source, size ); } template< typename Element, typename Index, typename Device > static bool memcmp( const Element* data1, const Element* data2, Loading src/core/tnlHost.h +7 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,11 @@ class tnlHost template< typename Element, typename Index > static const Element& getArrayElementReference(const Element* data, const Index i ); template< typename DestinationElement, typename SourceElement, typename Index, typename Device > static bool memcpy( DestinationElement* destination, const SourceElement* source, const Index size ); template< typename Element, typename Index, typename Device > static bool memcpy( Element* destination, const Element* source, Loading src/implementation/core/memory-operations.h +39 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <core/cuda/reduction-operations.h> #include <core/mfuncs.h> #include <tnlConfig.h> #include <string.h> const int tnlGPUvsCPUTransferBufferSize( 1 << 20 ); Loading Loading @@ -115,16 +116,26 @@ bool setMemoryCuda( Element* data, } template< typename DestinationElement, typename SourceElement, typename Index > bool copyMemoryHostToHost( DestinationElement* destination, const SourceElement* source, const Index size ) { for( Index i = 0; i < size; i ++ ) destination[ i ] = ( DestinationElement) source[ i ]; return true; } template< typename Element, typename Index > bool copyMemoryHostToHost( Element* destination, const Element* source, const Index size ) { for( Index i = 0; i < size; i ++ ) destination[ i ] = source[ i ]; memcpy( destination, source, size * sizeof( Element ) ); return true; } template< typename Element, typename Index > bool copyMemoryHostToCuda( Element* destination, const Element* source, Loading Loading @@ -170,6 +181,32 @@ bool copyMemoryCudaToHost( Element* destination, #endif } template< typename DestinationElement, typename SourceElement, typename Index > bool copyMemoryCudaToHost( DestinationElement* destination, const SourceElement* source, const Index size ) { #ifdef HAVE_CUDA abort(); // TODO: fix this cudaMemcpy( destination, source, size * sizeof( Element ), cudaMemcpyDeviceToHost ); if( ! checkCudaDevice ) { cerr << "Transfer of data from CUDA device to host failed." << endl; return false; } return true; #else cerr << "CUDA support is missing on this system " << __FILE__ << " line " << __LINE__ << "." << endl; return false; #endif } template< typename Element, typename Index > bool copyMemoryCudaToCuda( Element* destination, const Element* source, Loading src/implementation/core/tnlArray_impl.h +4 −3 Original line number Diff line number Diff line Loading @@ -213,7 +213,8 @@ tnlArray< Element, Device, Index >& << "Source size: " << array. getSize() << endl << "Target name: " << this -> getName() << endl << "Target size: " << this -> getSize() << endl ); Device :: template memcpy< typename Array :: ElementType, Device :: template memcpy< Element, typename Array :: ElementType, typename Array :: IndexType, typename Array :: DeviceType > ( this -> getData(), Loading src/implementation/core/tnlHost_impl.cpp +24 −24 Original line number Diff line number Diff line Loading @@ -80,30 +80,30 @@ template const float& tnlHost :: getArrayElementReference< float, lo template const double& tnlHost :: getArrayElementReference< double, long int >( const double* data, const long int i ); template const long double& tnlHost :: getArrayElementReference< long double, long int >( const long double* data, const long int i ); template bool tnlHost :: memcpy< char, int, tnlHost >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, tnlHost >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, int, tnlHost >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, int, tnlHost >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, int, tnlHost >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, int, tnlHost >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, long int, tnlHost >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, long int, tnlHost >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, tnlHost >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, long int, tnlHost >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, long int, tnlHost >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long int, tnlHost >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcpy< char, int, tnlCuda >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, tnlCuda >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, int, tnlCuda >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, int, tnlCuda >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, int, tnlCuda >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, int, tnlCuda >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, long int, tnlCuda >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, long int, tnlCuda >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, tnlCuda >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, long int, tnlCuda >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, long int, tnlCuda >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long int, tnlCuda >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcpy< char, char, int, tnlHost >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, int, tnlHost >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, long int, int, tnlHost >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, float, int, tnlHost >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, double, int, tnlHost >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, long double, int, tnlHost >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, char, long int, tnlHost >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, int, long int, tnlHost >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, long int, tnlHost >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, float, long int, tnlHost >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, double, long int, tnlHost >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long double, long int, tnlHost >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcpy< char, char, int, tnlCuda >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, int, tnlCuda >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, long int, int, tnlCuda >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, float, int, tnlCuda >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, double, int, tnlCuda >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, long double, int, tnlCuda >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, char, long int, tnlCuda >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, int, long int, tnlCuda >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, long int, tnlCuda >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, float, long int, tnlCuda >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, double, long int, tnlCuda >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long double, long int, tnlCuda >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcmp< char, int, tnlHost >( const char* data1, const char* data2, const int size ); template bool tnlHost :: memcmp< int, int, tnlHost >( const int* data1, const int* data2, const int size ); Loading Loading
src/core/tnlCuda.h +18 −3 Original line number Diff line number Diff line Loading @@ -79,9 +79,12 @@ class tnlCuda abort(); } template< typename Element, typename Index, typename Device > static bool memcpy( Element* destination, const Element* source, template< typename DestinationElement, typename SourceElement, typename Index, typename Device > static bool memcpy( DestinationElement* destination, const SourceElement* source, const Index size ) { switch( Device :: getDevice() ) Loading @@ -94,6 +97,18 @@ class tnlCuda return true; } template< typename Element, typename Index, typename Device > static bool memcpy( Element* destination, const Element* source, const Index size ) { return tnlCuda :: memcpy< Element, Element, Index, Device > ( destination, source, size ); } template< typename Element, typename Index, typename Device > static bool memcmp( const Element* data1, const Element* data2, Loading
src/core/tnlHost.h +7 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,11 @@ class tnlHost template< typename Element, typename Index > static const Element& getArrayElementReference(const Element* data, const Index i ); template< typename DestinationElement, typename SourceElement, typename Index, typename Device > static bool memcpy( DestinationElement* destination, const SourceElement* source, const Index size ); template< typename Element, typename Index, typename Device > static bool memcpy( Element* destination, const Element* source, Loading
src/implementation/core/memory-operations.h +39 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <core/cuda/reduction-operations.h> #include <core/mfuncs.h> #include <tnlConfig.h> #include <string.h> const int tnlGPUvsCPUTransferBufferSize( 1 << 20 ); Loading Loading @@ -115,16 +116,26 @@ bool setMemoryCuda( Element* data, } template< typename DestinationElement, typename SourceElement, typename Index > bool copyMemoryHostToHost( DestinationElement* destination, const SourceElement* source, const Index size ) { for( Index i = 0; i < size; i ++ ) destination[ i ] = ( DestinationElement) source[ i ]; return true; } template< typename Element, typename Index > bool copyMemoryHostToHost( Element* destination, const Element* source, const Index size ) { for( Index i = 0; i < size; i ++ ) destination[ i ] = source[ i ]; memcpy( destination, source, size * sizeof( Element ) ); return true; } template< typename Element, typename Index > bool copyMemoryHostToCuda( Element* destination, const Element* source, Loading Loading @@ -170,6 +181,32 @@ bool copyMemoryCudaToHost( Element* destination, #endif } template< typename DestinationElement, typename SourceElement, typename Index > bool copyMemoryCudaToHost( DestinationElement* destination, const SourceElement* source, const Index size ) { #ifdef HAVE_CUDA abort(); // TODO: fix this cudaMemcpy( destination, source, size * sizeof( Element ), cudaMemcpyDeviceToHost ); if( ! checkCudaDevice ) { cerr << "Transfer of data from CUDA device to host failed." << endl; return false; } return true; #else cerr << "CUDA support is missing on this system " << __FILE__ << " line " << __LINE__ << "." << endl; return false; #endif } template< typename Element, typename Index > bool copyMemoryCudaToCuda( Element* destination, const Element* source, Loading
src/implementation/core/tnlArray_impl.h +4 −3 Original line number Diff line number Diff line Loading @@ -213,7 +213,8 @@ tnlArray< Element, Device, Index >& << "Source size: " << array. getSize() << endl << "Target name: " << this -> getName() << endl << "Target size: " << this -> getSize() << endl ); Device :: template memcpy< typename Array :: ElementType, Device :: template memcpy< Element, typename Array :: ElementType, typename Array :: IndexType, typename Array :: DeviceType > ( this -> getData(), Loading
src/implementation/core/tnlHost_impl.cpp +24 −24 Original line number Diff line number Diff line Loading @@ -80,30 +80,30 @@ template const float& tnlHost :: getArrayElementReference< float, lo template const double& tnlHost :: getArrayElementReference< double, long int >( const double* data, const long int i ); template const long double& tnlHost :: getArrayElementReference< long double, long int >( const long double* data, const long int i ); template bool tnlHost :: memcpy< char, int, tnlHost >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, tnlHost >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, int, tnlHost >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, int, tnlHost >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, int, tnlHost >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, int, tnlHost >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, long int, tnlHost >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, long int, tnlHost >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, tnlHost >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, long int, tnlHost >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, long int, tnlHost >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long int, tnlHost >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcpy< char, int, tnlCuda >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, tnlCuda >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, int, tnlCuda >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, int, tnlCuda >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, int, tnlCuda >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, int, tnlCuda >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, long int, tnlCuda >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, long int, tnlCuda >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, tnlCuda >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, long int, tnlCuda >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, long int, tnlCuda >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long int, tnlCuda >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcpy< char, char, int, tnlHost >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, int, tnlHost >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, long int, int, tnlHost >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, float, int, tnlHost >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, double, int, tnlHost >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, long double, int, tnlHost >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, char, long int, tnlHost >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, int, long int, tnlHost >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, long int, tnlHost >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, float, long int, tnlHost >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, double, long int, tnlHost >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long double, long int, tnlHost >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcpy< char, char, int, tnlCuda >( char* destination, const char* source, const int size ); template bool tnlHost :: memcpy< int, int, int, tnlCuda >( int* destination, const int* source, const int size ); template bool tnlHost :: memcpy< long int, long int, int, tnlCuda >( long int* destination, const long int* source, const int size ); template bool tnlHost :: memcpy< float, float, int, tnlCuda >( float* destination, const float* source, const int size ); template bool tnlHost :: memcpy< double, double, int, tnlCuda >( double* destination, const double* source, const int size ); template bool tnlHost :: memcpy< long double, long double, int, tnlCuda >( long double* destination, const long double* source, const int size ); template bool tnlHost :: memcpy< char, char, long int, tnlCuda >( char* destination, const char* source, const long int size ); template bool tnlHost :: memcpy< int, int, long int, tnlCuda >( int* destination, const int* source, const long int size ); template bool tnlHost :: memcpy< long int, long int, long int, tnlCuda >( long int* destination, const long int* source, const long int size ); template bool tnlHost :: memcpy< float, float, long int, tnlCuda >( float* destination, const float* source, const long int size ); template bool tnlHost :: memcpy< double, double, long int, tnlCuda >( double* destination, const double* source, const long int size ); template bool tnlHost :: memcpy< long double, long double, long int, tnlCuda >( long double* destination, const long double* source, const long int size ); template bool tnlHost :: memcmp< char, int, tnlHost >( const char* data1, const char* data2, const int size ); template bool tnlHost :: memcmp< int, int, tnlHost >( const int* data1, const int* data2, const int size ); Loading