TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Perf_counters Class Reference

This class stores and manages counters in TRUST. It is a singleton. More...

#include <Perf_counters.h>

Classes

class  Impl

Public Types

using clock = std::chrono::high_resolution_clock
using time_point = std::chrono::time_point<clock>
using duration = std::chrono::duration<double>

Public Member Functions

time_point now ()
time_point start_clock ()
 Start a clock, return a time_point, not a double.
double compute_time (time_point start)
 return time since start in seconds
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 begin_count (const STD_COUNTERS &std_cnt, int counter_lvl=-100000)
void begin_count (const std::string &custom_count_name, int counter_lvl=-100000)
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 end_count (const STD_COUNTERS &std_cnt, int count_increment=1, long int quantity_increment=0)
 End the count of a counter and update the counter values.
void stop_counters ()
 Stop all counters, has to be called on every processor simultaneously.
void restart_counters ()
 Restart all counters, has to be called on every processor simultaneously.
void reset_counters ()
 Reset counters to zero, used between the start-up of the computation, the computation itself and the post-processing.
void print_TU_files (const std::string &message)
 Function that encapsulate the two functions that writes the TU files.
double get_computation_time ()
 Update computation_time_ and return its value as a double (in seconds).
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 call name.
double get_total_time (const std::string &name)
 Give as a double the total time (in second) elapsed in the operation tracked by the custom counter call name.
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 name since the counter was last opened.
double get_time_since_last_open (const std::string &name)
 Give as a double the time (in second) elapsed in the operation tracked by the standard counter call name since the counter was last opened.
bool is_running (const STD_COUNTERS &name)
 Check whether a counter is already running. Should rarely be used!
void start_timeloop ()
 Set time_loop_ to true in order to account for cache properly.
void end_timeloop ()
 Set time_loop_ to false as we exit the time loop.
void start_time_step ()
 , this function start statistics tracking for a time step. It has to be called at the start of each time step.
void end_time_step (long int tstep)
 This function compute statistics per time steps of counters used at least once during a time step.
void set_nb_time_steps_elapsed (int n)
int get_last_opened_counter_level () const
void record_nb_elem (trustIdType nb_elem)
void start_gpu_timer ()
void stop_gpu_timer ()
bool is_gpu_verbose_on () const
void set_gpu_verbose (bool on)
bool get_init_device () const
void set_init_device (bool init)
bool get_gpu_timer () const
void set_gpu_timer (bool timer)
void add_to_gpu_timer_counter (int to_add)
int get_gpu_timer_counter () const
double stop_gpu_timer_and_compute_gpu_time ()
bool get_use_gpu () const
bool get_gpu_fence () const
void set_gpu_fence (bool fence)
 Perf_counters (const Perf_counters &)=delete
Perf_countersoperator= (const Perf_counters &)=delete

Static Public Member Functions

static Perf_countersgetInstance ()
 The class Perf_counters is based on a phoenix singleton pattern. To access to the unique object inside the code, use the getInstance() function.

Detailed Description

This class stores and manages counters in TRUST. It is a singleton.

Definition at line 85 of file Perf_counters.h.

Member Typedef Documentation

◆ clock

using Perf_counters::clock = std::chrono::high_resolution_clock

Definition at line 88 of file Perf_counters.h.

◆ duration

using Perf_counters::duration = std::chrono::duration<double>

Definition at line 90 of file Perf_counters.h.

◆ time_point

using Perf_counters::time_point = std::chrono::time_point<clock>

Definition at line 89 of file Perf_counters.h.

Constructor & Destructor Documentation

◆ Perf_counters()

Perf_counters::Perf_counters ( const Perf_counters & )
delete

Member Function Documentation

◆ add_to_gpu_timer_counter()

void Perf_counters::add_to_gpu_timer_counter ( int to_add)

Definition at line 2072 of file Perf_counters.cpp.

◆ begin_count() [1/2]

void Perf_counters::begin_count ( const std::string & custom_count_name,
int counter_lvl = -100000 )

