Commit 64ae289e authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Analyzing grid entity efficiency.

parent 2c26ffc9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public:
   {
      config.addEntry< int >( "loops", "Number of iterations for every computation.", 10 );
      config.addEntry< bool >( "reset", "Call reset function between loops.", true );
      config.addEntry< double >( "min-time", "Minimal real time in seconds for every computation.", 1 );
      config.addEntry< double >( "min-time", "Minimal real time in seconds for every computation.", 0.0 );
      config.addEntry< bool >( "timing", "Turns off (or on) the timing (for the purpose of profiling).", true );
      config.addEntry< int >( "verbose", "Verbose mode, the higher number the more verbosity.", 1 );
   }
+8 −1
Original line number Diff line number Diff line
@@ -22,8 +22,15 @@ class BenchmarkTraverserUserData
   public:

      using MeshType = typename MeshFunction::MeshType;
      using RealType = typename MeshType::RealType;
      using DeviceType = typename MeshType::DeviceType;
      using MeshFunctionPointer = Pointers::SharedPointer< MeshFunction >;
      
      BenchmarkTraverserUserData( MeshFunctionPointer& f )
         : u( &f.template modifyData< DeviceType >() ), data( f->getData().getData() ){}

      MeshFunction* u;
      RealType* data;
};


+18 −12
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

#include "AddOneEntitiesProcessor.h"
#include "BenchmarkTraverserUserData.h"
#include "SimpleCell.h"

namespace TNL {
   namespace Benchmarks {
@@ -38,13 +39,16 @@ _GridTraverser1D(
   typedef Meshes::Grid< 1, Real, Devices::Cuda, Index > GridType;
   typename GridType::CoordinatesType coordinates;
 
   GridEntity entity;//( *grid, );
   //entity.getCoordinates().x() = begin.x() + ( gridIdx * Devices::Cuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x;
   coordinates.x() = begin.x() + ( gridIdx * Devices::Cuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x;
   if( coordinates <= end )
   {
      GridEntity entity( *grid, coordinates );
      entity.refresh();
      ( userData.u->getData() )[ coordinates.x() ] += ( RealType ) 1.0;
      //( *userData.u )( entity) += 1.0;
      //entity.refresh();
      //( userData.u->getData() )[ entity.getIndex( coordinates ) ] += ( RealType ) 1.0;
      //( userData.u->getData() )[ coordinates.x() ] += ( RealType ) 1.0;
      userData.data[ coordinates.x() ] += ( RealType ) 1.0;
      //( *userData.u )( entity ) += ( RealType ) 1.0;
      //EntitiesProcessor::processEntity( entity.getMesh(), userData, entity );
   }
}
@@ -66,8 +70,9 @@ class GridTraverserBenchmarkHelper< Grid, Devices::Host >
      using CoordinatesType = typename Grid::CoordinatesType;
      using MeshFunction = Functions::MeshFunction< Grid >;
      using MeshFunctionPointer = Pointers::SharedPointer< MeshFunction >;
      using Cell = typename Grid::template EntityType< 1, Meshes::GridEntityNoStencilStorage >;
      using Traverser = Meshes::Traverser< Grid, Cell >;
      using CellType = typename Grid::template EntityType< 1, Meshes::GridEntityNoStencilStorage >;
      using SimpleCellType = SimpleCell< GridType >;
      using Traverser = Meshes::Traverser< Grid, CellType >;
      using UserDataType = BenchmarkTraverserUserData< MeshFunction >;
      using AddOneEntitiesProcessorType = AddOneEntitiesProcessor< UserDataType >;

@@ -84,13 +89,13 @@ class GridTraverserBenchmarkHelper< Grid, Devices::Host >
         const CoordinatesType begin( 0 );
         const CoordinatesType end = CoordinatesType( size ) - CoordinatesType( 1 );
         //MeshFunction* _u = &u.template modifyData< Device >();
         Cell entity( *grid );
         /*SimpleCellType entity( *grid );
         for( IndexType x = begin.x(); x <= end.x(); x ++ )
         {
            entity.getCoordinates().x() = x;
            entity.refresh();
            AddOneEntitiesProcessorType::processEntity( entity.getMesh(), userData, entity );
         }
         }*/

      }
};
@@ -107,8 +112,9 @@ class GridTraverserBenchmarkHelper< Grid, Devices::Cuda >
      using CoordinatesType = typename Grid::CoordinatesType;
      using MeshFunction = Functions::MeshFunction< Grid >;
      using MeshFunctionPointer = Pointers::SharedPointer< MeshFunction >;
      using Cell = typename Grid::template EntityType< 1, Meshes::GridEntityNoStencilStorage >;
      using Traverser = Meshes::Traverser< Grid, Cell >;
      using CellType = typename Grid::template EntityType< 1, Meshes::GridEntityNoStencilStorage >;
      using SimpleCellType = SimpleCell< GridType >;
      using Traverser = Meshes::Traverser< Grid, CellType >;
      using UserDataType = BenchmarkTraverserUserData< MeshFunction >;
      using AddOneEntitiesProcessorType = AddOneEntitiesProcessor< UserDataType >;

@@ -132,7 +138,7 @@ class GridTraverserBenchmarkHelper< Grid, Devices::Cuda >
                  gridsCount,
                  gridIdx,
                  gridSize );
               _GridTraverser1D< RealType, IndexType, Cell, UserDataType, AddOneEntitiesProcessorType >
               _GridTraverser1D< RealType, IndexType, SimpleCellType, UserDataType, AddOneEntitiesProcessorType >
               <<< blocksCount, blockSize >>>
               ( &grid.template getData< Devices::Cuda >(),
                 userData,
+2 −2
Original line number Diff line number Diff line
@@ -48,9 +48,9 @@ class GridTraversersBenchmark< 1, Device, Real, Index >
      using AddOneEntitiesProcessorType = AddOneEntitiesProcessor< UserDataType >;
      
      GridTraversersBenchmark( Index size )
      :size( size ), v( size ), grid( size ), u( grid )
      :size( size ), v( size ), grid( size ), u( grid ),
       userData( this->u )
      {
         userData.u = &this->u.template modifyData< Device >();
         v_data = v.getData();
      }

+2 −2
Original line number Diff line number Diff line
@@ -46,9 +46,9 @@ class GridTraversersBenchmark< 2, Device, Real, Index >
      using AddOneEntitiesProcessorType = AddOneEntitiesProcessor< UserDataType >;

      GridTraversersBenchmark( Index size )
      :size( size ), v( size * size ), grid( size, size ), u( grid )
      :size( size ), v( size * size ), grid( size, size ), u( grid ),
       userData( u )
      {
         userData.u = &this->u.template modifyData< Device >();
         v_data = v.getData();
      }

Loading