Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
perfs.h
Go to the documentation of this file.
1/** @file perfs.h
2 */
3/**
4# Performance monitoring (for the Navier--Stokes solvers)
5
6This logs simple statistics available for the various [Navier--Stokes
7solvers](/src/README#navierstokes). */
8
9/** @brief Event: perfs (i += 1) */
10void event_perfs (void) {
11 static FILE * fp = fopen ("perfs", "w");
12 if (i == 0)
13 fprintf (fp,
14 "t dt mgp.i mgp.nrelax mgpf.i mgpf.nrelax mgu.i mgu.nrelax "
15 "grid->tn perf.t perf.speed npe perf.ispeed\n");
16 static double start = 0.;
17 if (i > 10 && perf.t - start < 1.) return 0;
18 fprintf (fp, "%g %g %d %d %d %d %d %d %ld %g %g %d %g\n",
20 grid->tn, perf.t, perf.speed, npe(), perf.ispeed);
21 fflush (fp);
22 start = perf.t;
23}
24
25/**
26If we have a display (and gnuplot works), a graph of the statistics is
27displayed and updated at regular intervals (10 seconds as defined in
28[perfs.plot]()). */
29
30/** @brief Event: perf_plot (i = 10) */
31void event_perf_plot (void) {
32 if (getenv ("DISPLAY"))
33 popen ("gnuplot -e 'set term x11 noraise title perfs' "
34 "\f$BASILISK/navier-stokes/perfs.plot 2> /dev/null "
35 "& read dummy; kill \f$! 2> /dev/null", "w");
36}
37
38/**
39The graph looks like this:
40
41![Graph displayed by [perfs.h]()](perfs.png)
42
43## Monitoring a distant run
44
45This can also be useful to monitor what is happening to a simulation
46running on a remote system. The [perfs.sh]() script provides a
47convenient way to do this.
48
49Imagine you started a simulation including the [perfs.h]() file on the
50"mesu" system at UPMC (typically using the queueing system) and that
51the simulation is running in the `wave/level-10/` directory on
52mesu. You can then get a regularly-updated graph of what is happening
53using:
54
55~~~bash
56bash $BASILISK/navier-stokes/perfs.sh mesu.dsi.upmc.fr:wave/level-10/perfs
57~~~
58
59## See also
60
61* [Continuous profiling monitoring](/src/profiling.h).
62*/
mgstats mgu
Definition all-mach.h:66
mgstats mgp
Definition all-mach.h:66
int npe
Definition balance.h:195
mgstats mgpf
Definition centered.h:74
int x
Definition common.h:76
Grid * grid
Definition common.h:32
#define popen
Definition config.h:666
double dt
scalar int i
Definition embed.h:74
double t
Definition events.h:24
void event_perf_plot(void)
If we have a display (and gnuplot works), a graph of the statistics is displayed and updated at regul...
Definition perfs.h:37
FILE * fp
Definition mtrace.h:7
void event_perfs(void)
Event: perfs (i += 1)
Definition perfs.h:10
long tn
Definition common.h:28
int nrelax
Definition poisson.h:116
int i
Definition poisson.h:113
struct @16 perf
Performance statistics are stored in this structure.
src vof fflush(ferr)