Custom counters, start the tracking of the wanted operation

Parameters
custom_count_namestring key in the custom counter map
counter_lvllevel of the counter you try to open, warning it changes the value of the level of the counter associated with custom_count_name

Definition at line 1937 of file Perf_counters.cpp.

◆ begin_count() [2/2]

void Perf_counters::begin_count ( const STD_COUNTERS & std_cnt,
int counter_lvl = -100000 )

Standard counters, start the tracking of the wanted operation

Parameters
std_cntreference to the standard counter
counter_lvllevel of the counter you try to open, warning it changes the value of the counter level associated with counter std_cnt

Definition at line 1932 of file Perf_counters.cpp.

◆ compute_time()

double Perf_counters::compute_time ( time_point start)

return time since start in seconds

Definition at line 1921 of file Perf_counters.cpp.

◆ create_custom_counter()

void Perf_counters::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.

Parameters
counter_level
counter_description
counter_family
is_comm
Returns
create a new counter
Note
If the counter description already exists, it will not create a new counter.

Definition at line 1927 of file Perf_counters.cpp.

◆ end_count() [1/2]

void Perf_counters::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.

Parameters
cis the counter to end the count
count_incrementis the count increment. If not specified, then it is equal to 1
quantity_incrementis the increment of custom variable quantity. If not specified, it is set to 0.

Definition at line 1942 of file Perf_counters.cpp.

◆ end_count() [2/2]

void Perf_counters::end_count ( const STD_COUNTERS & std_cnt,
int count_increment = 1,
long int quantity_increment = 0 )

End the count of a counter and update the counter values.

Parameters
cis the counter to end the count
count_incrementis the count increment. If not specified, then it is equal to 1
quantity_incrementis the increment of custom variable quantity. If not specified, it is set to 0.

Definition at line 1947 of file Perf_counters.cpp.

◆ end_time_step()

void Perf_counters::end_time_step ( long int tstep)

This function compute statistics per time steps of counters used at least once during a time step.

Parameters
tstepis the current time step number

Definition at line 2017 of file Perf_counters.cpp.

◆ end_timeloop()

void Perf_counters::end_timeloop ( )

Set time_loop_ to false as we exit the time loop.

Definition at line 2007 of file Perf_counters.cpp.

◆ get_computation_time()

double Perf_counters::get_computation_time ( )

Update computation_time_ and return its value as a double (in seconds).

Definition at line 1972 of file Perf_counters.cpp.

◆ get_gpu_fence()

bool Perf_counters::get_gpu_fence ( ) const

Definition at line 2089 of file Perf_counters.cpp.

◆ get_gpu_timer()

bool Perf_counters::get_gpu_timer ( ) const

Definition at line 2067 of file Perf_counters.cpp.

◆ get_gpu_timer_counter()

int Perf_counters::get_gpu_timer_counter ( ) const

Definition at line 2077 of file Perf_counters.cpp.

◆ get_init_device()

bool Perf_counters::get_init_device ( ) const

Definition at line 2057 of file Perf_counters.cpp.

◆ get_last_opened_counter_level()

int Perf_counters::get_last_opened_counter_level ( ) const

Definition at line 2027 of file Perf_counters.cpp.

◆ get_time_since_last_open() [1/2]

double Perf_counters::get_time_since_last_open ( const std::string & name)

Give as a double the time (in second) elapsed in the operation tracked by the standard counter call name since the counter was last opened.

Definition at line 1992 of file Perf_counters.cpp.

◆ get_time_since_last_open() [2/2]

double Perf_counters::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 name since the counter was last opened.

Definition at line 1987 of file Perf_counters.cpp.

◆ get_total_time() [1/2]

double Perf_counters::get_total_time ( const std::string & name)

Give as a double the total time (in second) elapsed in the operation tracked by the custom counter call name.

Definition at line 1982 of file Perf_counters.cpp.

◆ get_total_time() [2/2]

double Perf_counters::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 call name.

