diff --git a/src/Benchmarks/BLAS/vector-operations.h b/src/Benchmarks/BLAS/vector-operations.h index b9a68d618b1c7caf5eb47a21e630143927367e54..8dd63de85b985f72a9a1dc3888f2e587234340be 100644 --- a/src/Benchmarks/BLAS/vector-operations.h +++ b/src/Benchmarks/BLAS/vector-operations.h @@ -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; }; diff --git a/src/Benchmarks/Traversers/WriteOne.h b/src/Benchmarks/Traversers/WriteOne.h new file mode 100644 index 0000000000000000000000000000000000000000..73bf0bfecfb3f111f0feac0e6091aa9549430673 --- /dev/null +++ b/src/Benchmarks/Traversers/WriteOne.h @@ -0,0 +1,88 @@ +/*************************************************************************** + 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 + + + diff --git a/src/Benchmarks/Traversers/grid-traversing.h b/src/Benchmarks/Traversers/grid-traversing.h new file mode 100644 index 0000000000000000000000000000000000000000..df45b1d7fe62be4eb6bfae1d6e85d387ef73f6c3 --- /dev/null +++ b/src/Benchmarks/Traversers/grid-traversing.h @@ -0,0 +1,54 @@ +/*************************************************************************** + 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