1 #ifndef ASYNC_H_ // IWYU pragma: keep
2 #define ASYNC_H_
3 
4 #include <stddef.h>              // for size_t
5 #include "macros.h"              // for ATTR_PRINTF
6 #include "parallelizing_info.h"
7 
8 /* How long do we typically accept to wait for asynchronous output (=
9  * signals) to be checked ? */
10 #define PREFERRED_ASYNC_LAG     15.0
11 
12 /* This structure **MUST** be made only of doubles, or disaster will
13  * occur */
14 struct timing_interval_data_s {
15     double job[2];  // user, system
16     double thread[2];       // user, system
17     double wct;
18 };
19 typedef struct timing_interval_data_s timing_interval_data[1];
20 
21 struct timing_data {
22     int go_mark;
23     int begin_mark;
24     int end_mark;
25     int last_print;
26     int next_print;
27     int next_async_check;
28     int async_check_period;
29     int which;
30     int ntimers;
31     char ** names;
32     size_t * items;
33     timing_interval_data * since_last_reset;
34     timing_interval_data * since_beginning;
35     /* values stored in the timing_interval_data structures correspond to
36      * time interval values, except for the [which] structure, where it
37      * is (the opposite of) the time since when we've been measuring on
38      * its account. Switching from a timer to another then means getting
39      * a clock tick, adding it to counter [which], and subtracting it to
40      * another (which will then become [which]).
41      */
42 };
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 void timing_init(struct timing_data * t, int n, int start, int end);
49 void timing_set_timer_name(struct timing_data * t, int i, const char *, ...)
50     ATTR_PRINTF(3, 4);
51 void timing_set_timer_items(struct timing_data * t, int i, size_t count);
52 void timing_clear(struct timing_data * t);
53 void timing_next_timer(struct timing_data * t);
54 
55 void timing_check(parallelizing_info pi, struct timing_data * t, int iter, int print);
56 void timing_update_ticks(struct timing_data * t, int iter);
57 void timing_disp_collective_oneline(parallelizing_info pi, struct timing_data * timing, int iter, int print, const char * stage);
58 void timing_final_tally(parallelizing_info pi, struct timing_data * timing, int print, const char * stage);
59 
60 void block_control_signals();
61 void catch_control_signals();
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif	/* ASYNC_H_ */
68