diff --git a/tests/benchmarks/CMakeLists.txt b/tests/benchmarks/CMakeLists.txt index 90d967d345e0c9b55c1202f31550b2d14f0cdc29..975147ee5a63a8b17f3446d203bb25af3c34ee66 100755 --- a/tests/benchmarks/CMakeLists.txt +++ b/tests/benchmarks/CMakeLists.txt @@ -1,6 +1,10 @@ ADD_SUBDIRECTORY( share ) IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE( tnl-cuda-benchmarks${debugExt} tnl-cuda-benchmarks.cu + OPTIONS ${CUDA_ADD_EXECUTABLE_OPTIONS} ) + SET_TARGET_PROPERTIES( tnl-cuda-benchmarks${debugExt} PROPERTIES CUDA_COMPILE_FLAGS "${CXX_OPTIMIZE_FLAGS}" ) + TARGET_LINK_LIBRARIES( tnl-cuda-benchmarks${debugExt} tnl${debugExt}-${tnlVersion} ${CUSPARSE_LIBRARY} ) CUDA_ADD_EXECUTABLE( tnl-benchmark-spmv${debugExt} tnl-benchmark-spmv.cu OPTIONS ${CUDA_ADD_EXECUTABLE_OPTIONS} ) SET_TARGET_PROPERTIES( tnl-benchmark-spmv${debugExt} PROPERTIES CUDA_COMPILE_FLAGS "${CXX_OPTIMIZE_FLAGS}" ) @@ -18,7 +22,12 @@ ELSE() ENDIF() TARGET_LINK_LIBRARIES( tnl-benchmark-linear-solvers${debugExt} tnl${debugExt}-${tnlVersion} ) - + +if( BUILD_CUDA ) + INSTALL( TARGETS tnl-cuda-benchmarks${debugExt} + RUNTIME DESTINATION bin ) +endif() + INSTALL( TARGETS tnl-benchmark-spmv${debugExt} tnl-benchmark-linear-solvers${debugExt} RUNTIME DESTINATION bin ) diff --git a/tests/benchmarks/tnl-benchmarks.cpp b/tests/benchmarks/tnl-benchmarks.cpp deleted file mode 100644 index 69af7724356147e84594aa3c4f8c35db6010b20b..0000000000000000000000000000000000000000 --- a/tests/benchmarks/tnl-benchmarks.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - tnl-benchmarks.cpp - description - ------------------- - begin : Nov 25, 2010 - copyright : (C) 2010 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. * - * * - ***************************************************************************/ - - -#include <core/vectors/tnlVectorHost.h> -#include <core/vectors/tnlVectorCUDA.h> -#include <tnl-benchmarks.h> - - -int main( int argc, char* argv[] ) -{ - -#ifdef HAVE_CUDA - cout << "Benchmarking memory bandwidth when transfering int ..." << endl; - - const int size = 1 << 22; - double host_to_host_band_width; - double host_to_device_band_width; - double device_to_host_band_width; - double device_to_device_band_width; - - transferBenchmark< int >( size, - host_to_host_band_width, - host_to_device_band_width, - device_to_host_band_width, - device_to_device_band_width ); - - - cout << "Benchmarking reduction of int ..." << endl; - for( int i = 0; i <= 6; i ++ ) - reductionBenchmark< int >( size, i ); - - cout << "Benchmarking reduction of float ..." << endl; - for( int i = 0; i <= 6; i ++ ) - reductionBenchmark< float >( size, i ); - - cout << "Benchmarking reduction of double ..." << endl; - for( int i = 0; i <= 6; i ++ ) - reductionBenchmark< double >( size / 2, i ); - -#endif - return EXIT_SUCCESS; -} diff --git a/tests/benchmarks/tnl-cuda-benchmarks.cu b/tests/benchmarks/tnl-cuda-benchmarks.cu new file mode 100644 index 0000000000000000000000000000000000000000..ded925bea7ddba4f3b39e72fd7ddeec75103c2d1 --- /dev/null +++ b/tests/benchmarks/tnl-cuda-benchmarks.cu @@ -0,0 +1,52 @@ +/*************************************************************************** + tnl-cuda-benchmarks.cu - description + ------------------- + begin : May 28, 2015 + copyright : (C) 2015 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. * + * * + ***************************************************************************/ + +#include <core/vectors/tnlVector.h> +#include <core/tnlTimerRT.h> + +int main( int argc, char* argv[] ) +{ +#ifdef HAVE_CUDA + + tnlTimerRT timer; + const double oneGB = 1024.0 * 1024.0 * 1024.0; + + cout << "Benchmarking memory bandwidth when transfering int ..." << endl; + + const int size = 1 << 22; + + tnlVector< int, tnlHost > hostVector; + tnlVector< int, tnlCuda > deviceVector; + hostVector.setSize( size ); + deviceVector.setSize( size ); + + hostVector.setValue( 1.0 ); + deviceVector.setValue( 0.0 ); + + timer.reset(); + timer.start(); + deviceVector = hostVector; + timer.stop(); + + double bandwidth = ( double ) ( size ) * sizeof( int ) / timer.getTime() / oneGB; + + cout << bandwidth << " GB/sec." << endl; + + +#endif + return EXIT_SUCCESS; +} diff --git a/tests/benchmarks/tnl-benchmarks.h b/tests/benchmarks/tnl-cuda-benchmarks.h similarity index 100% rename from tests/benchmarks/tnl-benchmarks.h rename to tests/benchmarks/tnl-cuda-benchmarks.h