diff --git a/src/Benchmarks/Traversers/GridTraversersBenchmark.h b/src/Benchmarks/Traversers/GridTraversersBenchmark.h index 3302c4cb9407eae7d1feb4fe6b49f6ebc18adaff..6f1019debad51f6eb2c661508d19d9173be0c9f0 100644 --- a/src/Benchmarks/Traversers/GridTraversersBenchmark.h +++ b/src/Benchmarks/Traversers/GridTraversersBenchmark.h @@ -16,6 +16,10 @@ #include <TNL/Devices/Host.h> #include <TNL/Devices/Cuda.h> #include <TNL/Containers/Vector.h> +#include <TNL/Meshes/Grid.h> +#include <TNL/Meshes/GridEntityConfig.h> +#include <TNL/Meshes/Traverser.h> +#include <TNL/Functions/MeshFunction.h> namespace TNL { namespace Benchmarks { @@ -35,26 +39,52 @@ class GridTraversersBenchmark< 1, Device, Real, Index > public: using Vector = Containers::Vector< Real, Device, Index >; + using Grid = Meshes::Grid< 1, Real, Device, Index >; + using Coordinates = typename Grid::CoordinatesType; + using MeshFunction = Functions::MeshFunction< Grid >; + using Cell = typename Grid::EntityType< 1, Meshes::GridEntityNoStencilStorage >; + using Traverser = Meshes::Traverser< Grid, Cell >; GridTraversersBenchmark( Index size ) - :v( size ), size( size ) - {} + :v( size ), size( size ), grid( size ) + { + } - void writeOne() + void writeOneUsingParallelFor() { auto f = [] __cuda_callable__ ( Index i, Real* data ) { - data[ i ] = i; + data[ i ] = 1.0; }; ParallelFor< Device >::exec( ( Index ) 0, size, f, v.getData() ); } + void writeOneUsingTraverser() + { + class EntitiesProcessor + { + + }; + + class UserData + { + + }; + + Traverser traverser; + /*traverser.template processAllEntities< UserData, EntitiesProcessor > + ( meshPointer, + userData );*/ + + } + protected: Index size; Vector v; + Grid grid; }; @@ -66,16 +96,20 @@ class GridTraversersBenchmark< 2, Device, Real, Index > public: using Vector = Containers::Vector< Real, Device, Index >; + using Grid = Meshes::Grid< 2, Real, Device, Index >; + using Coordinates = typename Grid::CoordinatesType; GridTraversersBenchmark( Index size ) - :size( size ), v( size * size ) { } + :size( size ), v( size * size ), grid( size, size ) + { + } - void writeOne() + void writeOneUsingParallelFor() { Index _size = this->size; auto f = [=] __cuda_callable__ ( Index i, Index j, Real* data ) { - data[ i * _size + j ] = i + j; + data[ i * _size + j ] = 1.0; }; ParallelFor2D< Device >::exec( ( Index ) 0, @@ -88,8 +122,8 @@ class GridTraversersBenchmark< 2, Device, Real, Index > protected: Index size; - Vector v; + Grid grid; }; @@ -101,16 +135,22 @@ class GridTraversersBenchmark< 3, Device, Real, Index > public: using Vector = Containers::Vector< Real, Device, Index >; + using Grid = Meshes::Grid< 3, Real, Device, Index >; + using Coordinates = typename Grid::CoordinatesType; GridTraversersBenchmark( Index size ) - : size( size ), v( size * size * size ) {} + : size( size ), + v( size * size * size ), + grid( size, size, size ) + { + } - void writeOne() + void writeOneUsingParallelFor() { Index _size = this->size; auto f = [=] __cuda_callable__ ( Index i, Index j, Index k, Real* data ) { - data[ ( i * _size + j ) * _size + k ] = i + j + k; + data[ ( i * _size + j ) * _size + k ] = 1.0; }; ParallelFor3D< Device >::exec( ( Index ) 0, @@ -126,6 +166,7 @@ class GridTraversersBenchmark< 3, Device, Real, Index > Index size; Vector v; + Grid grid; }; diff --git a/src/Benchmarks/Traversers/tnl-benchmark-traversers.h b/src/Benchmarks/Traversers/tnl-benchmark-traversers.h index 9b69a316397197e2b5aa83b7cc4951b35b39f8d3..c6349f5960427bfb8363324ce7b43d22bb520637 100644 --- a/src/Benchmarks/Traversers/tnl-benchmark-traversers.h +++ b/src/Benchmarks/Traversers/tnl-benchmark-traversers.h @@ -54,20 +54,20 @@ bool runBenchmark( const Config::ParameterContainer& parameters, Benchmark::MetadataColumns( { {"size", convertToString( size ) }, } ) ); - auto hostWriteOne = [&] () + auto hostWriteOneUsingParallelFor = [&] () { - hostTraverserBenchmark.writeOne(); + hostTraverserBenchmark.writeOneUsingParallelFor(); }; - auto cudaWriteOne = [&] () + auto cudaWriteOneUsingParallelFor = [&] () { - cudaTraverserBenchmark.writeOne(); + cudaTraverserBenchmark.writeOneUsingParallelFor(); }; - benchmark.setOperation( "writeOne", size * sizeof( Real ) ); - benchmark.time( reset, "CPU", hostWriteOne ); + benchmark.setOperation( "write 1 using parallel for", size * sizeof( Real ) / oneGB ); + benchmark.time( reset, "CPU", hostWriteOneUsingParallelFor ); #ifdef HAVE_CUDA - benchmark.time( reset, "GPU", cudaWriteOne ); + benchmark.time( reset, "GPU", cudaWriteOneUsingParallelFor ); #endif } diff --git a/src/TNL/Meshes/GridDetails/Grid2D.h b/src/TNL/Meshes/GridDetails/Grid2D.h index 896b61548653e7d09f1fdf3e909f26575f135c58..f2dbebc5c78c36959a68a574886496c75857ca81 100644 --- a/src/TNL/Meshes/GridDetails/Grid2D.h +++ b/src/TNL/Meshes/GridDetails/Grid2D.h @@ -82,8 +82,8 @@ class Grid< 2, Real, Device, Index > : public Object /** * \brief Sets the size of dimensions. - * \param xSize Size of dimesion x. - * \param ySize Size of dimesion y. + * \param xSize Size of dimension x. + * \param ySize Size of dimension y. */ void setDimensions( const Index xSize, const Index ySize ); diff --git a/src/TNL/Meshes/GridDetails/Grid2D_impl.h b/src/TNL/Meshes/GridDetails/Grid2D_impl.h index 49ad9103539f27100bf88413631c402491a7bd67..41e05d8b5a5853f8f5cc9d08ef8a0360b7202636 100644 --- a/src/TNL/Meshes/GridDetails/Grid2D_impl.h +++ b/src/TNL/Meshes/GridDetails/Grid2D_impl.h @@ -43,7 +43,7 @@ Grid< 2, Real, Device, Index >::Grid( const Index xSize, const Index ySize ) : numberOfCells( 0 ), numberOfNxFaces( 0 ), numberOfNyFaces( 0 ), - numberOfFaces( 0 ), + numberOfFaces( 0 ), numberOfVertices( 0 ), distGrid(nullptr) { diff --git a/src/TNL/Meshes/GridDetails/Grid3D.h b/src/TNL/Meshes/GridDetails/Grid3D.h index 3ddd44735d23470990036116f33db34e68337528..617efe7f31bc9e8b5ef3898e0f75eb9cf1ada11a 100644 --- a/src/TNL/Meshes/GridDetails/Grid3D.h +++ b/src/TNL/Meshes/GridDetails/Grid3D.h @@ -57,8 +57,8 @@ class Grid< 3, Real, Device, Index > : public Object * \brief See Grid1D::Grid(). */ Grid(); - - Grid( const Index xSize, const Index ySize, const Index zSize ); + + Grid( const Index xSize, const Index ySize, const Index zSize ); /** * \brief See Grid1D::getType().