Peano
Loading...
Searching...
No Matches
KernelBenchmarksFVRusanov-main.cpp File Reference
#include "KernelBenchmarksFVRusanov-main.h"
#include "config.h"
#include "Constants.h"
#include "repositories/DataRepository.h"
#include "repositories/SolverRepository.h"
#include "repositories/StepRepository.h"
#include "tasks/FVRusanovEnclaveTask.h"
#include "peano4/peano.h"
#include "tarch/NonCriticalAssertions.h"
#include "tarch/accelerator/accelerator.h"
#include "tarch/accelerator/Device.h"
#include "tarch/multicore/multicore.h"
#include "tarch/multicore/Core.h"
#include "tarch/multicore/BooleanSemaphore.h"
#include "tarch/multicore/Lock.h"
#include "tarch/logging/Log.h"
#include "tarch/timing/Measurement.h"
#include "tarch/timing/Watch.h"
#include <cstring>
#include <fenv.h>
Include dependency graph for KernelBenchmarksFVRusanov-main.cpp:

Go to the source code of this file.

Functions

void initInputData (double *Q)
 Set input data.
void allocateAndStoreOutcome (const double *const *Q, const double *const maxEigenvalue, const int numberOfPatches)
 Allocates and stores outcome of one compute kernel.
void freeOutcome (const int numberOfPatches)
void validateOutcome (const double *const *Q, const double *const maxEigenvalue, const int numberOfPatches)
 Validate data against pre-stored simulation outcome.
void reportRuntime (const std::string &kernelIdentificator, const tarch::timing::Measurement &timingKernelLaunch, int numberOfPatches)
 Reports the runtime and throughput of the benchmarks.
template<void(*)(exahype2::CellData< double, double > &, tarch::timing::Measurement &, peano4::utils::LoopPlacement) Kernel, peano4::utils::LoopPlacement loopPlacement>
void wrapHostKernel (int device, exahype2::CellData< double, double > &patchData)
 We want to use all kernels exactly the same way.
template<void(*)(int, exahype2::CellData< double, double > &, tarch::timing::Measurement &) Kernel>
void wrapDeviceKernel (int device, exahype2::CellData< double, double > &patchData)
void runBenchmarks (int numberOfPatches)
 Run the benchmark for one particular number of patches.
int main (int argc, char **argv)
 Main routine of the SPH code.

Variables

tarch::logging::Log _log ("::")
constexpr double TimeStamp = 0.5
constexpr double TimeStepSize = 1e-6
constexpr double CellSize = 0.1
constexpr double CellOffset = 4.0
constexpr int HaloSize = 1
constexpr int NumberOfInputEntriesPerPatch
constexpr int NumberOfOutputEntriesPerPatch
constexpr int NumberOfFiniteVolumesPerPatch
double ** validQ = nullptr
doublevalidMaxEigenvalue = nullptr
bool outcomeIsInvalid = false
tarch::timing::Measurement timingComputeKernel

Function Documentation

◆ allocateAndStoreOutcome()

void allocateAndStoreOutcome ( const double *const * Q,
const double *const maxEigenvalue,
const int numberOfPatches )

Allocates and stores outcome of one compute kernel.

Make a persistent snapshot of a solution and assume, from hereon, that this snapshot is the valid data. You can call this routine as often as you want. Only the very first call will trigger a snapshot.

Note: needs to freed using the freeOutcome() routine.

Definition at line 99 of file KernelBenchmarksFVRusanov-main.cpp.

References logInfo, NumberOfOutputEntriesPerPatch, validMaxEigenvalue, and validQ.

Referenced by runBenchmarks().

Here is the caller graph for this function:

◆ freeOutcome()

void freeOutcome ( const int numberOfPatches)

Definition at line 116 of file KernelBenchmarksFVRusanov-main.cpp.

References validMaxEigenvalue, and validQ.

Referenced by main().

Here is the caller graph for this function:

◆ initInputData()

void initInputData ( double * Q)

Set input data.

We really don't care if this makes any sense. Just make the data reasonably smooth and ensure that all is positive, as there are density and energy among the unknowns. If they become negative or zero, the compute kernels do not make any sense anymore.

Definition at line 84 of file KernelBenchmarksFVRusanov-main.cpp.

References NumberOfInputEntriesPerPatch, and tarch::la::PI.

Referenced by runBenchmarks().

Here is the caller graph for this function:

◆ main()

◆ reportRuntime()

void reportRuntime ( const std::string & kernelIdentificator,
const tarch::timing::Measurement & timingKernelLaunch,
int numberOfPatches )

Reports the runtime and throughput of the benchmarks.

First set of outputs refers to the time of the compute kernel itself. Second set of outputs refers to the time including the kernel launch overhead. The throughput is measured in the updates of volumes per second (dof/s).

Definition at line 198 of file KernelBenchmarksFVRusanov-main.cpp.

References tarch::timing::Measurement::getValue(), logInfo, NumberOfFiniteVolumesPerPatch, timingComputeKernel, and tarch::timing::Measurement::toString().

Referenced by runBenchmarks().

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

◆ runBenchmarks()

void runBenchmarks ( int numberOfPatches)

Run the benchmark for one particular number of patches.

Parameters
numberOfPatchesNumber of patches to study

Definition at line 243 of file KernelBenchmarksFVRusanov-main.cpp.

