Peano
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1#pragma once
2
3#include "exahype2/dg/DGUtils.h"
4#include "repositories/SolverRepository.h"
5#include "tarch/timing/Measurement.h"
6#include "tarch/timing/Watch.h"
7
8#include <fstream>
9
10namespace benchmarks {
11 namespace exahype2 {
12 namespace kernelbenchmarks {
14 = (AderSolver::Order + 1) * (AderSolver::Order + 1)
15#if DIMENSIONS == 3
16 * (AderSolver::Order + 1)
17#endif
18 * (AderSolver::NumberOfUnknowns + AderSolver::NumberOfAuxiliaryVariables);
19
21
30 inline void initInputData(
31 SolverPrecision* Q,
32 const tarch::la::Vector<DIMENSIONS, double> CellCenter,
33 const tarch::la::Vector<DIMENSIONS, double> CellSize
34 ) {
35 // for (int i = 0; i < NumberOfInputEntriesPerCell; i++) {
36 // Q[i] = std::sin(1.0 * i / (NumberOfInputEntriesPerCell) * tarch::la::PI);
37 // }
38
39 int linearisedIndex = 0;
40 dfor(index, AderSolver::Order + 1) {
41 repositories::instanceOfAderSolver.initialCondition(
42 Q + linearisedIndex,
43 ::exahype2::dg::getQuadraturePoint(
46 index,
47 repositories::instanceOfAderSolver.Order + 1,
48 kernels::AderSolver::Quadrature<SolverPrecision>::nodes
49 ),
51 // index,
52 );
53 linearisedIndex += AderSolver::NumberOfUnknowns + AderSolver::NumberOfAuxiliaryVariables;
54 }
55 }
56
57
67 inline void reportRuntime(
68 const std::string& kernelIdentificator,
69 const tarch::timing::Measurement& timingComputeKernel,
70 const tarch::timing::Measurement& timingKernelLaunch,
71 int numberOfCells,
72 int numberOfThreads,
73 tarch::logging::Log _log
74 ) {
75 std::stringstream ss;
76 ss << "\n";
77 ss << kernelIdentificator << ":\n\t";
78 ss << "total compute time: " << timingComputeKernel.getValue() << " |\n\t";
79 ss << "average compute time per cell: " << (timingComputeKernel.getValue() / numberOfCells) << " |\n\t";
80 ss << timingComputeKernel.toString() << " |\n\t";
81 //ss << "total time including launch time: " << timingKernelLaunch.getValue() << " |\n\t";
82 //ss << "average total time per cell: " << (timingKernelLaunch.getValue() / numberOfCells);
83 //ss << " |\n\t" << timingKernelLaunch.toString();
84 logInfo("reportRuntime()", ss.str());
85
86 std::ostringstream snapshotFileName;
87 snapshotFileName << "ader-benchmarks-prec-"
88 << typeid(SolverPrecision).name()
89 << ".csv";
90 std::ofstream file( snapshotFileName.str(), std::ios_base::app );
91 file << kernelIdentificator << ","
92 << numberOfThreads << ","
93 << numberOfCells << ","
94 << timingComputeKernel.getValue() << ","
95 << timingKernelLaunch.getValue() << ","
96 << (timingComputeKernel.getValue() / numberOfCells) << ","
97 // << (timingKernelLaunch.getValue() / numberOfCells) << ","
98 // << timingKernelLaunch.max() << ","
99 // << timingKernelLaunch.min() << ","
100 // << timingKernelLaunch.getStandardDeviation()
101 << std::endl;
102 }
103 } // namespace kernelbenchmarks
104 } // namespace exahype2
105} // namespace benchmarks
const tarch::la::Vector< DIMENSIONS, double > CellCenter
tarch::timing::Measurement timingComputeKernel
const tarch::la::Vector< DIMENSIONS, double > CellSize
tarch::logging::Log _log("::")
constexpr int NumberOfInputEntriesPerCell
Definition Utils.h:14
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.
Definition Utils.h:67
constexpr int NumberOfOutputEntriesPerCell
Definition Utils.h:20
void initInputData(SolverPrecision *Q, const tarch::la::Vector< DIMENSIONS, double > CellCenter, const tarch::la::Vector< DIMENSIONS, double > CellSize)
Set input data.
Definition Utils.h:30