Loading src/core/arrays/CMakeLists.txt +1 −0 Original line number Diff line number Diff line set( headers tnlArray.h tnlArrayOperations.h tnlMultiArray.h tnlSharedArray.h ) Loading src/core/arrays/tnlArrayOperations.h 0 → 100644 +154 −0 Original line number Diff line number Diff line /*************************************************************************** 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_ */ tests/unit-tests/core/vectors/tnlVectorOperationsTester.h +1 −3 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading
src/core/arrays/CMakeLists.txt +1 −0 Original line number Diff line number Diff line set( headers tnlArray.h tnlArrayOperations.h tnlMultiArray.h tnlSharedArray.h ) Loading
src/core/arrays/tnlArrayOperations.h 0 → 100644 +154 −0 Original line number Diff line number Diff line /*************************************************************************** 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_ */
tests/unit-tests/core/vectors/tnlVectorOperationsTester.h +1 −3 Original line number Diff line number Diff line Loading @@ -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 */ Loading