17#include "../main/simulation.h"
18#include "../mpi_utils/setcomm.h"
20#define CPU_STRING_LEN 120
22#define TIMER_STACK_DEPTH 30
34#include "../logs/timer.h"
57#ifdef MEASURE_TOTAL_MOMENTUM
87 double timediff(
double t0,
double t1);
96#include "../logs/timer.h"
125 double WallclockTime;
127 void put_symbol(
char *
string,
double t0,
double t1,
char c);
130 struct state_of_system
132 double Mass, EnergyKin, EnergyPot, EnergyInt, EnergyTot, Momentum[4], AngMomentum[4], CenterOfMass[4], MassComp[
NTYPES],
134 AngMomentumComp[
NTYPES][4], CenterOfMassComp[
NTYPES][4];
136 state_of_system SysState;
138 void compute_global_quantities_of_system(
void);
144 Terminate(
"Wrong use of timer_stop(), you must stop the timer started last");
149 Terminate(
"Do not stop the out CPU_MISC timer");
158 Terminate(
"Try to start timer %d, but it is already running.\n", counter);
162 Terminate(
"Run out of timer stack space, increase TIMER_STACK_DEPTH");
169#include "../data/simparticles.h"
171#define TIMER_START_INTERNAL(counter) \
173 Logs.CPU_Step[Logs.TimerStack[Logs.TimerStackPos]] += Logs.measure_time(); \
174 for(int itimer = 0; itimer <= Logs.TimerStackPos; itimer++) \
175 if(logs::counter == Logs.TimerStack[itimer]) \
177 Terminate("Try to start timer %d, but it is already running.\n", logs::counter); \
179 if(++Logs.TimerStackPos >= TIMER_STACK_DEPTH) \
181 Terminate("Run out of timer stack space, increase TIMER_STACK_DEPTH"); \
185 Logs.TimerStack[Logs.TimerStackPos] = logs::counter; \
197#define TIMER_START(counter) TIMER_START_INTERNAL(counter)
199#define TIMER_STOP_INTERNAL(counter) \
201 if(Logs.TimerStack[Logs.TimerStackPos] != logs::counter) \
203 Terminate("Wrong use of TIMER_STOP, you must stop the timer started last"); \
205 Logs.CPU_Step[Logs.TimerStack[Logs.TimerStackPos--]] += Logs.measure_time(); \
206 if(Logs.TimerStackPos < 0) \
208 Terminate("Do not stop the out CPU_MISC timer"); \
220#define TIMER_STOP(counter) TIMER_STOP_INTERNAL(counter)
231#define TIMER_STOPSTART(stop, start) \
233 TIMER_STOP_INTERNAL(stop); \
234 TIMER_START_INTERNAL(start); \
243#define TIMER_ADD(counter, amount) Logs.CPU_Step[counter] += (amount);
250#define TIMER_DIFF(counter) (Logs.CPU_Step[logs::counter] - Logs.CPU_Step_Stored[logs::counter])
257#define TIMER_STORE memcpy(Logs.CPU_Step_Stored, Logs.CPU_Step, sizeof(Logs.CPU_Step));
void timer_stop(enum timers counter)
int flush_everything(void)
void block_checksum(void *base, size_t bytes, int res[4])
void init_cpu_log(simparticles *Sp_ptr)
timer_d Timer_data[CPU_LAST+1]
void write_cpu_log(void)
Write the FdBalance and FdCPU files.
void open_logfiles(void)
Open files for logging.
double CPU_Step[CPU_LAST]
void print_particle_info_from_ID(MyIDType ID)
double CPU_Step_Stored[CPU_LAST]
double measure_time(void)
void output_log_messages(void)
Write the FdInfo and FdTimeBin files.
double timediff(double t0, double t1)
void calc_memory_checksum(const char *msg, void *base, size_t bytes)
void compute_statistics(void)
Computes new global statistics if needed (done by energy_statistics())
void print_particle_info(int i)
void log_debug_md5(const char *msg)
enum timers TimerStack[TIMER_STACK_DEPTH]
void compute_total_momentum(void)
void timer_start(enum timers counter)
#define TIMER_STACK_DEPTH
struct containing the information of a CPU timer