From 34b694fad17259632bd66e4c32afc5b584c93e4a Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Wed, 10 Jul 2013 22:32:04 +0200 Subject: [PATCH] Fixing the unit tests. --- install | 2 +- src/core/tnlFile.h | 8 ++++---- src/implementation/core/memory-operations.h | 2 +- src/implementation/mesh/tnlLinearGridGeometry_impl.h | 6 ++---- src/matrix/tnlRgCSRMatrix.h | 2 +- tests/unit-tests/core/cuda/tnlCudaDeviceCheckTester.h | 8 ++++++++ .../unit-tests/core/cuda/tnlCudaMemoryOperationsTester.h | 8 +++++++- tests/unit-tests/core/cuda/tnlCudaReductionTester.h | 7 +++++++ .../unit-tests/core/cuda/tnlCudaVectorOperationsTester.h | 8 ++++++++ tests/unit-tests/core/tnlArrayTest.cpp | 1 + tests/unit-tests/tnlUnitTestStarter.h | 2 +- 11 files changed, 41 insertions(+), 13 deletions(-) diff --git a/install b/install index 029a1902e7..2b9489d97e 100755 --- a/install +++ b/install @@ -2,7 +2,7 @@ TARGET=TNL INSTALL_PREFIX=${HOME}/local -WITH_CUDA=no +WITH_CUDA=yes WITH_CUSPARSE=no CUDA_ARCHITECTURE=2.0 TEMPLATE_EXPLICIT_INSTANTIATION=yes diff --git a/src/core/tnlFile.h b/src/core/tnlFile.h index 4ad2b324ed..cf10693eb5 100644 --- a/src/core/tnlFile.h +++ b/src/core/tnlFile.h @@ -118,7 +118,7 @@ class tnlFile const Index elements ); template< typename Type, typename Device > - bool write( Type* buffer ); + bool write( const Type* buffer ); #else template< typename Type, typename Device = tnlHost, typename Index = int > bool read( Type* buffer, @@ -132,7 +132,7 @@ class tnlFile const Index elements ); template< typename Type, typename Device = tnlHost > - bool write( Type* buffer ); + bool write( const Type* buffer ); #endif @@ -149,7 +149,7 @@ bool tnlFile :: read( Type* buffer ) }; template< typename Type, typename Device > -bool tnlFile :: write( Type* buffer ) +bool tnlFile :: write( const Type* buffer ) { return write< Type, Device, int >( buffer, 1 ); }; @@ -247,7 +247,7 @@ bool tnlFile :: read( Type* buffer, template< class Type, typename Device, typename Index > bool tnlFile :: write( const Type* buffer, - const Index elements ) + const Index elements ) { if( ! fileOK ) { diff --git a/src/implementation/core/memory-operations.h b/src/implementation/core/memory-operations.h index cfc3fe2a41..9917d6833e 100644 --- a/src/implementation/core/memory-operations.h +++ b/src/implementation/core/memory-operations.h @@ -192,7 +192,7 @@ bool copyMemoryCudaToHost( DestinationElement* destination, abort(); // TODO: fix this cudaMemcpy( destination, source, - size * sizeof( Element ), + size * sizeof( SourceElement ), cudaMemcpyDeviceToHost ); if( ! checkCudaDevice ) { diff --git a/src/implementation/mesh/tnlLinearGridGeometry_impl.h b/src/implementation/mesh/tnlLinearGridGeometry_impl.h index f6d5e7daad..46d2cfb4eb 100644 --- a/src/implementation/mesh/tnlLinearGridGeometry_impl.h +++ b/src/implementation/mesh/tnlLinearGridGeometry_impl.h @@ -354,7 +354,7 @@ bool tnlLinearGridGeometry< 2, Real, Device, Index > :: save( tnlFile& file ) co { if( ! this -> parametricStep. save( file ) || ! this -> proportions. save( file ) || - ! file. write( &this -> numberOfSegments ) || + ! file. write< IndexType, DeviceType >( &this -> numberOfSegments ) || ! this -> ySegments. save( file ) || ! this -> ySegmentsLeftOffsets. save( file ) || ! this -> ySegmentsRightOffsets. save( file ) ) @@ -369,13 +369,11 @@ bool tnlLinearGridGeometry< 2, Real, Device, Index > :: load( tnlFile& file ) { if( ! this -> parametricStep. load( file ) || ! this -> proportions. load( file ) || - ! file. read( &this -> numberOfSegments ) || + ! file. read< IndexType, DeviceType >( &this -> numberOfSegments ) || ! this -> ySegments. load( file ) || ! this -> ySegmentsLeftOffsets. load( file ) || ! this -> ySegmentsRightOffsets. load( file ) ) - { return false; - } return true; }; diff --git a/src/matrix/tnlRgCSRMatrix.h b/src/matrix/tnlRgCSRMatrix.h index 96cb51cc56..642923fac9 100644 --- a/src/matrix/tnlRgCSRMatrix.h +++ b/src/matrix/tnlRgCSRMatrix.h @@ -500,7 +500,7 @@ template< typename Real, typename Device, typename Index > bool tnlRgCSRMatrix< Real, Device, Index > :: copyFrom( const tnlRgCSRMatrix< Real, Device2, Index >& rgCSRMatrix ) { dbgFunctionName( "tnlRgCSRMatrix< Real, Device, Index >", "copyFrom" ); - tnlAssert( rgCSRMatrix. getSize() > 0, cerr << "Copying from matrix " < rgCSRMatrix. getName() << " with non-positiove size." ); + tnlAssert( rgCSRMatrix. getSize() > 0, cerr << "Copying from matrix " << rgCSRMatrix. getName() << " with non-positiove size." ); this -> cudaBlockSize = rgCSRMatrix. cudaBlockSize; this -> groupSize = rgCSRMatrix. groupSize; diff --git a/tests/unit-tests/core/cuda/tnlCudaDeviceCheckTester.h b/tests/unit-tests/core/cuda/tnlCudaDeviceCheckTester.h index b0f9f0d47b..1cbf3df581 100644 --- a/tests/unit-tests/core/cuda/tnlCudaDeviceCheckTester.h +++ b/tests/unit-tests/core/cuda/tnlCudaDeviceCheckTester.h @@ -18,6 +18,9 @@ #ifndef TNLCUDADEVICECHECKTESTER_H_ #define TNLCUDADEVICECHECKTESTER_H_ +#include <tnlConfig.h> + +#ifdef HAVE_CPPUNIT #include <cppunit/TestSuite.h> #include <cppunit/TestResult.h> #include <cppunit/TestCaller.h> @@ -30,6 +33,7 @@ __global__ void simpleKernel() { int tIdx = threadIdx. x; + tIdx ++; } #endif @@ -71,5 +75,9 @@ class tnlCudaDeviceCheckTester : public CppUnit :: TestCase }; }; +#else +class tnlCudaDeviceCheckTester +{}; +#endif /* HAVE_CPPUNIT */ #endif /* TNLCUDADEVICECHECKTESTER_H_ */ diff --git a/tests/unit-tests/core/cuda/tnlCudaMemoryOperationsTester.h b/tests/unit-tests/core/cuda/tnlCudaMemoryOperationsTester.h index 565f0be711..4ba5f58a38 100644 --- a/tests/unit-tests/core/cuda/tnlCudaMemoryOperationsTester.h +++ b/tests/unit-tests/core/cuda/tnlCudaMemoryOperationsTester.h @@ -18,6 +18,9 @@ #ifndef TNLCUDAMEMORYOPERATIONSTESTER_H_ #define TNLCUDAMEMORYOPERATIONSTESTER_H_ +#include <tnlConfig.h> + +#ifdef HAVE_CPPUNIT #include <cppunit/TestSuite.h> #include <cppunit/TestResult.h> #include <cppunit/TestCaller.h> @@ -126,6 +129,9 @@ class tnlCudaMemoryOperationsTester : public CppUnit :: TestCase }; - +#else +class tnlCudaMemoryOperationsTester +{}; +#endif /* HAVE_CPPUNIT */ #endif /* TNLCUDAMEMORYOPERATIONSTESTER_H_ */ diff --git a/tests/unit-tests/core/cuda/tnlCudaReductionTester.h b/tests/unit-tests/core/cuda/tnlCudaReductionTester.h index 0bd7d097a4..9324d9dedf 100644 --- a/tests/unit-tests/core/cuda/tnlCudaReductionTester.h +++ b/tests/unit-tests/core/cuda/tnlCudaReductionTester.h @@ -19,6 +19,9 @@ #ifndef TNLCUDAREDUCTIONTESTER_H_ #define TNLCUDAREDUCTIONTESTER_H_ +#include <tnlConfig.h> + +#ifdef HAVE_CPPUNIT #include <cppunit/TestSuite.h> #include <cppunit/TestResult.h> #include <cppunit/TestCaller.h> @@ -805,5 +808,9 @@ class tnlCudaReductionTester : public CppUnit :: TestCase }; +#else +class tnlCudaReductionTester +{}; +#endif /* HAVE_CPPUNIT */ #endif /* TNLCUDAREDUCTIONTESTER_H_ */ diff --git a/tests/unit-tests/core/cuda/tnlCudaVectorOperationsTester.h b/tests/unit-tests/core/cuda/tnlCudaVectorOperationsTester.h index 71e28dab9f..d4589e8660 100644 --- a/tests/unit-tests/core/cuda/tnlCudaVectorOperationsTester.h +++ b/tests/unit-tests/core/cuda/tnlCudaVectorOperationsTester.h @@ -18,6 +18,9 @@ #ifndef TNLCUDAVECTOROPERATIONSTESTER_H_ #define TNLCUDAVECTOROPERATIONSTESTER_H_ +#include <tnlConfig.h> + +#ifdef HAVE_CPPUNIT #include <cppunit/TestSuite.h> #include <cppunit/TestResult.h> #include <cppunit/TestCaller.h> @@ -213,5 +216,10 @@ class tnlCudaVectorOperationsTester : public CppUnit :: TestCase }; +#else +template< typename Type > +class tnlCudaVectorOperationsTester +{}; +#endif /* HAVE_CPPUNIT */ #endif /* TNLCUDAVECTOROPERATIONSTESTER_H_ */ diff --git a/tests/unit-tests/core/tnlArrayTest.cpp b/tests/unit-tests/core/tnlArrayTest.cpp index 9782352a30..4184e8c356 100644 --- a/tests/unit-tests/core/tnlArrayTest.cpp +++ b/tests/unit-tests/core/tnlArrayTest.cpp @@ -15,6 +15,7 @@ * * ***************************************************************************/ +#include <cstdlib> #include "tnlArrayTester.h" #include "../tnlUnitTestStarter.h" diff --git a/tests/unit-tests/tnlUnitTestStarter.h b/tests/unit-tests/tnlUnitTestStarter.h index b828c2148d..9e3a543ba0 100644 --- a/tests/unit-tests/tnlUnitTestStarter.h +++ b/tests/unit-tests/tnlUnitTestStarter.h @@ -45,7 +45,7 @@ class tnlUnitTestStarter std :: cerr << "Error: CPPUNIT is missing." << std :: endl; return false; #endif - }; + } }; #endif /* TNLUNITTESTSTARTER_H_ */ -- GitLab