Skip to content
Snippets Groups Projects
Commit 0031f809 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Basic CUDA benchmark was added.

parent 41091991
No related branches found
No related tags found
No related merge requests found
ADD_SUBDIRECTORY( share ) ADD_SUBDIRECTORY( share )
IF( BUILD_CUDA ) 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 CUDA_ADD_EXECUTABLE( tnl-benchmark-spmv${debugExt} tnl-benchmark-spmv.cu
OPTIONS ${CUDA_ADD_EXECUTABLE_OPTIONS} ) OPTIONS ${CUDA_ADD_EXECUTABLE_OPTIONS} )
SET_TARGET_PROPERTIES( tnl-benchmark-spmv${debugExt} PROPERTIES CUDA_COMPILE_FLAGS "${CXX_OPTIMIZE_FLAGS}" ) SET_TARGET_PROPERTIES( tnl-benchmark-spmv${debugExt} PROPERTIES CUDA_COMPILE_FLAGS "${CXX_OPTIMIZE_FLAGS}" )
...@@ -18,7 +22,12 @@ ELSE() ...@@ -18,7 +22,12 @@ ELSE()
ENDIF() ENDIF()
TARGET_LINK_LIBRARIES( tnl-benchmark-linear-solvers${debugExt} tnl${debugExt}-${tnlVersion} ) 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} INSTALL( TARGETS tnl-benchmark-spmv${debugExt}
tnl-benchmark-linear-solvers${debugExt} tnl-benchmark-linear-solvers${debugExt}
RUNTIME DESTINATION bin ) RUNTIME DESTINATION bin )
......
/*************************************************************************** /***************************************************************************
tnl-benchmarks.cpp - description tnl-cuda-benchmarks.cu - description
------------------- -------------------
begin : Nov 25, 2010 begin : May 28, 2015
copyright : (C) 2010 by Tomas Oberhuber copyright : (C) 2015 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/ ***************************************************************************/
...@@ -15,43 +15,38 @@ ...@@ -15,43 +15,38 @@
* * * *
***************************************************************************/ ***************************************************************************/
#include <core/vectors/tnlVector.h>
#include <core/vectors/tnlVectorHost.h> #include <core/tnlTimerRT.h>
#include <core/vectors/tnlVectorCUDA.h>
#include <tnl-benchmarks.h>
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
#ifdef HAVE_CUDA #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, tnlTimerRT timer;
host_to_host_band_width, const double oneGB = 1024.0 * 1024.0 * 1024.0;
host_to_device_band_width,
device_to_host_band_width,
device_to_device_band_width );
cout << "Benchmarking memory bandwidth when transfering int ..." << endl;
cout << "Benchmarking reduction of int ..." << endl; const int size = 1 << 22;
for( int i = 0; i <= 6; i ++ )
reductionBenchmark< int >( size, i ); tnlVector< int, tnlHost > hostVector;
tnlVector< int, tnlCuda > deviceVector;
hostVector.setSize( size );
deviceVector.setSize( size );
cout << "Benchmarking reduction of float ..." << endl; hostVector.setValue( 1.0 );
for( int i = 0; i <= 6; i ++ ) deviceVector.setValue( 0.0 );
reductionBenchmark< float >( size, i );
timer.reset();
timer.start();
deviceVector = hostVector;
timer.stop();
double bandwidth = ( double ) ( size ) * sizeof( int ) / timer.getTime() / oneGB;
cout << "Benchmarking reduction of double ..." << endl; cout << bandwidth << " GB/sec." << endl;
for( int i = 0; i <= 6; i ++ )
reductionBenchmark< double >( size / 2, i );
#endif #endif
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment