diff --git a/src/core/arrays/CMakeLists.txt b/src/core/arrays/CMakeLists.txt index 519dea4e2ff6eb468af5caef24e8663d5ee6e21b..d922e8e7127b18fc1660a67f57eafbd974cfe72c 100755 --- a/src/core/arrays/CMakeLists.txt +++ b/src/core/arrays/CMakeLists.txt @@ -1,4 +1,5 @@ set( headers tnlArray.h + tnlArrayOperations.h tnlMultiArray.h tnlSharedArray.h ) diff --git a/src/core/arrays/tnlArrayOperations.h b/src/core/arrays/tnlArrayOperations.h new file mode 100644 index 0000000000000000000000000000000000000000..5101b73cdc8dfcf0590bdcf2eebcc15224ded60c --- /dev/null +++ b/src/core/arrays/tnlArrayOperations.h @@ -0,0 +1,154 @@ +/*************************************************************************** + tnlArrayOperationsTest.cpp - description + ------------------- + begin : Jul 15, 2013 + copyright : (C) 2013 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLARRAYOPERATIONS_H_ +#define TNLARRAYOPERATIONS_H_ + +#include <core/tnlHost.h> +#include <core/tnlCuda.h> + +template< typename Device > +class tnlArrayOperations{}; + +template<> +class tnlArrayOperations< tnlHost > +{ + public: + + template< typename Element, typename Index > + static bool allocateMemory( Element*& data, + const Index size ); + + template< typename Element > + bool freeMemory( Element* data ); + + template< typename Element, typename Index > + bool setMemory( Element* data, + const Element& value, + const Index size ); + + template< typename DestinationElement, typename SourceElement, typename Index > + bool copyMemoryToHost( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename Element, typename Index > + bool copyMemoryToHost( Element* destination, + const Element* source, + const Index size ); + + template< typename DestinationElement, typename SourceElement, typename Index > + bool copyMemoryToCuda( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename Element, typename Index > + bool copyMemoryToCuda( Element* destination, + const Element* source, + const Index size ); + + template< typename Element, + typename Index > + bool compareMemoryOnHost( const Element* data1, + const Element* data2, + const Index size ); + + template< typename Element1, + typename Element2, + typename Index > + bool compareMemoryOnHost( const Element1* data1, + const Element2* data2, + const Index size ); + + template< typename Element1, + typename Element2, + typename Index > + bool compareMemoryOnCuda( const Element1* hostData, + const Element2* deviceData, + const Index size ); + template< typename Element, + typename Index > + bool compareMemoryOnCuda( const Element* deviceData1, + const Element* deviceData2, + const Index size ); +}; + +template<> +class tnlArrayOperations< tnlCuda > +{ + public: + + template< typename Element, typename Index > + static bool allocateMemory( Element*& data, + const Index size ); + + template< typename Element > + bool freeMemory( Element* data ); + + template< typename Element, typename Index > + bool setMemory( Element* data, + const Element& value, + const Index size ); + + template< typename DestinationElement, typename SourceElement, typename Index > + bool copyMemoryToHost( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename Element, typename Index > + bool copyMemoryToHost( Element* destination, + const Element* source, + const Index size ); + + template< typename DestinationElement, typename SourceElement, typename Index > + bool copyMemoryToCuda( DestinationElement* destination, + const SourceElement* source, + const Index size ); + + template< typename Element, typename Index > + bool copyMemoryToCuda( Element* destination, + const Element* source, + const Index size ); + + template< typename Element, + typename Index > + bool compareMemoryOnHost( const Element* data1, + const Element* data2, + const Index size ); + + template< typename Element1, + typename Element2, + typename Index > + bool compareMemoryOnHost( const Element1* data1, + const Element2* data2, + const Index size ); + + template< typename Element1, + typename Element2, + typename Index > + bool compareMemoryOnCuda( const Element1* hostData, + const Element2* deviceData, + const Index size ); + template< typename Element, + typename Index > + bool compareMemoryOnCuda( const Element* deviceData1, + const Element* deviceData2, + const Index size ); +}; + + +#endif /* TNLARRAYOPERATIONS_H_ */ diff --git a/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h b/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h index 9da836ff19a8dc2fd94e64136afe56198b69a425..a535a0573a09b4c828f02ff4e22de41131432789 100644 --- a/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h +++ b/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h @@ -265,12 +265,10 @@ class tnlVectorOperationsTester : public CppUnit :: TestCase CPPUNIT_ASSERT( tnlVectorOperations< Device > :: getVectorDifferenceLpNorm( u, v, 1.0 ) == 2.0 * size ); CPPUNIT_ASSERT( tnlVectorOperations< Device > :: getVectorDifferenceLpNorm( u, v, 2.0 ) == sqrt( 4.0 * size ) ); } - - }; #else -template< typename Device > +template< typename Real, typename Device > class tnlVectorOperationsTester {}; #endif /* HAVE_CPPUNIT */