MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Classes | Macros | Enumerations | Functions
walltime.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Clock
 
struct  ClockTable
 

Macros

#define WALLTIME_IGNORE   "."
 
#define LINENO(a, b)   a ":" # b
 
#define walltime_measure(name)   walltime_measure_full(name, __FILE__ , __LINE__)
 
#define walltime_add(name, dt)   walltime_add_full(name, dt, __FILE__, __LINE__)
 
#define walltime_step_min(id)   walltime_get(id, CLOCK_STEP_MIN)
 
#define walltime_step_max(id)   walltime_get(id, CLOCK_STEP_MAX)
 
#define walltime_step_mean(id)   walltime_get(id, CLOCK_STEP_MEAN)
 
#define walltime_accu_min(id)   walltime_get(id, CLOCK_ACCU_MIN)
 
#define walltime_accu_max(id)   walltime_get(id, CLOCK_ACCU_MAX)
 
#define walltime_accu_mean(id)   walltime_get(id, CLOCK_ACCU_MEAN)
 

Enumerations

enum  clocktype {
  CLOCK_STEP_MEAN , CLOCK_STEP_MAX , CLOCK_STEP_MIN , CLOCK_ACCU_MEAN ,
  CLOCK_ACCU_MAX , CLOCK_ACCU_MIN
}
 

Functions

int walltime_clock (const char *name)
 
void walltime_reset (void)
 
double walltime_measure_internal (const char *name)
 
double walltime_add_internal (const char *name, const double dt)
 
double walltime_measure_full (const char *name, const char *file, const int line)
 
double walltime_add_full (const char *name, const double dt, const char *file, const int line)
 
char walltime_get_symbol (const char *name)
 
double walltime_get_time (const char *name)
 
double walltime_get (const char *name, const enum clocktype type)
 
void walltime_summary (const int root, MPI_Comm comm)
 
void walltime_report (FILE *fd, const int root, MPI_Comm comm)
 
void walltime_init (struct ClockTable *table)
 

Macro Definition Documentation

◆ LINENO

#define LINENO (   a,
 
)    a ":" # b

Definition at line 7 of file walltime.h.

◆ walltime_accu_max

#define walltime_accu_max (   id)    walltime_get(id, CLOCK_ACCU_MAX)

Definition at line 33 of file walltime.h.

◆ walltime_accu_mean

#define walltime_accu_mean (   id)    walltime_get(id, CLOCK_ACCU_MEAN)

Definition at line 34 of file walltime.h.

◆ walltime_accu_min

#define walltime_accu_min (   id)    walltime_get(id, CLOCK_ACCU_MIN)

Definition at line 32 of file walltime.h.

◆ walltime_add

#define walltime_add (   name,
  dt 
)    walltime_add_full(name, dt, __FILE__, __LINE__)

Definition at line 9 of file walltime.h.

◆ WALLTIME_IGNORE

#define WALLTIME_IGNORE   "."

Definition at line 6 of file walltime.h.

◆ walltime_measure

#define walltime_measure (   name)    walltime_measure_full(name, __FILE__ , __LINE__)

Definition at line 8 of file walltime.h.

◆ walltime_step_max

#define walltime_step_max (   id)    walltime_get(id, CLOCK_STEP_MAX)

Definition at line 30 of file walltime.h.

◆ walltime_step_mean

#define walltime_step_mean (   id)    walltime_get(id, CLOCK_STEP_MEAN)

Definition at line 31 of file walltime.h.

◆ walltime_step_min

#define walltime_step_min (   id)    walltime_get(id, CLOCK_STEP_MIN)

Definition at line 29 of file walltime.h.

Enumeration Type Documentation

◆ clocktype

enum clocktype
Enumerator
CLOCK_STEP_MEAN 
CLOCK_STEP_MAX 
CLOCK_STEP_MIN 
CLOCK_ACCU_MEAN 
CLOCK_ACCU_MAX 
CLOCK_ACCU_MIN 

Definition at line 15 of file walltime.h.

15  {
22 };
@ CLOCK_STEP_MAX
Definition: walltime.h:17
@ CLOCK_ACCU_MIN
Definition: walltime.h:21
@ CLOCK_STEP_MEAN
Definition: walltime.h:16
@ CLOCK_STEP_MIN
Definition: walltime.h:18
@ CLOCK_ACCU_MAX
Definition: walltime.h:20
@ CLOCK_ACCU_MEAN
Definition: walltime.h:19

Function Documentation

◆ walltime_add_full()

double walltime_add_full ( const char *  name,
const double  dt,
const char *  file,
const int  line 
)

Definition at line 203 of file walltime.c.

