Commit a5400d89 authored by Sebastian Eibl's avatar Sebastian Eibl

reworked benchmark structure

parent a40b3c5c
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file Accessor.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const walberla::real_t& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass();}
walberla::real_t& getInvMassRef(const size_t p_idx) {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass();}
void setInvMass(const size_t p_idx, const walberla::real_t& v) { ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvMass() = v;}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF();}
auto& getInvInertiaBFRef(const size_t p_idx) {return ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF();}
void setInvInertiaBF(const size_t p_idx, const Mat3& v) { ss_->shapes[ps_->getShapeIDRef(p_idx)]->getInvInertiaBF() = v;}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
} // namespace mesa_pd
} // namespace walberla
......@@ -2,13 +2,13 @@ waLBerla_link_files_to_builddir( *.cfg )
waLBerla_link_files_to_builddir( *.py )
waLBerla_add_executable ( NAME PE_GranularGas
FILES PE_GranularGas.cpp
FILES PE_GranularGas.cpp SQLProperties.cpp Parameters.cpp NodeTimings.cpp
DEPENDS blockforest core pe postprocessing )
waLBerla_add_executable ( NAME MESA_PD_GranularGas
FILES MESA_PD_GranularGas.cpp
FILES MESA_PD_GranularGas.cpp SQLProperties.cpp Parameters.cpp NodeTimings.cpp sortParticleStorage.cpp CreateParticles.cpp
DEPENDS blockforest core pe mesa_pd postprocessing vtk )
waLBerla_add_executable ( NAME MESA_PD_KernelBenchmark
FILES MESA_PD_KernelBenchmark.cpp
FILES MESA_PD_KernelBenchmark.cpp SQLProperties.cpp Parameters.cpp NodeTimings.cpp sortParticleStorage.cpp CreateParticles.cpp
DEPENDS blockforest core pe mesa_pd postprocessing vtk )
# -*- coding: utf-8 -*-
from jinja2 import Environment, FileSystemLoader
import os
class Parameter:
def __init__(self, name, type, defValue=""):
"""Propery of a data strcuture
Parameters
----------
name : str
name of the property
type : str
type of the property
defValue : str
default value the property should be initialized with
"""
self.name = name
self.type = type
self.defValue = defValue
def __str__(self):
return "name: {}, type: {}, defValue: {}".format(self.name, self.type, self.defValue)
class Config:
def __init__(self):
self.parameters = []
def parameterExists(self, name):
for v in self.parameters:
if v.name==name:
return True
return False
def addParameter(self, name, type, defValue):
if self.parameterExists( name ):
print("parameters already added: " + name)
else:
self.parameters.append( Parameter(name, type, defValue) )
def generateFile(self, template):
context = dict()
context["parameters"] = self.parameters
path = ""
filename = template.replace(".templ", "")
dirname = os.path.dirname(__file__)
env = Environment(loader=FileSystemLoader(dirname))
print("generating: " + path + filename)
fout = open(path + filename, "wb")
content = env.get_template(template).render(context)
fout.write(content.encode('utf8'))
fout.close()
def generate(self):
print("="*90)
print("Config File:")
print("")
print("{0: <30}{1: <30}{2: <30}".format("Name", "Type", "Def. Value"))
print("="*90)
for param in self.parameters:
print("{0: <30.29}{1: <30.29}{2: <30.29}".format(param.name, param.type, param.defValue))
print("="*90)
self.generateFile("Parameters.templ.h")
self.generateFile("Parameters.templ.cpp")
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file Contact.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include <mesa_pd/data/DataTypes.h>
namespace walberla {
namespace mesa_pd {
struct Contact
{
Contact(const size_t idx1,
const size_t idx2,
const Vec3 contactPoint,
const Vec3 contactNormal,
const real_t penetrationDepth)
: idx1_(idx1)
, idx2_(idx2)
, contactPoint_(contactPoint)
, contactNormal_(contactNormal)
, penetrationDepth_(penetrationDepth) {}
size_t idx1_;
size_t idx2_;
Vec3 contactPoint_;
Vec3 contactNormal_;
real_t penetrationDepth_;
};
} // namespace mesa_pd
} // namespace walberla
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file CreateParticles.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include "CreateParticles.h"
namespace walberla {
namespace mesa_pd {
data::ParticleStorage::iterator createPlane( data::ParticleStorage& ps,
data::ShapeStorage& ss,
const Vec3& pos,
const Vec3& normal )
{
auto p0 = ps.create(true);
p0->getPositionRef() = pos;
p0->getShapeIDRef() = ss.create<data::HalfSpace>( normal );
p0->getOwnerRef() = walberla::mpi::MPIManager::instance()->rank();
p0->getTypeRef() = 0;
data::particle_flags::set(p0->getFlagsRef(), data::particle_flags::INFINITE);
data::particle_flags::set(p0->getFlagsRef(), data::particle_flags::FIXED);
data::particle_flags::set(p0->getFlagsRef(), data::particle_flags::NON_COMMUNICATING);
return p0;
}
data::ParticleStorage::iterator createSphere( data::ParticleStorage& ps,
const Vec3& pos,
const real_t& radius,
const uint64_t shapeID)
{
auto p = ps.create();
p->getPositionRef() = pos;
p->getInteractionRadiusRef() = radius;
p->getShapeIDRef() = shapeID;
p->getOwnerRef() = walberla::MPIManager::instance()->rank();
p->getTypeRef() = 0;
return p;
}
} // namespace mesa_pd
} // namespace walberla
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file CreateParticles.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include <mesa_pd/data/DataTypes.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
#include <core/mpi/MPIManager.h>
namespace walberla {
namespace mesa_pd {
data::ParticleStorage::iterator createPlane( data::ParticleStorage& ps,
data::ShapeStorage& ss,
const Vec3& pos,
const Vec3& normal );
data::ParticleStorage::iterator createSphere( data::ParticleStorage& ps,
const Vec3& pos,
const real_t& radius,
const uint64_t shapeID);
} // namespace mesa_pd
} // namespace walberla
GranularGas
{
simulationCorner < 0, 0, 0 >;
simulationDomain < 6, 6, 6 >;
simulationDomain < 40, 40, 40 >;
blocks < 2,2,2 >;
isPeriodic < 1, 1, 1 >;
initialRefinementLevel 0;
sorting none;
radius 0.6;
spacing 1.0;
......
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file NodeTimings.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include "NodeTimings.h"
namespace walberla {
namespace mesa_pd {
void storeNodeTimings( const uint_t runId,
const std::string & dbFile,
const std::string & tableName,
const WcTimingPool & tp )
{
std::map< std::string, walberla::int64_t > integerProperties;
std::map< std::string, double > realProperties;
std::map< std::string, std::string > stringProperties;
walberla::mpi::SendBuffer sb;
walberla::mpi::RecvBuffer rb;
sb << walberla::getHostName();
sb << int64_t(walberla::mpi::MPIManager::instance()->rank());
sb << tp;
walberla::mpi::gathervBuffer(sb, rb);
WALBERLA_ROOT_SECTION()
{
while (!rb.isEmpty())
{
integerProperties.clear();
realProperties.clear();
stringProperties.clear();
std::string hostname;
int64_t rank;
WcTimingPool cTP;
rb >> hostname;
rb >> rank;
rb >> cTP;
stringProperties["hostname"] = hostname;
integerProperties["rank"] = rank;
for (auto& v : cTP)
{
realProperties[v.first] = v.second.average();
}
postprocessing::storeAdditionalRunInfoInSqliteDB( runId,
dbFile,
tableName,
integerProperties,
stringProperties,
realProperties );
}
}
}
} // namespace mesa_pd
} // namespace walberla
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file NodeTimings.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include <core/Abort.h>
#include <core/Hostname.h>
#include <core/mpi/Gatherv.h>
#include <core/logging/Logging.h>
#include <core/timing/TimingPool.h>
#include <postprocessing/sqlite/SQLite.h>
namespace walberla {
namespace mesa_pd {
void storeNodeTimings( const uint_t runId,
const std::string & dbFile,
const std::string & tableName,
const WcTimingPool & tp );
} // namespace mesa_pd
} // namespace walberla
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file Parameters.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#include "Parameters.h"
#include <core/logging/Logging.h>
namespace walberla {
void loadFromConfig(Parameters& params, const Config::BlockHandle& cfg)
{
params.sorting = cfg.getParameter<std::string>("sorting", "none" );
WALBERLA_LOG_INFO_ON_ROOT("sorting: " << params.sorting);
params.spacing = cfg.getParameter<real_t>("spacing", real_t(1.0) );
WALBERLA_LOG_INFO_ON_ROOT("spacing: " << params.spacing);
params.radius = cfg.getParameter<real_t>("radius", real_t(0.5) );
WALBERLA_LOG_INFO_ON_ROOT("radius: " << params.radius);
params.bBarrier = cfg.getParameter<bool>("bBarrier", false );
WALBERLA_LOG_INFO_ON_ROOT("bBarrier: " << params.bBarrier);
params.storeNodeTimings = cfg.getParameter<bool>("storeNodeTimings", false );
WALBERLA_LOG_INFO_ON_ROOT("storeNodeTimings: " << params.storeNodeTimings);
params.checkSimulation = cfg.getParameter<bool>("checkSimulation", false );
WALBERLA_LOG_INFO_ON_ROOT("checkSimulation: " << params.checkSimulation);
params.numOuterIterations = cfg.getParameter<int64_t>("numOuterIterations", 10 );
WALBERLA_LOG_INFO_ON_ROOT("numOuterIterations: " << params.numOuterIterations);
params.initialRefinementLevel = cfg.getParameter<int64_t>("initialRefinementLevel", 0 );
WALBERLA_LOG_INFO_ON_ROOT("initialRefinementLevel: " << params.initialRefinementLevel);
params.simulationSteps = cfg.getParameter<int64_t>("simulationSteps", 10 );
WALBERLA_LOG_INFO_ON_ROOT("simulationSteps: " << params.simulationSteps);
params.dt = cfg.getParameter<real_t>("dt", real_t(0.01) );
WALBERLA_LOG_INFO_ON_ROOT("dt: " << params.dt);
params.visSpacing = cfg.getParameter<int64_t>("visSpacing", 1000 );
WALBERLA_LOG_INFO_ON_ROOT("visSpacing: " << params.visSpacing);
params.path = cfg.getParameter<std::string>("path", "vtk_out" );
WALBERLA_LOG_INFO_ON_ROOT("path: " << params.path);
params.sqlFile = cfg.getParameter<std::string>("sqlFile", "benchmark.sqlite" );
WALBERLA_LOG_INFO_ON_ROOT("sqlFile: " << params.sqlFile);
}
void saveToSQL(const Parameters& params,
std::map< std::string, walberla::int64_t >& integerProperties,
std::map< std::string, double >& realProperties,
std::map< std::string, std::string >& stringProperties )
{
stringProperties["sorting"] = params.sorting;
realProperties["spacing"] = double_c(params.spacing);
realProperties["radius"] = double_c(params.radius);
integerProperties["numOuterIterations"] = params.numOuterIterations;
integerProperties["initialRefinementLevel"] = params.initialRefinementLevel;
integerProperties["simulationSteps"] = params.simulationSteps;
realProperties["dt"] = double_c(params.dt);
integerProperties["visSpacing"] = params.visSpacing;
stringProperties["path"] = params.path;
stringProperties["sqlFile"] = params.sqlFile;
}
} //namespace walberla
\ No newline at end of file
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file Parameters.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#pragma once
#include <core/config/Config.h>
#include <core/DataTypes.h>
#include <string>
namespace walberla {
struct Parameters
{
std::string sorting = "none";
real_t spacing = real_t(1.0);
real_t radius = real_t(0.5);
bool bBarrier = false;
bool storeNodeTimings = false;
bool checkSimulation = false;
int64_t numOuterIterations = 10;
int64_t initialRefinementLevel = 0;
int64_t simulationSteps = 10;
real_t dt = real_t(0.01);
int64_t visSpacing = 1000;
std::string path = "vtk_out";
std::string sqlFile = "benchmark.sqlite";
};
void loadFromConfig(Parameters& params,
const Config::BlockHandle& cfg);
void saveToSQL(const Parameters& params,
std::map< std::string, walberla::int64_t >& integerProperties,
std::map< std::string, double >& realProperties,
std::map< std::string, std::string >& stringProperties );
} //namespace walberla
\ No newline at end of file
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file Parameters.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#include "Parameters.h"
#include <core/logging/Logging.h>
namespace walberla {
void loadFromConfig(Parameters& params, const Config::BlockHandle& cfg)
{
{%- for param in parameters %}
params.{{param.name}} = cfg.getParameter<{{param.type}}>("{{param.name}}", {{param.defValue}} );
WALBERLA_LOG_INFO_ON_ROOT("{{param.name}}: " << params.{{param.name}});
{% endfor %}
}
void saveToSQL(const Parameters& params,
std::map< std::string, walberla::int64_t >& integerProperties,
std::map< std::string, double >& realProperties,
std::map< std::string, std::string >& stringProperties )
{
{%- for param in parameters %}
{%- if param.type=="int64_t" %}
integerProperties["{{param.name}}"] = params.{{param.name}};
{%- endif %}
{%- if param.type=="real_t" %}
realProperties["{{param.name}}"] = double_c(params.{{param.name}});
{%- endif %}
{%- if param.type=="std::string" %}
stringProperties["{{param.name}}"] = params.{{param.name}};
{%- endif %}
{% endfor %}
}
} //namespace walberla
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file Parameters.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#pragma once
#include <core/config/Config.h>
#include <core/DataTypes.h>
#include <string>
namespace walberla {
struct Parameters
{
{%- for param in parameters %}
{{param.type}} {{param.name}} = {{param.defValue}};
{%- endfor %}
};
void loadFromConfig(Parameters& params,
const Config::BlockHandle& cfg);
void saveToSQL(const Parameters& params,
std::map< std::string, walberla::int64_t >& integerProperties,
std::map< std::string, double >& realProperties,
std::map< std::string, std::string >& stringProperties );
} //namespace walberla
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//