Skip to content
Snippets Groups Projects
Commit 60f9f4b1 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Jakub Klinkovský
Browse files

Implemented SimpleCell traverser benchmark test.

parent 31303f1a
No related branches found
No related tags found
1 merge request!20Traversers optimizations
...@@ -37,18 +37,19 @@ _GridTraverser1D( ...@@ -37,18 +37,19 @@ _GridTraverser1D(
typedef Real RealType; typedef Real RealType;
typedef Index IndexType; typedef Index IndexType;
typedef Meshes::Grid< 1, Real, Devices::Cuda, Index > GridType; typedef Meshes::Grid< 1, Real, Devices::Cuda, Index > GridType;
typename GridType::CoordinatesType coordinates; //typename GridType::CoordinatesType coordinates;
GridEntity entity;//( *grid, ); GridEntity entity( *grid );
//entity.getCoordinates().x() = begin.x() + ( gridIdx * Devices::Cuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x; 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; //coordinates.x() = begin.x() + ( gridIdx * Devices::Cuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x;
if( coordinates <= end ) if( entity.getCoordinates() <= end )
{ {
//entity.refresh(); entity.refresh();
//( userData.u->getData() )[ entity.getIndex( coordinates ) ] += ( RealType ) 1.0; //( userData.u->getData() )[ entity.getIndex( coordinates ) ] += ( RealType ) 1.0;
//( userData.u->getData() )[ coordinates.x() ] += ( RealType ) 1.0; //( userData.u->getData() )[ coordinates.x() ] += ( RealType ) 1.0;
userData.data[ coordinates.x() ] += ( RealType ) 1.0; //userData.data[ entity.getIndex() ] += ( RealType ) 1.0;
//( *userData.u )( entity ) += ( RealType ) 1.0; //userData.u->getData()[ entity.getIndex() ] += ( RealType ) 1.0;
( *userData.u )( entity ) += ( RealType ) 1.0;
//EntitiesProcessor::processEntity( entity.getMesh(), userData, entity ); //EntitiesProcessor::processEntity( entity.getMesh(), userData, entity );
} }
} }
...@@ -80,22 +81,25 @@ class GridTraverserBenchmarkHelper< Grid, Devices::Host > ...@@ -80,22 +81,25 @@ class GridTraverserBenchmarkHelper< Grid, Devices::Host >
UserDataType& userData, UserDataType& userData,
std::size_t size ) std::size_t size )
{ {
/*Meshes::GridTraverser< Grid >::template processEntities< Cell, WriteOneEntitiesProcessorType, WriteOneTraverserUserDataType, false >( /*Meshes::GridTraverser< Grid >::template processEntities< CellType, AddOneEntitiesProcessorType, UserDataType, false >(
grid, grid,
CoordinatesType( 0 ), CoordinatesType( 0 ),
grid->getDimensions() - CoordinatesType( 1 ), grid->getDimensions() - CoordinatesType( 1 ),
userData );*/ userData );
*/
const CoordinatesType begin( 0 ); const CoordinatesType begin( 0 );
const CoordinatesType end = CoordinatesType( size ) - CoordinatesType( 1 ); const CoordinatesType end = CoordinatesType( size ) - CoordinatesType( 1 );
//MeshFunction* _u = &u.template modifyData< Device >(); //MeshFunction* _u = &u.template modifyData< Device >();
/*SimpleCellType entity( *grid ); SimpleCellType entity( *grid );
for( IndexType x = begin.x(); x <= end.x(); x ++ ) for( IndexType x = begin.x(); x <= end.x(); x ++ )
{ {
entity.getCoordinates().x() = x; entity.getCoordinates().x() = x;
entity.refresh(); entity.refresh();
AddOneEntitiesProcessorType::processEntity( entity.getMesh(), userData, entity ); //userData.u->getData()[ entity.getIndex() ] += ( RealType ) 1.0;
}*/ ( *userData.u )( entity ) += ( RealType ) 1.0;
//AddOneEntitiesProcessorType::processEntity( entity.getMesh(), userData, entity );
}
} }
}; };
......
/***************************************************************************
SimpleCell.h - description
-------------------
begin : Jan 5, 2019
copyright : (C) 2019 by oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
// Implemented by: Tomas Oberhuber
#pragma once
#include <TNL/Devices/Cuda.h>
#include <TNL/Meshes/Grid.h>
namespace TNL {
namespace Benchmarks {
namespace Traversers {
template< typename Grid >
class SimpleCell{};
template< typename Real,
typename Device,
typename Index >
class SimpleCell< Meshes::Grid< 1, Real, Device, Index > >
{
public:
using GridType = Meshes::Grid< 1, Real, Device, Index >;
using RealType = typename GridType::RealType;
using DeviceType = typename GridType::DeviceType;
using IndexType = typename GridType::IndexType;
using CoordinatesType = typename GridType::CoordinatesType;
constexpr static int getEntityDimension() { return 1; };
__cuda_callable__
SimpleCell( const GridType& grid ) :
grid( grid ){};
__cuda_callable__
const GridType& getMesh() const { return this->grid;};
__cuda_callable__
CoordinatesType& getCoordinates() { return this->coordinates; };
__cuda_callable__
void refresh() {index = coordinates.x();};
__cuda_callable__
const IndexType& getIndex() const { return this->index; };
protected:
const GridType& grid;
CoordinatesType coordinates;
IndexType index;
};
template< typename Real,
typename Device,
typename Index >
class SimpleCell< Meshes::Grid< 2, Real, Device, Index > >
{
public:
using GridType = Meshes::Grid< 1, Real, Device, Index >;
using RealType = typename GridType::RealType;
using DeviceType = typename GridType::DeviceType;
using IndexType = typename GridType::IndexType;
using CoordinatesType = typename GridType::CoordinatesType;
constexpr static int getEntityDimension() { return 2; };
};
template< typename Real,
typename Device,
typename Index >
class SimpleCell< Meshes::Grid< 3, Real, Device, Index > >
{
public:
using GridType = Meshes::Grid< 1, Real, Device, Index >;
using RealType = typename GridType::RealType;
using DeviceType = typename GridType::DeviceType;
using IndexType = typename GridType::IndexType;
using CoordinatesType = typename GridType::CoordinatesType;
constexpr static int getEntityDimension() { return 3; };
};
} // namespace Traversers
} // namespace Benchmarks
} // namespace TNL
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