Definition at line 1977 of file Perf_counters.cpp.

◆ get_use_gpu()

bool Perf_counters::get_use_gpu ( ) const

Definition at line 2087 of file Perf_counters.cpp.

◆ getInstance()

Perf_counters & Perf_counters::getInstance ( )
inlinestatic

The class Perf_counters is based on a phoenix singleton pattern. To access to the unique object inside the code, use the getInstance() function.

Returns
the unique Perf_counters object

Definition at line 106 of file Perf_counters.h.

◆ is_gpu_verbose_on()

bool Perf_counters::is_gpu_verbose_on ( ) const

Definition at line 2047 of file Perf_counters.cpp.

◆ is_running()

bool Perf_counters::is_running ( const STD_COUNTERS & name)

Check whether a counter is already running. Should rarely be used!

Definition at line 1997 of file Perf_counters.cpp.

◆ now()

time_point Perf_counters::now ( )
inline

Definition at line 91 of file Perf_counters.h.

◆ operator=()

Perf_counters & Perf_counters::operator= ( const Perf_counters & )
delete

◆ print_TU_files()

void Perf_counters::print_TU_files ( const std::string & message)

Function that encapsulate the two functions that writes the TU files.

Parameters
messsagecan only take three values: "Computation start-up statistics", "Time loop statistics" or "Post-resolution statistics"
Note
It also resets the counters

Definition at line 1967 of file Perf_counters.cpp.

◆ record_nb_elem()

void Perf_counters::record_nb_elem ( trustIdType nb_elem)

Definition at line 2032 of file Perf_counters.cpp.

◆ reset_counters()

void Perf_counters::reset_counters ( )

Reset counters to zero, used between the start-up of the computation, the computation itself and the post-processing.

Definition at line 1962 of file Perf_counters.cpp.

◆ restart_counters()

void Perf_counters::restart_counters ( )

Restart all counters, has to be called on every processor simultaneously.

Definition at line 1957 of file Perf_counters.cpp.

◆ set_gpu_fence()

void Perf_counters::set_gpu_fence ( bool fence)

Definition at line 2091 of file Perf_counters.cpp.

◆ set_gpu_timer()

void Perf_counters::set_gpu_timer ( bool timer)

◆ set_gpu_verbose()

void Perf_counters::set_gpu_verbose ( bool on)

Definition at line 2052 of file Perf_counters.cpp.

◆ set_init_device()

void Perf_counters::set_init_device ( bool init)

Definition at line 2062 of file Perf_counters.cpp.

◆ set_nb_time_steps_elapsed()

void Perf_counters::set_nb_time_steps_elapsed ( int n)

Definition at line 2022 of file Perf_counters.cpp.

◆ start_clock()

time_point Perf_counters::start_clock ( )
inline

Start a clock, return a time_point, not a double.

Definition at line 98 of file Perf_counters.h.

◆ start_gpu_timer()

void Perf_counters::start_gpu_timer ( )

Definition at line 2037 of file Perf_counters.cpp.

◆ start_time_step()

void Perf_counters::start_time_step ( )

, this function start statistics tracking for a time step. It has to be called at the start of each time step.

Definition at line 2012 of file Perf_counters.cpp.

◆ start_timeloop()

void Perf_counters::start_timeloop ( )

Set time_loop_ to true in order to account for cache properly.

Definition at line 2002 of file Perf_counters.cpp.

◆ stop_counters()

void Perf_counters::stop_counters ( )

Stop all counters, has to be called on every processor simultaneously.

Definition at line 1952 of file Perf_counters.cpp.

◆ stop_gpu_timer()

void Perf_counters::stop_gpu_timer ( )

Definition at line 2042 of file Perf_counters.cpp.

◆ stop_gpu_timer_and_compute_gpu_time()

double Perf_counters::stop_gpu_timer_and_compute_gpu_time ( )

Definition at line 2082 of file Perf_counters.cpp.


The documentation for this class was generated from the following files: