16#ifndef Perf_counters_included
17#define Perf_counters_included
27enum class STD_COUNTERS :
int
29 total_execution_time ,
30 computation_start_up ,
71 IO_EcrireFicPartageMPIIO ,
72 IO_EcrireFicPartageBin ,
88 using clock = std::chrono::high_resolution_clock;
90 using duration = std::chrono::duration<double>;
109 static bool destroyed =
false;
112 if (instance ==
nullptr)
117 std::cout<<
"[Stats] The singleton pattern had to be reconstructed for avoiding \'Static Initialization Order Fiasco\' " <<std::endl;
118 std::cout<<
"It does not impact the TU files but be careful with the values of times printed afterwards" <<std::endl;
124 instance->~Perf_counters();
131 instance = &counters_stat_;
153 void create_custom_counter(std::string counter_description ,
int counter_level, std::string counter_family =
"None",
bool is_comm=
false,
bool is_gpu=
false);
160 void begin_count(
const STD_COUNTERS& std_cnt,
int counter_lvl = -100000);
167 void begin_count(
const std::string& custom_count_name,
int counter_lvl= -100000);
175 void end_count(
const std::string& custom_count_name,
int count_increment=1,
long int quantity_increment=0);
183 void end_count(
const STD_COUNTERS& std_cnt,
int count_increment=1,
long int quantity_increment=0);
304 std::unique_ptr<Impl> pimpl_;
This class stores and manages counters in TRUST. It is a singleton.
int get_last_opened_counter_level() const
bool is_running(const STD_COUNTERS &name)
Check whether a counter is already running. Should rarely be used!
std::chrono::time_point< clock > time_point
void set_gpu_timer(bool timer)
int get_gpu_timer_counter() const
void end_time_step(long int tstep)
This function compute statistics per time steps of counters used at least once during a time step.
double stop_gpu_timer_and_compute_gpu_time()
void start_timeloop()
Set time_loop_ to true in order to account for cache properly.
Perf_counters(const Perf_counters &)=delete
void set_gpu_verbose(bool on)
void set_gpu_fence(bool fence)
bool get_gpu_timer() const
std::chrono::duration< double > duration
static Perf_counters & getInstance()
The class Perf_counters is based on a phoenix singleton pattern. To access to the unique object insid...
std::chrono::high_resolution_clock clock
void record_nb_elem(trustIdType nb_elem)
void begin_count(const STD_COUNTERS &std_cnt, int counter_lvl=-100000)
void set_init_device(bool init)
bool get_gpu_fence() const
void set_nb_time_steps_elapsed(int n)
double get_time_since_last_open(const STD_COUNTERS &name)
Give as a double the time (in second) elapsed in the operation tracked by the standard counter call n...
void add_to_gpu_timer_counter(int to_add)
void stop_counters()
Stop all counters, has to be called on every processor simultaneously.
double get_total_time(const STD_COUNTERS &name)
Give as a double the total time (in second) elapsed in the operation tracked by the standard counter ...
bool get_init_device() const
void restart_counters()
Restart all counters, has to be called on every processor simultaneously.
void end_timeloop()
Set time_loop_ to false as we exit the time loop.
void reset_counters()
Reset counters to zero, used between the start-up of the computation, the computation itself and the ...
double compute_time(time_point start)
return time since start in seconds
void print_TU_files(const std::string &message)
Function that encapsulate the two functions that writes the TU files.
time_point start_clock()
Start a clock, return a time_point, not a double.
void end_count(const std::string &custom_count_name, int count_increment=1, long int quantity_increment=0)
End the count of a counter and update the counter values.
void create_custom_counter(std::string counter_description, int counter_level, std::string counter_family="None", bool is_comm=false, bool is_gpu=false)
Create a new counter and add it to the map of custom counters.
void start_time_step()
, this function start statistics tracking for a time step. It has to be called at the start of each t...
Perf_counters & operator=(const Perf_counters &)=delete
bool is_gpu_verbose_on() const
double get_computation_time()
Update computation_time_ and return its value as a double (in seconds).