Peano
Loading...
Searching...
No Matches
BenchmarkDriver.cpp File Reference
#include <algorithm>
#include <cstring>
#include <random>
#include "Benchmarks-main.h"
#include "Constants.h"
#include "tarch/NonCriticalAssertions.h"
#include "tarch/logging/Log.h"
#include "tarch/multicore/multicore.h"
#include "tarch/multicore/Core.h"
#include "peano4/peano.h"
#include "peano4/grid/Spacetree.h"
#include "peano4/parallel/SpacetreeSet.h"
#include "repositories/DataRepository.h"
#include "repositories/StepRepository.h"
#include "repositories/GlobalState.h"
#include "swift2/UserInterface.h"
#include "swift2/kernels/legacy/Density.h"
#include "swift2/kernels/legacy/HydroForce.h"
#include "swift2/kernels/legacy/Leapfrog.h"
#include "swift2/kernels/legacy/SmoothingLength.h"
#include "swift2/timestepping/Leapfrog.h"
#include "swift2/timestepping/TimeStepping.h"
#include "swift2/kernels/ParticleSetIterators.h"
#include "NohProblem.h"
#include "tarch/timing/Measurement.h"
#include "tarch/multicore/otter.h"
#include "globaldata/HydroPart.h"
#include "vertexdata/HydroPartSet.h"
Include dependency graph for BenchmarkDriver.cpp:

Go to the source code of this file.

Functions

void initParticle (globaldata::HydroPart &particle, int numberOfParticles, int index)
 Initialise the particles with some meaningful information.
void initParticles (int numberOfParticles, bool initScatteredData)
void validateOutcomes (const std::string &name, int numberOfParticles)
 Validate the scattered data against the continuous data.
void prepareForceBenchmark (int numberOfParticles, bool initScatteredData)
 Prepare the force benchmark.
std::vector< intCoalescedMemoryIndices (TwoPowerD)
std::vector< intScatteredMemoryIndices (1)
void createCoalescedMemoryIndices ()
 Create CoalescedMemory particle indicator.
void allocateParticles (int numberOfParticles)
void deleteParticles (int numberOfParticles)
void assessKernel (std::function< void(int) > kernelCallInLoop, const std::string &name, int numberOfParticles, bool firstAssessCallForThisProgramPhase)
void runBenchmark (int numberOfParticles)
void initGridTraversalEvent ()
 Initialise the global variable gridTraversalEvent.
int main (int argc, char **argv)
 Main routine of the SPH code.

Variables

tarch::logging::Log _log ("::")
peano4::grid::GridTraversalEvent gridTraversalEvent
 See initGridTraversalEvent()
vertexdata::HydroPartSet * workItemParticleSet
globaldata::HydroPart * scatteredWorkItems
vertexdata::HydroPartSet * scatteredWorkItemParticleSet

Function Documentation

◆ allocateParticles()

void allocateParticles ( int numberOfParticles)

Definition at line 299 of file BenchmarkDriver.cpp.

References tarch::allocateMemory(), assertionEquals, tarch::Heap, scatteredWorkItemParticleSet, scatteredWorkItems, and workItemParticleSet.

Referenced by runBenchmark().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assessKernel()

void assessKernel ( std::function< void(int) > kernelCallInLoop,
const std::string & name,
int numberOfParticles,
bool firstAssessCallForThisProgramPhase )
Parameters
firstAssessCallForThisProgramPhaseIf it is true, we do not check the continuous data structure against the scattered one.

Definition at line 357 of file BenchmarkDriver.cpp.

References tarch::timing::Watch::getCalendarTime(), tarch::timing::Measurement::getValue(), logInfo, benchmarks::name, tarch::timing::Measurement::setValue(), tarch::timing::Watch::stop(), tarch::timing::Measurement::toString(), and validateOutcomes().

Referenced by runBenchmark(), runBenchmarks(), and runBenchmarks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CoalescedMemoryIndices()

std::vector< int > CoalescedMemoryIndices ( TwoPowerD )

References TwoPowerD.

Referenced by createCoalescedMemoryIndices(), and runBenchmark().

Here is the caller graph for this function:

◆ createCoalescedMemoryIndices()

void createCoalescedMemoryIndices ( )

Create CoalescedMemory particle indicator.

Whenever we enter a cell, we are given all the particles associated to the \( 2^d \) vertices of the cell as one big container. If we work with CoalescedMemory storage schemes, these particles will technically be stored as \( 2^d \) continuous sequences. In the benchmark, all particles of one work item are held in one continuous sequence, which is a special case of this. Nevertheless, we create a vector of integeres, which pretends that they were split up further.

So if chunk has 18 entries, it might, in 2d, holds the entries 5,5,5,3.

Definition at line 284 of file BenchmarkDriver.cpp.

References CoalescedMemoryIndices(), ScatteredMemoryIndices(), and TwoPowerD.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteParticles()

void deleteParticles ( int numberOfParticles)

◆ initGridTraversalEvent()

void initGridTraversalEvent ( )

Initialise the global variable gridTraversalEvent.

We work with one big traversal event which represents the unit square/cube. It is not refined, and none of the adjacent vertices are hanging. The traversal event is not used directly, but the markers are derived from it later throughout the benchmark run.

Definition at line 1353 of file BenchmarkDriver.cpp.