203  {
204  char fullname[128] = {0};
205  const char * basename = file + strlen(file);
206  while(basename >= file && *basename != '/') basename --;
207  basename ++;
208  sprintf(fullname, "%s@%s:%04d", name, basename, line);
209  return walltime_add_internal(fullname, dt);
210 
211 }
const char * name
Definition: densitykernel.c:93
double walltime_add_internal(const char *name, const double dt)
Definition: walltime.c:180

References name, and walltime_add_internal().

Here is the call graph for this function:

◆ walltime_add_internal()

double walltime_add_internal ( const char *  name,
const double  dt 
)

Definition at line 180 of file walltime.c.

180  {
181  int id = walltime_clock(name);
182  CT->C[id].time += dt;
183  return dt;
184 }
struct Clock C[512]
Definition: walltime.h:51
double time
Definition: walltime.h:41
int walltime_clock(const char *name)
Definition: walltime.c:112
static struct ClockTable * CT
Definition: walltime.c:9

References ClockTable::C, CT, name, Clock::time, and walltime_clock().

Referenced by walltime_add_full().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ walltime_clock()

int walltime_clock ( const char *  name)

Definition at line 112 of file walltime.c.

112  {
113  struct Clock dummy;
114  strncpy(dummy.name, name, sizeof(dummy.name));
115  dummy.name[sizeof(dummy.name)-1]='\0';
116 
117  struct Clock * rt = (struct Clock *) bsearch(&dummy, CT->C, CT->N, sizeof(struct Clock), clockcmp);
118  if(rt == NULL) {
120  rt = (struct Clock *) bsearch(&dummy, CT->C, CT->N, sizeof(struct Clock), clockcmp);
121  }
122  return rt - CT->C;
123 };
Definition: walltime.h:39
static void walltime_clock_insert(const char *name)
Definition: walltime.c:83
static int clockcmp(const void *c1, const void *c2)
Definition: walltime.c:77

References ClockTable::C, clockcmp(), CT, ClockTable::N, name, Clock::name, and walltime_clock_insert().

Referenced by walltime_add_internal(), walltime_clock_insert(), walltime_get(), walltime_get_symbol(), walltime_get_time(), and walltime_measure_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ walltime_get()

double walltime_get ( const char *  name,
const enum clocktype  type 
)

Definition at line 130 of file walltime.c.

130  {
131  int id = walltime_clock(name);
132  /* only make sense on root */
133  switch(type) {
134  case CLOCK_STEP_MEAN:
135  return CT->C[id].mean;
136  case CLOCK_STEP_MIN:
137  return CT->C[id].min;
138  case CLOCK_STEP_MAX:
139  return CT->C[id].max;
140  case CLOCK_ACCU_MEAN:
141  return CT->AC[id].mean;
142  case CLOCK_ACCU_MIN:
143  return CT->AC[id].min;
144  case CLOCK_ACCU_MAX:
145  return CT->AC[id].max;
146  }
147  return 0;
148 }
struct Clock AC[512]
Definition: walltime.h:52
double max
Definition: walltime.h:42
double mean
Definition: walltime.h:44
double min
Definition: walltime.h:43

References ClockTable::AC, ClockTable::C, CLOCK_ACCU_MAX, CLOCK_ACCU_MEAN, CLOCK_ACCU_MIN, CLOCK_STEP_MAX, CLOCK_STEP_MEAN, CLOCK_STEP_MIN, CT, Clock::max, Clock::mean, Clock::min, name, and walltime_clock().

Here is the call graph for this function:

◆ walltime_get_symbol()

char walltime_get_symbol ( const char *  name)

Definition at line 125 of file walltime.c.

125  {
126  int id = walltime_clock(name);
127  return CT->C[id].symbol;
128 }
char symbol
Definition: walltime.h:45

References ClockTable::C, CT, name, Clock::symbol, and walltime_clock().

Here is the call graph for this function:

◆ walltime_get_time()

double walltime_get_time ( const char *  name)

Definition at line 149 of file walltime.c.

149  {
150  int id = walltime_clock(name);
151  return CT->C[id].time;
152 }

References ClockTable::C, CT, name, Clock::time, and walltime_clock().

Here is the call graph for this function:

◆ walltime_init()

void walltime_init ( struct ClockTable table)

Definition at line 19 of file walltime.c.

19  {
20  CT = ct;
21  CT->Nmax = 512;
22  CT->N = 0;
23  CT->ElapsedTime = 0;
27 }
double ElapsedTime
Definition: walltime.h:54
int Nmax
Definition: walltime.h:49
static double seconds(void)
Definition: walltime.c:216
static double LastReportTime
Definition: walltime.c:12
void walltime_reset()
Definition: walltime.c:176

