forked from petsc/petsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpetsclogtypes.h
223 lines (181 loc) · 9.42 KB
/
petsclogtypes.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#pragma once
#include <petscsystypes.h>
/* SUBMANSEC = Profiling */
/*S
PetscEventPerfInfo - statistics on how many times the event is used, how much time it takes, etc.
Level: advanced
Note:
This is the data structure that describes profiling statsitics collected for an event from
the default log handler (`PetscLogDefaultBegin()`) using `PetscLogEventGetPerfInfo()`.
.seealso(): [](ch_profiling)
S*/
typedef struct {
int id; /* The integer identifying this event / stage */
PetscBool active; /* Deprecated */
PetscBool visible; /* The flag to print info in summary */
int depth; /* The nesting depth of the event call */
int count; /* The number of times this event was executed */
PetscLogDouble flops; /* The flops used in this event */
PetscLogDouble flops2; /* The square of flops used in this event */
PetscLogDouble flopsTmp; /* The accumulator for flops used in this event */
PetscLogDouble time; /* The time taken for this event */
PetscLogDouble time2; /* The square of time taken for this event */
PetscLogDouble timeTmp; /* The accumulator for time taken for this event */
PetscLogDouble syncTime; /* The synchronization barrier time */
PetscLogDouble dof[8]; /* The number of degrees of freedom associated with this event */
PetscLogDouble errors[8]; /* The errors (user-defined) associated with this event */
PetscLogDouble numMessages; /* The number of messages in this event */
PetscLogDouble messageLength; /* The total message lengths in this event */
PetscLogDouble numReductions; /* The number of reductions in this event */
PetscLogDouble memIncrease; /* How much the resident memory has increased in this event */
PetscLogDouble mallocIncrease; /* How much the maximum malloced space has increased in this event */
PetscLogDouble mallocSpace; /* How much the space was malloced and kept during this event */
PetscLogDouble mallocIncreaseEvent; /* Maximum of the high water mark with in event minus memory available at the end of the event */
#if defined(PETSC_HAVE_DEVICE)
PetscLogDouble CpuToGpuCount; /* The total number of CPU to GPU copies */
PetscLogDouble GpuToCpuCount; /* The total number of GPU to CPU copies */
PetscLogDouble CpuToGpuSize; /* The total size of CPU to GPU copies */
PetscLogDouble GpuToCpuSize; /* The total size of GPU to CPU copies */
PetscLogDouble GpuFlops; /* The flops done on a GPU in this event */
PetscLogDouble GpuTime; /* The time spent on a GPU in this event */
#endif
} PetscEventPerfInfo;
typedef struct _n_PetscIntStack *PetscIntStack;
/*MC
PetscLogEvent - id used to identify PETSc or user events which timed portions (blocks of executable)
code.
Level: intermediate
.seealso: [](ch_profiling), `PetscLogEventRegister()`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogStage`
M*/
typedef int PetscLogEvent;
/*MC
PetscLogStage - id used to identify user stages (phases, sections) of runs - for logging
Level: intermediate
.seealso: [](ch_profiling), `PetscLogStageRegister()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogEvent`
M*/
typedef int PetscLogStage;
/*MC
PetscLogClass - id used to identify classes for logging purposes only. It
is not equal to its `PetscClassId`, which is the identifier used for other
purposes.
Level: developer
.seealso: [](ch_profiling), `PetscLogStateClassRegister()`
M*/
typedef int PetscLogClass;
/*S
PetscLogHandler - Interface for performance logging. A log handler receives a `PetscLogState` that has
information about the events (`PetscLogEvent`) and stages (`PetscLogStage`) in the logging environment.
When a handler is connected to PETSc's global logging stream (`PetscLogHandlerStart()`), it receives
updates about events (`PetscLogEventBegin()` / `PetscLogEventEnd()`), stages (`PetscLogStagePush()` /
`PetscLogStagePop()`), and objects (`PetscLogObjectCreate()` / `PetscLogObjectDestroy()`). After
collecting information the logger can summarize its data with `PetscLogHandlerView()`.
Example Usage:
.vb
#include <petscsys.h>
int main() {
UserCtx ctx;
PetscLogHandlerType handler_type;
PetscInitialize(...);
// ... fill in ctx
PetscLogHandlerCreate(PETSC_COMM_WORLD, &handler);
PetscLogHandlerSetType(handler, handler_type);
PetscLogHandlerStart(handler); // connect your handler to global logging state
// ... run code to be profiled
PetscLogHandlerStop(handler); // disconnect your handler from the global logging state
PetscLogHandlerView(handler, PETSC_VIEWER_STDOUT_WORLD); // view the results
PetscLogHandlerDestroy(&handler);
PetscFinalize();
}
.ve
Level: developer
.seealso: [](ch_profiling),
`PetscLogHandlerCreate()`,
`PetscLogHandlerStart()`, `PetscLogHandlerStop()`,
`PetscLogHandlerSetType()`, `PetscLogHandlerGetType()`,
`PetscLogHandlerSetState()`, `PetscLogHandlerGetState()`,
`PetscLogHandlerEventBegin()`, `PetscLogHandlerEventEnd()`,
`PetscLogHandlerEventSync()`,
`PetscLogHandlerObjectCreate()`, `PetscLogHandlerObjectDestroy()`,
`PetscLogHandlerStagePush()`, `PetscLogHandlerStagePop()`,
`PetscLogHandlerView()`,
`PetscLogHandlerDestroy()`,
S*/
typedef struct _p_PetscLogHandler *PetscLogHandler;
/*J
PetscLogHandlerType - String with the name of a `PetscLogHandler` type
Level: Developer
Note:
Implementations included with PETSc include\:
+ `PETSCLOGHANDLERDEFAULT` (`PetscLogDefaultBegin()`) - formats data for PETSc's default summary (`PetscLogView()`) and data-dump (`PetscLogDump()`) formats.
. `PETSCLOGHANDLERNESTED` (`PetscLogNestedBegin()`) - formats data for XML or flamegraph output
. `PETSCLOGHANDLERTRACE` (`PetscLogTraceBegin()`) - traces profiling events in an output stream
. `PETSCLOGHANDLERMPE` (`PetscLogMPEBegin()`) - outputs parallel performance visualization using MPE
. `PETSCLOGHANDLERPERFSTUBS` (`PetscLogPerfstubsBegin()`) - outputs instrumentation data for PerfStubs/TAU
. `PETSCLOGHANDLERLEGACY` (`PetscLogLegacyCallbacksBegin()`) - adapts legacy callbacks to the `PetscLogHandler` interface
- `PETSCLOGHANDLERNVTX` - creates NVTX ranges for events that are visible in Nsight
.seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogHandlerSetType()`, `PetscLogHandlerGetType()`
J*/
typedef const char *PetscLogHandlerType;
#define PETSCLOGHANDLERDEFAULT "default"
#define PETSCLOGHANDLERNESTED "nested"
#define PETSCLOGHANDLERTRACE "trace"
#define PETSCLOGHANDLERMPE "mpe"
#define PETSCLOGHANDLERPERFSTUBS "perfstubs"
#define PETSCLOGHANDLERLEGACY "legacy"
#define PETSCLOGHANDLERNVTX "nvtx"
typedef struct _n_PetscLogRegistry *PetscLogRegistry;
/*S
PetscLogState - Interface for the shared state information used by `PetscLogHandler`s.
Most users will not need to reference a `PetscLogState` directly: global logging routines
like `PetscLogEventRegister()` and `PetscLogStagePush()` implicitly manipulate PETSc's global
logging state, `PetscLogGetState()`.
Level: developer
Notes:
`PetscLogState` holds a registry of events (`PetscLogStateEventRegister()`), stages
(`PetscLogStateStageRegister()`), and classes (`PetscLogStateClassRegister()`).
It keeps track of when the user has activated events (`PetscLogStateEventSetActive()`) and
stages (`PetscLogStateStageSetActive()`). It also keeps a stack of running stages
(`PetscLogStateStagePush()`, `PetscLogStateStagePop()`).
The struct defining `PetscLogState` is in a public header so that `PetscLogEventBegin()`,
`PetscLogEventEnd()`, `PetscLogObjectCreate()`, and `PetscLogObjectDestroy()` can be defined
as macros rather than function calls, but users are discouraged from directly accessing
the struct's fields, which are subject to change.
.seealso: [](ch_profiling), `PetscLogStateCreate()`, `PetscLogStateDestroy()`
S*/
typedef struct _n_PetscLogState *PetscLogState;
struct _n_PetscLogState {
PetscLogRegistry registry;
PetscBT active;
PetscIntStack stage_stack;
int current_stage;
int bt_num_stages;
int bt_num_events;
int refct;
};
/*S
PetscLogEventInfo - A registry entry about a logging event for `PetscLogState`.
Level: developer
.seealso: [](ch_profiling), `PetscLogEvent`, `PetscLogState`, `PetscLogStateEventGetInfo()`
S*/
typedef struct {
char *name; /* The name of this event */
PetscClassId classid; /* The class the event is associated with */
PetscBool collective; /* Flag this event as collective */
} PetscLogEventInfo;
/*S
PetscLogClassInfo - A registry entry about a class for `PetscLogState`.
Level: developer
.seealso: [](ch_profiling), `PetscLogClass`, `PetscLogState`, `PetscLogStateStageGetInfo()`
S*/
typedef struct {
char *name; /* The class name */
PetscClassId classid; /* The integer identifying this class */
} PetscLogClassInfo;
/*S
PetscLogStageInfo - A registry entry about a class for `PetscLogState`.
Level: developer
.seealso: [](ch_profiling), `PetscLogStage`, `PetscLogState`, `PetscLogStateClassGetInfo()`
S*/
typedef struct _PetscLogStageInfo {
char *name; /* The stage name */
} PetscLogStageInfo;