References allocateAndStoreOutcome(), tarch::allocateMemory(), assessKernel(), exahype2::CellData< inType, outType >::cellCentre, CellOffset, CellSize, exahype2::CellData< inType, outType >::cellSize, exahype2::CellData< inType, outType >::dt, endParallelFor, tarch::freeMemory(), tarch::timing::Watch::getCalendarTime(), HaloSize, tarch::Heap, tarch::accelerator::Device::HostDevice, initInputData(), tarch::ManagedSharedAcceleratorDeviceMemory, exahype2::CellData< inType, outType >::maxEigenvalue, NumberOfInputEntriesPerPatch, NumberOfOutputEntriesPerPatch, parallelFor, exahype2::CellData< inType, outType >::QIn, exahype2::CellData< inType, outType >::QOut, reportRuntime(), peano4::utils::Serial, tarch::timing::Measurement::setValue(), peano4::utils::SpreadOut, tarch::timing::Watch::stop(), exahype2::CellData< inType, outType >::t, TimeStamp, TimeStepSize, exahype2::fv::rusanov::omp::timeStepWithRusanovBatchedHeapStateless(), exahype2::fv::rusanov::cpp::timeStepWithRusanovBatchedUSMStateless(), exahype2::fv::rusanov::sycl::timeStepWithRusanovBatchedUSMStateless(), exahype2::fv::rusanov::omp::timeStepWithRusanovPatchwiseHeapStateless(), exahype2::fv::rusanov::cpp::timeStepWithRusanovPatchwiseUSMStateless(), exahype2::fv::rusanov::sycl::timeStepWithRusanovPatchwiseUSMStateless(), exahype2::fv::rusanov::sycl::timeStepWithRusanovTaskgraphUSMStateless(), timingComputeKernel, validateOutcome(), void, wrapDeviceKernel(), and wrapHostKernel().

Referenced by main().

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

◆ validateOutcome()

void validateOutcome ( const double *const * Q,
const double *const maxEigenvalue,
const int numberOfPatches )

Validate data against pre-stored simulation outcome.

Works if and only if storeOutcome has been performed before. Does not abort in case there are errors. If there are errors, we return a status code != 0.

Definition at line 135 of file KernelBenchmarksFVRusanov-main.cpp.

References std::abs(), tarch::la::equals(), logError, NumberOfOutputEntriesPerPatch, outcomeIsInvalid, validMaxEigenvalue, and validQ.

Referenced by runBenchmarks().

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

◆ wrapDeviceKernel()

void wrapDeviceKernel ( int device,
exahype2::CellData< double, double > & patchData )

◆ wrapHostKernel()

void wrapHostKernel ( int device,
exahype2::CellData< double, double > & patchData )

We want to use all kernels exactly the same way.

However, the various kernels all have slightly different signatures. So we write small helper functions (wrappers) which map the generic test signature onto the specific kernel.

To make this possible, all parameters which are not part of the generic interface, i.e., which are not patch data or the boolean, have to be mapped onto template arguments.

Definition at line 227 of file KernelBenchmarksFVRusanov-main.cpp.

References assertionEquals, tarch::accelerator::Device::HostDevice, and timingComputeKernel.

Variable Documentation

◆ _log

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

◆ CellOffset

double CellOffset = 4.0
constexpr

Definition at line 40 of file KernelBenchmarksFVRusanov-main.cpp.

◆ CellSize

double CellSize = 0.1
constexpr

Definition at line 39 of file KernelBenchmarksFVRusanov-main.cpp.

◆ HaloSize

int HaloSize = 1
constexpr

Definition at line 41 of file KernelBenchmarksFVRusanov-main.cpp.

◆ NumberOfFiniteVolumesPerPatch

int NumberOfFiniteVolumesPerPatch
constexpr
Initial value:
= FVRusanov::NumberOfFiniteVolumesPerAxisPerPatch
* FVRusanov::NumberOfFiniteVolumesPerAxisPerPatch

Definition at line 61 of file KernelBenchmarksFVRusanov-main.cpp.

◆ NumberOfInputEntriesPerPatch

int NumberOfInputEntriesPerPatch
constexpr
Initial value:
= (FVRusanov::NumberOfFiniteVolumesPerAxisPerPatch + 2 * HaloSize)
* (FVRusanov::NumberOfFiniteVolumesPerAxisPerPatch + 2 * HaloSize)
* (FVRusanov::NumberOfUnknowns + FVRusanov::NumberOfAuxiliaryVariables)
static constexpr int HaloSize

Definition at line 45 of file KernelBenchmarksFVRusanov-main.cpp.

◆ NumberOfOutputEntriesPerPatch

int NumberOfOutputEntriesPerPatch
constexpr
Initial value:
= (FVRusanov::NumberOfFiniteVolumesPerAxisPerPatch + 0)
* (FVRusanov::NumberOfFiniteVolumesPerAxisPerPatch + 0)
* (FVRusanov::NumberOfUnknowns + FVRusanov::NumberOfAuxiliaryVariables)

Definition at line 53 of file KernelBenchmarksFVRusanov-main.cpp.

◆ outcomeIsInvalid

bool outcomeIsInvalid = false

Definition at line 72 of file KernelBenchmarksFVRusanov-main.cpp.

◆ TimeStamp

double TimeStamp = 0.5
constexpr

Definition at line 37 of file KernelBenchmarksFVRusanov-main.cpp.

◆ TimeStepSize

double TimeStepSize = 1e-6
constexpr

Definition at line 38 of file KernelBenchmarksFVRusanov-main.cpp.

◆ timingComputeKernel

tarch::timing::Measurement timingComputeKernel

Definition at line 74 of file KernelBenchmarksFVRusanov-main.cpp.

◆ validMaxEigenvalue

double* validMaxEigenvalue = nullptr

Definition at line 71 of file KernelBenchmarksFVRusanov-main.cpp.

◆ validQ

double** validQ = nullptr

Definition at line 70 of file KernelBenchmarksFVRusanov-main.cpp.