Loading src/Benchmarks/BLAS/vector-operations.h +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ benchmarkVectorOperations( Benchmark & benchmark, deviceVector.setValue( 1.0 ); #endif // A relatively harmless call to keep the compiler from realizing we // don't actually do any useful work with the result of the reduciton. // don't actually do any useful work with the result of the reduction. srand48(resultHost); resultHost = resultDevice = 0.0; }; Loading src/Benchmarks/Traversers/WriteOne.h 0 → 100644 +88 −0 Original line number Diff line number Diff line /*************************************************************************** WriteOne.h - description ------------------- begin : Dec 19, 2018 copyright : (C) 2018 by oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /* See Copyright Notice in tnl/Copyright */ // Implemented by: Tomas Oberhuber #pragma once #include <TNL/ParallelFor.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Cuda.h> #include <TNL/Containers/Vector.h> namespace TNL { namespace Benchmarks { template< int Dimenions, typename Device, typename Real, typename Index > class WriteOne{}; template< typename Device, typename Real, typename Index > class WriteOne< 1, Device, Real, Index > { public: using Vector = Containers::Vector< Real, Device, Index >; static void run( std::size_t size ) { Vector v( size ); auto writeOne = []( Index i, Real* data ) { data[ i ] = 1.0; }; ParallelFor< Devices::Host >::exec( ( std::size_t ) 0, size, writeOne, v.getData() ); } }; template< typename Device, typename Real, typename Index > class WriteOne< 2, Device, Real, Index > { public: using Vector = Containers::Vector< Real, Device, Index >; static void run( std::size_t size ) { } }; template< typename Device, typename Real, typename Index > class WriteOne< 3, Device, Real, Index > { public: using Vector = Containers::Vector< Real, Device, Index >; static void run( std::size_t size ) { } }; } // namespace Benchmarks } // namespace TNL src/Benchmarks/Traversers/grid-traversing.h 0 → 100644 +54 −0 Original line number Diff line number Diff line /*************************************************************************** grid-traversing.h - description ------------------- begin : Dec 19, 2018 copyright : (C) 2018 by oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /* See Copyright Notice in tnl/Copyright */ // Implemented by: Tomas Oberhuber #pragma once #include "../Benchmarks.h" #include "WriteOne.h" #include <TNL/Containers/Vector.h> namespace TNL { namespace Benchmarks { template< int Dimension, typename Real = double, typename Index = int > class benchmarkTraversingFullGrid { public: static void run ( Benchmark& benchmark, std::size_t size ) { auto reset = [&]() {}; auto testHost = [&] () { WriteOne< Dimension, Devices::Host, Real, Index >::run( size ); }; auto testCuda = [&] () { WriteOne< Dimension, Devices::Cuda, Real, Index >::run( size ); }; benchmark.setOperation( "writeOne", size * sizeof( Real ) ); benchmark.time( reset, "CPU", testHost ); #ifdef HAVE_CUDA benchmark.time( reset, "GPU", testCuda ); #endif } }; } // namespace Benchmarks } // namespace TNL No newline at end of file Loading
src/Benchmarks/BLAS/vector-operations.h +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ benchmarkVectorOperations( Benchmark & benchmark, deviceVector.setValue( 1.0 ); #endif // A relatively harmless call to keep the compiler from realizing we // don't actually do any useful work with the result of the reduciton. // don't actually do any useful work with the result of the reduction. srand48(resultHost); resultHost = resultDevice = 0.0; }; Loading
src/Benchmarks/Traversers/WriteOne.h 0 → 100644 +88 −0 Original line number Diff line number Diff line /*************************************************************************** WriteOne.h - description ------------------- begin : Dec 19, 2018 copyright : (C) 2018 by oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /* See Copyright Notice in tnl/Copyright */ // Implemented by: Tomas Oberhuber #pragma once #include <TNL/ParallelFor.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Cuda.h> #include <TNL/Containers/Vector.h> namespace TNL { namespace Benchmarks { template< int Dimenions, typename Device, typename Real, typename Index > class WriteOne{}; template< typename Device, typename Real, typename Index > class WriteOne< 1, Device, Real, Index > { public: using Vector = Containers::Vector< Real, Device, Index >; static void run( std::size_t size ) { Vector v( size ); auto writeOne = []( Index i, Real* data ) { data[ i ] = 1.0; }; ParallelFor< Devices::Host >::exec( ( std::size_t ) 0, size, writeOne, v.getData() ); } }; template< typename Device, typename Real, typename Index > class WriteOne< 2, Device, Real, Index > { public: using Vector = Containers::Vector< Real, Device, Index >; static void run( std::size_t size ) { } }; template< typename Device, typename Real, typename Index > class WriteOne< 3, Device, Real, Index > { public: using Vector = Containers::Vector< Real, Device, Index >; static void run( std::size_t size ) { } }; } // namespace Benchmarks } // namespace TNL
src/Benchmarks/Traversers/grid-traversing.h 0 → 100644 +54 −0 Original line number Diff line number Diff line /*************************************************************************** grid-traversing.h - description ------------------- begin : Dec 19, 2018 copyright : (C) 2018 by oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /* See Copyright Notice in tnl/Copyright */ // Implemented by: Tomas Oberhuber #pragma once #include "../Benchmarks.h" #include "WriteOne.h" #include <TNL/Containers/Vector.h> namespace TNL { namespace Benchmarks { template< int Dimension, typename Real = double, typename Index = int > class benchmarkTraversingFullGrid { public: static void run ( Benchmark& benchmark, std::size_t size ) { auto reset = [&]() {}; auto testHost = [&] () { WriteOne< Dimension, Devices::Host, Real, Index >::run( size ); }; auto testCuda = [&] () { WriteOne< Dimension, Devices::Cuda, Real, Index >::run( size ); }; benchmark.setOperation( "writeOne", size * sizeof( Real ) ); benchmark.time( reset, "CPU", testHost ); #ifdef HAVE_CUDA benchmark.time( reset, "GPU", testCuda ); #endif } }; } // namespace Benchmarks } // namespace TNL No newline at end of file