DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Profiling.cpp
Go to the documentation of this file.
1/// @file Profiling.cpp
2/// @brief Implementation of @ref DNDS::PerformanceTimer "PerformanceTimer" (start/stop/accumulate/reset)
3/// and the singleton instance accessor.
4
5#include "Profiling.hpp"
6
7namespace DNDS
8{
10 {
11 static PerformanceTimer instance;
12 return instance;
13 }
14
16 {
17 tStart[t] = MPI_Wtime();
18 }
19
21 {
22 tStart[t + Ntype] = MPI_Wtime();
23 }
24
26 {
27 this->timer[t] += MPI_Wtime() - tStart[t];
28 }
29
31 {
32 this->timer[t + Ntype] += MPI_Wtime() - tStart[t];
33 }
34
36 {
37 return timer[t];
38 }
39
41 {
42 return timer[t + Ntype];
43 }
44
46 {
47 real timeTotal{0};
48 MPI::Allreduce(&timer[t], &timeTotal, 1, DNDS_MPI_REAL, MPI_SUM, mpi.comm);
49 return timeTotal / mpi.size; // loses one record of all reduce
50 }
51
53 {
54 real timeTotal{0};
55 MPI::Allreduce(&timer[t + Ntype], &timeTotal, 1, DNDS_MPI_REAL, MPI_SUM, mpi.comm);
56 return timeTotal / mpi.size; // loses one record of all reduce
57 }
58
60 {
61 timer[t] = 0;
62 }
63
65 {
66 timer[t + Ntype] = 0;
67 }
68
70 {
71 for (int i = 0; i < Ntype_All; i++)
72 clearTimer(TimerType(i)); // TODO: optimization
73 }
74
75}
Wall-clock performance timer and running scalar statistics utilities.
Process-wide singleton aggregating wall-clock timings by category.
Definition Profiling.hpp:23
void clearAllTimer()
Zero every timer slot.
Definition Profiling.cpp:69
static const int Ntype
Definition Profiling.hpp:50
TimerType
Named timer slots. New categories can be added before __EndTimerType.
Definition Profiling.hpp:27
static PerformanceTimer & Instance()
Access the process-wide singleton.
Definition Profiling.cpp:9
void clearTimer(TimerType t)
Zero the accumulated time for one timer slot.
Definition Profiling.cpp:59
void StartTimer(TimerType t)
Record the current wall time in the "start" slot for timer t.
Definition Profiling.cpp:15
real getTimerCollective(TimerType t, const MPIInfo &mpi)
Global maximum across ranks (collective on mpi.comm).
Definition Profiling.cpp:45
static const int Ntype_All
Definition Profiling.hpp:52
void StopTimer(TimerType t)
Add (now - start) to the accumulated time for timer t.
Definition Profiling.cpp:25
real getTimer(TimerType t)
Current local (this-rank) accumulated wall time (seconds).
Definition Profiling.cpp:35
MPI_int Allreduce(const void *sendbuf, void *recvbuf, MPI_int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Wrapper over MPI_Allreduce.
Definition MPI.cpp:203
the host side operators are provided as implemented
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Definition Defines.hpp:105
const MPI_Datatype DNDS_MPI_REAL
MPI datatype matching real (= MPI_REAL8).
Definition MPI.hpp:92
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Definition MPI.hpp:215