References CT, ClockTable::ElapsedTime, LastReportTime, ClockTable::N, ClockTable::Nmax, seconds(), walltime_clock_insert(), and walltime_reset().

Referenced by begrun(), main(), setup_density(), setup_particles(), setup_tree(), and test_fof().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ walltime_measure_full()

double walltime_measure_full ( const char *  name,
const char *  file,
const int  line 
)

Definition at line 195 of file walltime.c.

195  {
196  char fullname[128] = {0};
197  const char * basename = file + strlen(file);
198  while(basename >= file && *basename != '/') basename --;
199  basename ++;
200  sprintf(fullname, "%s@%s:%04d", name, basename, line);
201  return walltime_measure_internal(fullname);
202 }
double walltime_measure_internal(const char *name)
Definition: walltime.c:185

References name, and walltime_measure_internal().

Here is the call graph for this function:

◆ walltime_measure_internal()

double walltime_measure_internal ( const char *  name)

Definition at line 185 of file walltime.c.

185  {
186  double t = seconds();
187  double dt = t - WallTimeClock;
189  if(name[0] != '.') {
190  int id = walltime_clock(name);
191  CT->C[id].time += dt;
192  }
193  return dt;
194 }
static double WallTimeClock
Definition: walltime.c:11

References ClockTable::C, CT, name, seconds(), Clock::time, walltime_clock(), and WallTimeClock.

Referenced by walltime_measure_full().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ walltime_report()

void walltime_report ( FILE *  fd,
const int  root,
MPI_Comm  comm 
)

Definition at line 220 of file walltime.c.

220  {
221  int rank;
222  MPI_Comm_rank(comm, &rank);
223  if(rank != root) return;
224  int i;
225  for(i = 0; i < CT->N; i ++) {
226  char * name = CT->C[i].name;
227  int level = 0;
228  char * p = name;
229  while(*p) {
230  if(*p == '/') {
231  level ++;
232  name = p + 1;
233  }
234  p++;
235  }
236  /* if there is just one child, don't print it*/
237  if(CT->Nchildren[i] == 1) continue;
238  fprintf(fp, "%*s%-26s %10.2f %4.1f%% %10.2f %4.1f%% %10.2f %10.2f\n",
239  level, "", /* indents */
240  name, /* just the last seg of name*/
241  CT->AC[i].mean,
242  CT->AC[i].mean / CT->ElapsedTime * 100.,
243  CT->C[i].mean,
244  CT->C[i].mean / CT->StepTime * 100.,
245  CT->C[i].min,
246  CT->C[i].max
247  );
248  }
249 }
double StepTime
Definition: walltime.h:55
int Nchildren[512]
Definition: walltime.h:53
char name[128]
Definition: walltime.h:40

References ClockTable::AC, ClockTable::C, CT, ClockTable::ElapsedTime, Clock::max, Clock::mean, Clock::min, ClockTable::N, name, Clock::name, ClockTable::Nchildren, and ClockTable::StepTime.

Referenced by compute_global_quantities_of_system(), and main().

Here is the caller graph for this function:

◆ walltime_reset()

void walltime_reset ( void  )

Definition at line 176 of file walltime.c.

176  {
178 }

References seconds(), and WallTimeClock.

Referenced by walltime_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ walltime_summary()

void walltime_summary ( const int  root,
MPI_Comm  comm 
)

Definition at line 55 of file walltime.c.

55  {
57  int i;
58  /* add to the cumulative time */
59  for(i = 0; i < CT->N; i ++) {
60  CT->AC[i].time += CT->C[i].time;
61  }
62  walltime_summary_clocks(CT->C, CT->N, root, comm);
63  walltime_summary_clocks(CT->AC, CT->N, root, comm);
64 
65  /* clear .time for next step */
66  for(i = 0; i < CT->N; i ++) {
67  CT->C[i].time = 0;
68  }
69  MPI_Barrier(comm);
70  /* wo do this here because all processes are sync after summary_clocks*/
71  double step_all = seconds() - LastReportTime;
73  CT->ElapsedTime += step_all;
74  CT->StepTime = step_all;
75 }
static void walltime_update_parents(void)
Definition: walltime.c:154
static void walltime_summary_clocks(struct Clock *C, int N, int root, MPI_Comm comm)
Definition: walltime.c:29

References ClockTable::AC, ClockTable::C, CT, ClockTable::ElapsedTime, LastReportTime, ClockTable::N, seconds(), ClockTable::StepTime, Clock::time, walltime_summary_clocks(), and walltime_update_parents().

Referenced by compute_global_quantities_of_system(), and main().

Here is the call graph for this function:
Here is the caller graph for this function: