-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpitrace.h
205 lines (182 loc) · 6.56 KB
/
mpitrace.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#define _GNU_SOURCE
#include <mpi.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <execinfo.h>
#include <sys/resource.h>
#include <utmpx.h>
#ifdef USE_NVTX
#include <cuda_profiler_api.h>
#include <nvToolsExt.h>
#endif
/*----------------------------------------------------------*/
/* dimensions of arrays */
/*----------------------------------------------------------*/
#define MAX_BINS 31
#define MAX_IDS 146
#define SORT_ASCENDING_ORDER 1
#define SORT_DESCENDING_ORDER -1
/*----------------------------------------------------------*/
/* define a structure to hold trace events */
/*----------------------------------------------------------*/
static int max_events = 100000;
struct intPair { int src; int dest; };
typedef union { long offset; struct intPair ranks; } unType;
struct eventstruct {
double tbeg;
double tend;
int taskid;
int eventid;
unType UN;
int bytes;
int parent;
int grandparent;
int ioflag;
};
struct eventstruct * event;
/*----------------------------------------------------------*/
/* elapsed-time timing functions */
/*----------------------------------------------------------*/
#define WTIME(TV) gettimeofday(&TV, NULL)
#define TCONV(TV) (double) (TV).tv_sec + 1.0e-6*((double) (TV).tv_usec)
/*----------------------------------------------------------*/
/* MPI version 3 uses const qualifiers */
/*----------------------------------------------------------*/
#if MPI_VERSION >= 3
typedef const void * sbuf_t;
typedef const int * iarray_t;
typedef const MPI_Datatype * datarray_t;
typedef const char * name_t;
#else
typedef void * sbuf_t;
typedef int * iarray_t;
typedef MPI_Datatype * datarray_t;
typedef char * name_t;
#endif
/*----------------------------------------------------------*/
/* variables with file scope */
/*----------------------------------------------------------*/
static int taskid = 0;
static int ntasks = 1;
static int jobid = 0;
static char * trace_dir = NULL;
static double elapsed_time, elapsed_time_initial, mpi_init_time;
static double exclusive_time = 0.0, exclusive_time_start;
static double user_time, user_time_initial;
static double system_time, system_time_initial;
static long context_switches, context_switches_initial;
static double max_memory;
static int event_number = 0;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
static int swap_bytes = 0;
#else
static int swap_bytes = 1;
#endif
static int collect_summary = 1;
static int first_summary_start = 1;
static int summary_start_count = 0;
static int first_trace_start = 1;
static int trace_events = 0;
static int enable_tracing = 0;
static int time_window_tracing = 0;
static double trace_begin_time = 0.0;
static double trace_end_time = 0.0;
static int time_window_profiling = 0;
static double profile_begin_time = 0.0;
static double profile_end_time = 0.0;
static int traceback_level = 0;
static int traceback_abort = 0;
static int trace_send_pattern = 0;
static int translate_ranks = 1;
static float * send_bytes = NULL;
static int * send_count = NULL;
static MPI_Group world_group = MPI_GROUP_EMPTY;
static int save_all_tasks = 0;
static int output_filter = 0;
static int use_output_list = 0;
static int trace_max_rank = 127;
static int trace_min_rank = 0;
static int event_buffer_overflow = 0;
static int add_timestamp = 0;
static char timestamp[12];
static long long event_count[MAX_IDS];
static double total_time[MAX_IDS];
static double total_bytes[MAX_IDS];
static char label[MAX_IDS][80];
static long long bin_count[MAX_IDS][MAX_BINS];
static double bin_bytes[MAX_IDS][MAX_BINS];
static double bin_time[MAX_IDS][MAX_BINS];
static double total_size[MAX_BINS];
static int comm_size[MAX_BINS];
static long long comm_count[MAX_IDS][MAX_BINS];
static double comm_bytes[MAX_IDS][MAX_BINS];
static double comm_time[MAX_IDS][MAX_BINS];
static int vprof_profile = 0;
static int pg_profile = 0;
static int comm_profile = 0;
static int collective_barrier = 0;
static int barrier_flag[MAX_IDS];
static double synctime = 0.0;
static char host[80];
static char * hostnames;
static int disable_tracing[MAX_IDS];
/*-----------------------------------------------*/
/* variables for profiling by the caller address */
/*-----------------------------------------------*/
#define MAX_PROFILE_BLOCKS 10000
#define FIFO_DEPTH 16
static int profile_block = 0;
static int profile_by_call_site = 0;
static int profile_fifo[FIFO_DEPTH];
static long long profile_call_count[MAX_PROFILE_BLOCKS][MAX_IDS];;
static int profile_callsite[MAX_PROFILE_BLOCKS];
static double profile_elapsed_time[MAX_PROFILE_BLOCKS];
static double profile_callsite_time[MAX_PROFILE_BLOCKS][MAX_IDS];
/*----------------------------------------------------------*/
/* function prototypes */
/*----------------------------------------------------------*/
static void LogEvent(int, struct timeval, struct timeval, int, int, int, MPI_Comm);
static void LogIOEvent(int, struct timeval, struct timeval, long, int, MPI_Comm);
static void get_parents(int, int *, int *);
static void write_tracefile(FILE *, struct eventstruct *, int);
static void reverse_byte_order(char *, char *, int);
static void swap8(char * in, char * out);
static void swap4(char * in, char * out);
static void write_profile_data(void);
static void write_profile_data_myrank(void);
static int index_from_address(int);
static void print_profile_by_call_site(FILE *);
static void initialize_summary_data(void);
static void stop_timers(void);
static void print_profile_by_call_site(FILE *);
void mpitrace_traceback(int *);
void mpitrace_handler(MPI_Comm *comm, int *error);
void mpitrace_sortx(double *, int, int *, int);
void mpitrace_trace_start(void);
void mpitrace_trace_stop(void);
void mpitrace_summary_start(void);
void mpitrace_summary_stop(void);
void mpitrace_vprof_start(void);
void mpitrace_vprof_stop(void);
void mpitrace_vprof_write(int, int, char *);
#ifdef HPM
void HPM_Init(void);
void HPM_Start(const char *);
void HPM_Stop(const char *);
void HPM_Print(int, int, char *, int);
void HPM_Print_myrank(int, int, char *, int);
#endif
#ifdef HPMPROF
void HPM_Prof_init(void);
void HPM_Prof_Auto_start(void);
void HPM_Prof_start(void);
void HPM_Prof_stop(void);
void HPM_Prof_write(int, int, char *, int);
#endif