References gridTraversalEvent.

Referenced by main().

Here is the caller graph for this function:

◆ initParticle()

void initParticle ( globaldata::HydroPart & particle,
int numberOfParticles,
int index )

Initialise the particles with some meaningful information.

We basically spread them out evenly (so there's no division by zero if we compute distances) and then use the Noh2d setup to give each particle a meaningful value.

Definition at line 70 of file BenchmarkDriver.cpp.

References benchmarks::swift2::hydro::kernel_throughput::initNohProblemIC().

Referenced by initParticles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initParticles()

void initParticles ( int numberOfParticles,
bool initScatteredData )

Definition at line 103 of file BenchmarkDriver.cpp.

References initParticle(), scatteredWorkItemParticleSet, and workItemParticleSet.

Referenced by prepareForceBenchmark(), and runBenchmark().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

◆ prepareForceBenchmark()

void prepareForceBenchmark ( int numberOfParticles,
bool initScatteredData )

Prepare the force benchmark.

To prepare for the force benchmark, we run through the following steps:

  • Initialise the particles through an initParticles() call. This initialises the workItemParticleSet sequence.
  • invoke resetSmoothingLengthIterationCounter() and resetAcceleration() on the particles. For this, we run over all the workItemParticleSets and, within each set, use the forAllParticles function to initialise the particles.

Definition at line 232 of file BenchmarkDriver.cpp.

References swift2::kernels::alwaysUpdateInVertexKernel(), swift2::kernels::forAllParticles(), swift2::kernels::kernelrealisation::Generic, gridTraversalEvent, initParticles(), swift2::kernels::legacy::resetAcceleration(), swift2::kernels::legacy::resetSmoothingLengthIterationCounter(), scatteredWorkItemParticleSet, and workItemParticleSet.

Referenced by runBenchmark().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runBenchmark()

void runBenchmark ( int numberOfParticles)

Definition at line 386 of file BenchmarkDriver.cpp.

References allocateParticles(), swift2::kernels::alwaysUpdateInVertexKernel(), swift2::kernels::alwaysUpdateParticlePairs(), assessKernel(), swift2::kernels::kernelrealisation::CoalescedMemory, swift2::kernels::kernelrealisation::CoalescedMemoryActiveLocal, swift2::kernels::kernelrealisation::CoalescedMemoryActiveLocalOffload, CoalescedMemoryIndices(), swift2::kernels::kernelrealisation::CoalescedMemoryLocalActive, swift2::kernels::kernelrealisation::CoalescedMemoryLocalActiveOffload, swift2::kernels::kernelrealisation::CoalescedMemoryOffload, deleteParticles(), swift2::kernels::legacy::densityKernel(), swift2::kernels::legacy::densityKernelEvaluatePairInteractionPredicate(), swift2::kernels::legacy::densityKernelUpdateParticlePredicate(), swift2::kernels::kernelrealisation::EvaluatePredicateInPrologue, swift2::kernels::kernelrealisation::EvaluatePredicateInPrologueActiveLocal, swift2::kernels::kernelrealisation::EvaluatePredicateInPrologueLocalActive, swift2::kernels::forAllParticlePairs(), swift2::kernels::forAllParticles(), swift2::kernels::legacy::forceKernelEvaluatePairInteractionPredicate(), swift2::kernels::legacy::forceKernelUpdateParticlePredicate(), swift2::kernels::kernelrealisation::Generic, swift2::kernels::kernelrealisation::GenericOffload, gridTraversalEvent, initParticles(), swift2::kernels::legacy::leapfrogDriftWithGlobalTimeStepSize(), swift2::kernels::legacy::leapfrogDriftWithGlobalTimeStepSizeParticleUpdatePredicate(), swift2::kernels::legacy::leapfrogKickWithGlobalTimeStepSize(), logInfo, prepareForceBenchmark(), swift2::timestepping::resetMovedParticleMarker(), swift2::kernels::legacy::resetPredictedValues(), scatteredWorkItemParticleSet, and workItemParticleSet.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScatteredMemoryIndices()

std::vector< int > ScatteredMemoryIndices ( 1 )

Referenced by createCoalescedMemoryIndices().

Here is the caller graph for this function:

◆ validateOutcomes()

void validateOutcomes ( const std::string & name,
int numberOfParticles )

Validate the scattered data against the continuous data.

We assume that the benchmark always assesses the generic kernel operating on scattered data first and that there's exactly one run with this data set. That means that we can assume that the scattered data is our validation data and the kernels over the continuous dataset have to yield exactly the same outcome. We validate this here.

Definition at line 136 of file BenchmarkDriver.cpp.

References tarch::la::equals(), benchmarks::name, scatteredWorkItemParticleSet, and workItemParticleSet.

Referenced by assessKernel().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _log

tarch::logging::Log _log("::") ( "::" )

◆ gridTraversalEvent

◆ scatteredWorkItemParticleSet

vertexdata::HydroPartSet* scatteredWorkItemParticleSet

◆ scatteredWorkItems

globaldata::HydroPart* scatteredWorkItems

Definition at line 58 of file BenchmarkDriver.cpp.

Referenced by allocateParticles(), and deleteParticles().

◆ workItemParticleSet

vertexdata::HydroPartSet* workItemParticleSet