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 true
53 );
54 linearisedIndex += AderSolver::NumberOfUnknowns + AderSolver::NumberOfAuxiliaryVariables;
55 }
56 }
57
58
68 inline void reportRuntime(
69 const std::string& kernelIdentificator,
70 const tarch::timing::Measurement& timingComputeKernel,
71 const tarch::timing::Measurement& timingKernelLaunch,
72 int numberOfCells,
73 int numberOfThreads,
74 tarch::logging::Log _log
75 ) {
76 std::stringstream ss;
77 ss << "\n";
78 ss << kernelIdentificator << ":\n\t";
79 ss << "total compute time: " << timingComputeKernel.getValue() << " |\n\t";
80 ss << "average compute time per cell: " << (timingComputeKernel.getValue() / numberOfCells) << " |\n\t";
81 ss << timingComputeKernel.toString() << " |\n\t";
82 //ss << "total time including launch time: " << timingKernelLaunch.getValue() << " |\n\t";
83 //ss << "average total time per cell: " << (timingKernelLaunch.getValue() / numberOfCells);
84 //ss << " |\n\t" << timingKernelLaunch.toString();
85 logInfo("reportRuntime()", ss.str());
86
87 std::ostringstream snapshotFileName;
88 snapshotFileName << "ader-benchmarks-prec-"
89 << typeid(SolverPrecision).name()
90 << ".csv";
91 std::ofstream file( snapshotFileName.str(), std::ios_base::app );
92 file << kernelIdentificator << ","
93 << numberOfThreads << ","
94 << numberOfCells << ","
95 << timingComputeKernel.getValue() << ","
96 << timingKernelLaunch.getValue() << ","
97 << (timingComputeKernel.getValue() / numberOfCells) << ","
98 // << (timingKernelLaunch.getValue() / numberOfCells) << ","
99 // << timingKernelLaunch.max() << ","
100 // << timingKernelLaunch.min() << ","
101 // << timingKernelLaunch.getStandardDeviation()
102 << std::endl;
103 }
104 } // namespace kernelbenchmarks
105 } // namespace exahype2
106} // 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:68
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