29 #include "exahype2/CellData.h"
30 #include "kernels/AderSolver/BufferSizes.h"
31 #include "kernels/AderSolver/FaceIntegral.h"
32 #include "kernels/AderSolver/FusedSpaceTimePredictorVolumeIntegral.h"
33 #include "kernels/AderSolver/MaxScaledEigenvalue.h"
34 #include "kernels/AderSolver/RiemannSolver.h"
35 #include "repositories/SolverRepository.h"
46 exahype2::CellData<SolverPrecision, SolverPrecision>* myCellData,
50 tarch::timing::Measurement& measurement
55 SolverPrecision* lQhbnd[2 * DIMENSIONS] = {
56 myFaceData->
QIn[faceId][0],
57 myFaceData->
QIn[faceId][1],
59 myFaceData->
QIn[faceId][2],
61 myFaceData->
QIn[faceId][DIMENSIONS + 0],
62 myFaceData->
QIn[faceId][DIMENSIONS + 1]
65 myFaceData->
QIn[faceId][DIMENSIONS + 2]
69 SolverPrecision* lFhbnd[2 * DIMENSIONS] = {
70 myFaceData->
QOut[faceId][0],
71 myFaceData->
QOut[faceId][1],
73 myFaceData->
QOut[faceId][2],
75 myFaceData->
QOut[faceId][DIMENSIONS + 0],
76 myFaceData->
QOut[faceId][DIMENSIONS + 1]
79 myFaceData->
QOut[faceId][DIMENSIONS + 2]
83 tarch::timing::Watch watchKernelCompute(
"::runBenchmarks",
"assessKernel(...)",
false);
85 int numberOfIterations = kernels::AderSolver::fusedSpaceTimePredictorVolumeIntegral<SolverPrecision, SolverPrecision, SolverPrecision>(
86 repositories::instanceOfAderSolver,
89 myCellData->QIn[cellId],
90 myCellData->cellCentre[cellId],
91 myCellData->cellSize[cellId],
96 watchKernelCompute.stop();
97 measurement.setValue(watchKernelCompute.getCalendarTime());
102 const int leftFaceId,
103 const int rightFaceId,
104 const int faceDirection,
105 tarch::timing::Measurement& measurement
108 tarch::timing::Watch watchKernelCompute(
"::runBenchmarks",
"assessKernel(...)",
false);
114 kernels::AderSolver::riemannSolver<SolverPrecision>(
115 repositories::instanceOfAderSolver,
116 myFaceData->
QOut[leftFaceId][faceDirection + DIMENSIONS],
117 myFaceData->
QOut[rightFaceId][faceDirection],
118 myFaceData->
QIn[leftFaceId][faceDirection + DIMENSIONS],
119 myFaceData->
QIn[rightFaceId][faceDirection],
120 0.5 * (myFaceData->
t[leftFaceId] + myFaceData->
t[rightFaceId]),
121 0.5 * (myFaceData->
dt[leftFaceId] + myFaceData->
dt[rightFaceId]),
123 0.5 * (myFaceData->
cellSize[leftFaceId] + myFaceData->
cellSize[rightFaceId]),
129 watchKernelCompute.stop();
130 measurement.setValue(watchKernelCompute.getCalendarTime());
134 exahype2::CellData<SolverPrecision, SolverPrecision>* myCellData,
138 tarch::timing::Measurement& measurement
143 SolverPrecision* lQhbnd[2 * DIMENSIONS] = {
144 myFaceData->
QIn[faceId][0],
145 myFaceData->
QIn[faceId][1],
147 myFaceData->
QIn[faceId][2],
149 myFaceData->
QIn[faceId][DIMENSIONS + 0],
150 myFaceData->
QIn[faceId][DIMENSIONS + 1]
153 myFaceData->
QIn[faceId][DIMENSIONS + 2]
157 SolverPrecision* lFhbnd[2 * DIMENSIONS] = {
158 myFaceData->
QOut[faceId][0],
159 myFaceData->
QOut[faceId][1],
161 myFaceData->
QOut[faceId][2],
163 myFaceData->
QOut[faceId][DIMENSIONS + 0],
164 myFaceData->
QOut[faceId][DIMENSIONS + 1]
167 myFaceData->
QOut[faceId][DIMENSIONS + 2]
171 tarch::timing::Watch watchKernelCompute(
"::runBenchmarks",
"assessKernel(...)",
false);
173 for (
int d = 0; d < DIMENSIONS; d++) {
174 const int direction = d;
176 const double inverseDxDirection = 1.0 / myCellData->cellSize[cellId][d];
178 kernels::AderSolver::faceIntegral(
179 myCellData->QIn[cellId],
180 myFaceData->
QOut[faceId][d],
188 kernels::AderSolver::faceIntegral(
189 myCellData->QIn[cellId],
190 myFaceData->
QOut[faceId][d + DIMENSIONS],
199 myCellData->maxEigenvalue[cellId] = kernels::AderSolver::maxScaledEigenvalue(
200 repositories::instanceOfAderSolver,
201 myCellData->QIn[cellId],
202 myCellData->cellCentre[cellId],
203 myCellData->cellSize[cellId],
208 int numberOfIterations = kernels::AderSolver::fusedSpaceTimePredictorVolumeIntegral<SolverPrecision, SolverPrecision, SolverPrecision>(
209 repositories::instanceOfAderSolver,
212 myCellData->QIn[cellId],
213 myCellData->cellCentre[cellId],
214 myCellData->cellSize[cellId],
219 watchKernelCompute.stop();
220 measurement.setValue(watchKernelCompute.getCalendarTime());
228 const tarch::la::Vector<DIMENSIONS, double>
cellCenter,
229 const tarch::la::Vector<DIMENSIONS, double>
cellSize
234 exahype2::CellData<SolverPrecision, SolverPrecision> cellData(numberOfCells);
237 for (
int cellIndex = 0; cellIndex < numberOfCells; cellIndex++) {
238 cellData.QIn[cellIndex] = tarch::allocateMemory<SolverPrecision>(
240 tarch::MemoryLocation::Heap
244 cellData.QOut[cellIndex] =
nullptr;
247 cellData.cellSize[cellIndex] =
cellSize;
248 cellData.maxEigenvalue[cellIndex] = 0.0;
253 for (
int i = 0; i < 2 * DIMENSIONS; i++) {
254 cellFaceData.
QIn[cellIndex][i] = tarch::allocateMemory<SolverPrecision>(
255 kernels::AderSolver::getBndFaceSize(),
256 tarch::MemoryLocation::Heap
258 cellFaceData.
QOut[cellIndex][i] = tarch::allocateMemory<SolverPrecision>(
259 kernels::AderSolver::getBndFluxSize(),
260 tarch::MemoryLocation::Heap
272 int numberOfThreads = 1;
274 #if defined(WITH_OPENMP)
275 for (
int threadIndex = 0; threadIndex < NumberOfLaunchingThreads.size(); threadIndex++) {
276 numberOfThreads = NumberOfLaunchingThreads[threadIndex];
280 for (
int cellIndex = 0; cellIndex < numberOfCells; cellIndex++) {
285 tarch::timing::Measurement timingKernelLaunch;
287 for (
int sample = 0; sample <= NumberOfSamples; sample++) {
289 tarch::timing::Watch watchKernelLaunch(
"::runBenchmarks",
"assessKernel(...)",
false);
291 #if defined(WITH_OPENMP)
292 #pragma omp parallel for num_threads(NumberOfLaunchingThreads[threadIndex])
294 for (
int cellIndex = 0; cellIndex < numberOfCells; cellIndex++) {
301 #if defined(WITH_OPENMP)
302 #pragma omp parallel for num_threads(NumberOfLaunchingThreads[threadIndex])
304 for (
int cellIndex = 0; cellIndex < numberOfCells; cellIndex++) {
305 cellData.maxEigenvalue[cellIndex] = 0.0;
309 watchKernelLaunch.stop();
310 timingKernelLaunch.setValue(watchKernelLaunch.getCalendarTime());
317 #if defined(WITH_OPENMP)
321 for (
int cellIndex = 0; cellIndex < numberOfCells; cellIndex++) {
322 tarch::freeMemory(cellData.QIn[cellIndex], tarch::MemoryLocation::Heap);
323 tarch::freeMemory(cellData.QOut[cellIndex], tarch::MemoryLocation::Heap);
325 for (
int i = 0; i < 2 * DIMENSIONS; i++) {
326 tarch::freeMemory(cellFaceData.
QIn[cellIndex][i], tarch::MemoryLocation::Heap);
327 tarch::freeMemory(cellFaceData.
QOut[cellIndex][i], tarch::MemoryLocation::Heap);
void secondTask(exahype2::CellData< SolverPrecision, SolverPrecision > *myCellData, exahype2::CellFaceData< SolverPrecision, SolverPrecision > *myFaceData, const int cellId, const int faceId, tarch::timing::Measurement &measurement)
void initialTask(exahype2::CellData< SolverPrecision, SolverPrecision > *myCellData, exahype2::CellFaceData< SolverPrecision, SolverPrecision > *myFaceData, const int cellId, const int faceId, tarch::timing::Measurement &measurement)
void firstTask(exahype2::CellFaceData< SolverPrecision, SolverPrecision > *myFaceData, const int leftFaceId, const int rightFaceId, const int faceDirection, tarch::timing::Measurement &measurement)
constexpr double timeStamp
const tarch::la::Vector< DIMENSIONS, double > cellCenter
const tarch::la::Vector< DIMENSIONS, double > cellSize
constexpr double timeStepSize
tarch::timing::Measurement timingComputeKernel
constexpr int NumberOfInputEntriesPerCell
void reportRuntime(const std::string &kernelIdentificator, const tarch::timing::Measurement &timingComputeKernel, const tarch::timing::Measurement &timingKernelLaunch, int numberOfCells, int numberOfThreads, tarch::logging::Log _log)
Reports the runtime and throughput of the benchmarks.
constexpr int NumberOfOutputEntriesPerCell
void initInputData(SolverPrecision *Q, const tarch::la::Vector< DIMENSIONS, double > CellCenter, const tarch::la::Vector< DIMENSIONS, double > CellSize)
Set input data.
tarch::logging::Log _log
This is variant 1 of the fused kernels.
void runBenchmarks(int numberOfCells, double timeStamp, double timeStepSize, const tarch::la::Vector< DIMENSIONS, double > cellCenter, const tarch::la::Vector< DIMENSIONS, double > cellSize)
Represents the faces of one cell, with a total of 2*Dim faces per cell For ADER QIn will contain the ...
tarch::la::Vector< DIMENSIONS, double > * cellSize
tarch::la::Vector< DIMENSIONS, double > * cellCentre
outType *(* QOut)[2 *DIMENSIONS]
Out values.
inType *(* QIn)[2 *DIMENSIONS]
QIn may not be const, as some kernels delete it straightaway once the input data has been handled.