Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
timing_functions.h
1#ifndef TIMING_FUNCTIONS_H
2#define TIMING_FUNCTIONS_H
3
4#include <vector>
5
6#include "../global/global.h" // Provides Real, Get_Time
7
8// #ifdef CPU_TIME
9// Each instance of this class represents a single timer, timing a single
10// section of code. All instances have their own n_steps, time_start, etc. so
11// that all timers can run independently
13{
14 public:
15 const char* name;
16 int n_steps = 0;
17 Real time_start = 0;
18 Real t_min = 0;
19 Real t_max = 0;
20 Real t_avg = 0;
21 Real t_all = 0;
22 bool inactive = true;
23 OneTime(void) {}
24 OneTime(const char* input_name)
25 {
26 name = input_name;
27 inactive = false;
28 }
29 void Start();
30 void Subtract(Real time_to_subtract);
31 void End(bool const print_high_values = false);
32 void PrintStep();
33 void PrintAverage();
34 void PrintAll();
35 void RecordTime(Real time);
36};
37
38// Time loops through instances of OneTime. onetimes is initialized with
39// pointers to each timer.
40//
41class Time
42{
43 public:
44 int n_steps;
45
46 OneTime Total;
47 OneTime Calc_dt;
48 OneTime Hydro_Integrator;
49 OneTime Hydro;
50 OneTime Boundaries;
51 OneTime Grav_Potential;
52 OneTime Pot_Boundaries;
53 OneTime Part_Density;
54 OneTime Part_Boundaries;
55 OneTime Part_Dens_Transf;
56 OneTime Advance_Part_1;
57 OneTime Advance_Part_2;
58 OneTime Cooling_GPU;
59 OneTime Cooling_Grackle;
60 OneTime Chemistry;
61 OneTime Feedback;
63
64 std::vector<OneTime*> onetimes;
65
66 Time();
67 void Initialize();
68 void Print_Times();
69 void Print_Average_Times(struct Parameters P);
70};
71// #endif // CPU_TIME
72
73// ScopedTimer does nothing if CPU_TIME is disabled
74/* \brief ScopedTimer helps time a scope. Initialize as first variable and C++ guarantees it is destroyed last */
76{
77 public:
78 const char* name;
79 double time_start = 0;
80
81 /* \brief ScopedTimer Constructor initializes name and time */
82 ScopedTimer(const char* input_name);
83
84 /* \brief ScopedTimer Destructor computes dt and prints */
85 ~ScopedTimer(void);
86};
87
88#endif // TIMING_FUNCTIONS_H
Definition feedback_analysis.h:13
Definition timing_functions.h:13
Definition timing_functions.h:76
Definition timing_functions.h:42
Definition global.h:217