GADGET-4
logs.h File Reference

declares constants and some classes used for log-file handling More...

#include <stdio.h>
#include "../main/simulation.h"
#include "../mpi_utils/setcomm.h"
#include "../logs/timer.h"
#include "../data/simparticles.h"

Go to the source code of this file.

Classes

class  logs
 
struct  logs::timer_d
 struct containing the information of a CPU timer More...
 

Macros

#define CPU_STRING_LEN   120
 
#define TIMER_STACK_DEPTH   30
 
#define TIMER_STRUCT
 
#define TIMER_ENUM
 
#define TIMER_START_INTERNAL(counter)
 
#define TIMER_START(counter)   TIMER_START_INTERNAL(counter)
 Starts the timer counter. More...
 
#define TIMER_STOP_INTERNAL(counter)
 
#define TIMER_STOP(counter)   TIMER_STOP_INTERNAL(counter)
 Stops the timer counter. More...
 
#define TIMER_STOPSTART(stop, start)
 Stops the timer 'stop' and starts the timer 'start'. More...
 
#define TIMER_ADD(counter, amount)   Logs.CPU_Step[counter] += (amount);
 Adds amount to the timer counter. More...
 
#define TIMER_DIFF(counter)   (Logs.CPU_Step[logs::counter] - Logs.CPU_Step_Stored[logs::counter])
 Returns amount elapsed for the timer since last save with TIMER_STORE. More...
 
#define TIMER_STORE   memcpy(Logs.CPU_Step_Stored, Logs.CPU_Step, sizeof(Logs.CPU_Step));
 Copies the current value of CPU times to a stored variable, such that differences with respect to this reference can be calculated. More...
 

Variables

logs Logs
 

Detailed Description

declares constants and some classes used for log-file handling

Definition in file logs.h.

Macro Definition Documentation

◆ CPU_STRING_LEN

#define CPU_STRING_LEN   120

Definition at line 20 of file logs.h.

◆ TIMER_ADD

#define TIMER_ADD (   counter,
  amount 
)    Logs.CPU_Step[counter] += (amount);

Adds amount to the timer counter.

Parameters
counterName of the timer to add to
amountamount to add to timer counter

Definition at line 243 of file logs.h.

◆ TIMER_DIFF

#define TIMER_DIFF (   counter)    (Logs.CPU_Step[logs::counter] - Logs.CPU_Step_Stored[logs::counter])

Returns amount elapsed for the timer since last save with TIMER_STORE.

Parameters
counterName of the timer to add to

Definition at line 250 of file logs.h.

◆ TIMER_ENUM

#define TIMER_ENUM

Definition at line 95 of file logs.h.

◆ TIMER_STACK_DEPTH

#define TIMER_STACK_DEPTH   30

Definition at line 22 of file logs.h.

◆ TIMER_START

#define TIMER_START (   counter)    TIMER_START_INTERNAL(counter)

Starts the timer counter.

Use this macro instead of directly accessing the CPU_Step array, so manual instrumentation APIs can be attached.

Parameters
counterName of the timer to start

Definition at line 197 of file logs.h.

◆ TIMER_START_INTERNAL

#define TIMER_START_INTERNAL (   counter)
Value:
{ \
for(int itimer = 0; itimer <= Logs.TimerStackPos; itimer++) \
if(logs::counter == Logs.TimerStack[itimer]) \
{ \
Terminate("Try to start timer %d, but it is already running.\n", logs::counter); \
}; \
{ \
Terminate("Run out of timer stack space, increase TIMER_STACK_DEPTH"); \
} \
else \
{ \
Logs.TimerStack[Logs.TimerStackPos] = logs::counter; \
} \
}
double measure_time(void)
Definition: logs.cc:458
int TimerStackPos
Definition: logs.h:120
enum timers TimerStack[TIMER_STACK_DEPTH]
Definition: logs.h:119
logs Logs
Definition: main.cc:43
#define TIMER_STACK_DEPTH
Definition: logs.h:22

Definition at line 171 of file logs.h.

◆ TIMER_STOP

#define TIMER_STOP (   counter)    TIMER_STOP_INTERNAL(counter)

Stops the timer counter.

Use this macro instead of directly accessing the CPU_Step array, so manual instrumentation APIs can be attached.

Parameters
counterName of the timer to stop

Definition at line 220 of file logs.h.

◆ TIMER_STOP_INTERNAL

#define TIMER_STOP_INTERNAL (   counter)
Value:
{ \
if(Logs.TimerStack[Logs.TimerStackPos] != logs::counter) \
{ \
Terminate("Wrong use of TIMER_STOP, you must stop the timer started last"); \
} \
Logs.CPU_Step[Logs.TimerStack[Logs.TimerStackPos--]] += Logs.measure_time(); \
if(Logs.TimerStackPos < 0) \
{ \
Terminate("Do not stop the out CPU_MISC timer"); \
} \
}

Definition at line 199 of file logs.h.

◆ TIMER_STOPSTART

#define TIMER_STOPSTART (   stop,
  start 
)
Value:
{ \
TIMER_STOP_INTERNAL(stop); \
TIMER_START_INTERNAL(start); \
}

Stops the timer 'stop' and starts the timer 'start'.

Use this macro instead of directly accessing the CPU_Step array, so manual instrumentation APIs can be attached.

Parameters
stopName of the timer to stop
startName of the timer to start

Definition at line 231 of file logs.h.

◆ TIMER_STORE

#define TIMER_STORE   memcpy(Logs.CPU_Step_Stored, Logs.CPU_Step, sizeof(Logs.CPU_Step));

Copies the current value of CPU times to a stored variable, such that differences with respect to this reference can be calculated.

Definition at line 257 of file logs.h.

◆ TIMER_STRUCT

#define TIMER_STRUCT

Variable Documentation

◆ Logs

logs Logs
extern

Definition at line 43 of file main.cc.