1 2 #include <petscviewer.h> 3 #include <petsc/private/logimpl.h> /*I "petscsys.h" I*/ 4 #include <petsc/private/loghandlerimpl.h> 5 #include <petsc/private/petscimpl.h> 6 7 /*@ 8 PetscLogHandlerCreate - Create a log handler for profiling events and stages. PETSc 9 provides several implementations of `PetscLogHandler` that interface to different ways to 10 summarize or visualize profiling data: see `PetscLogHandlerType` for a list. 11 12 Collective 13 14 Input Parameter: 15 . comm - the communicator for synchronizing and viewing events with this handler 16 17 Output Parameter: 18 . handler - the `PetscLogHandler` 19 20 Level: developer 21 22 Notes: 23 This does not put the handler in use in PETSc's global logging system: use `PetscLogHandlerStart()` after creation. 24 25 See `PetscLogHandler` for example usage. 26 27 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogHandlerSetType()`, `PetscLogHandlerStart()`, `PetscLogHandlerStop()` 28 @*/ 29 PetscErrorCode PetscLogHandlerCreate(MPI_Comm comm, PetscLogHandler *handler) 30 { 31 PetscLogHandler h; 32 33 PetscFunctionBegin; 34 *handler = NULL; 35 PetscCall(PetscLogHandlerPackageInitialize()); 36 // We do not use PetscHeaderCreate() here because having PetscLogObjectCreate() run for PetscLogHandler would be very fragile 37 PetscCall(PetscNew(&h)); 38 PetscCall(PetscHeaderCreate_Private((PetscObject)(h), PETSCLOGHANDLER_CLASSID, "PetscLogHandler", "Profile events, stages, and objects", "Profiling", comm, (PetscObjectDestroyFunction)PetscLogHandlerDestroy, (PetscObjectViewFunction)PetscLogHandlerView)); 39 *handler = h; 40 PetscFunctionReturn(PETSC_SUCCESS); 41 } 42 43 /*@ 44 PetscLogHandlerDestroy - Destroy a `PetscLogHandler` 45 46 Logically collective 47 48 Input Parameter: 49 . handler - handler to be destroyed 50 51 Level: developer 52 53 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogHandlerCreate()` 54 @*/ 55 PetscErrorCode PetscLogHandlerDestroy(PetscLogHandler *handler) 56 { 57 PetscLogHandler h; 58 59 PetscFunctionBegin; 60 if (!*handler) PetscFunctionReturn(PETSC_SUCCESS); 61 h = *handler; 62 *handler = NULL; 63 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 64 if (--((PetscObject)h)->refct > 0) PetscFunctionReturn(PETSC_SUCCESS); 65 PetscTryTypeMethod(h, destroy); 66 PetscCall(PetscLogStateDestroy(&h->state)); 67 // We do not use PetscHeaderDestroy() because having PetscLogObjectDestroy() run for PetscLgoHandler would be very fragile 68 PetscCall(PetscHeaderDestroy_Private((PetscObject)(h), PETSC_FALSE)); 69 PetscCall(PetscFree(h)); 70 PetscFunctionReturn(PETSC_SUCCESS); 71 } 72 73 /*@ 74 PetscLogHandlerSetState - Set the logging state that provides the stream of events and stages for a log handler. 75 76 Logically collective 77 78 Input Parameters: 79 + h - the `PetscLogHandler` 80 - state - the `PetscLogState` 81 82 Level: developer 83 84 Note: 85 Most users well not need to set a state explicitly: the global logging state (`PetscLogGetState()`) is set when calling `PetscLogHandlerStart()` 86 87 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogState`, `PetscLogEventBegin()`, `PetscLogHandlerStart()` 88 @*/ 89 PetscErrorCode PetscLogHandlerSetState(PetscLogHandler h, PetscLogState state) 90 { 91 PetscFunctionBegin; 92 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 93 if (state) { 94 PetscAssertPointer(state, 2); 95 state->refct++; 96 } 97 PetscCall(PetscLogStateDestroy(&h->state)); 98 h->state = state; 99 PetscFunctionReturn(PETSC_SUCCESS); 100 } 101 102 /*@ 103 PetscLogHandlerGetState - Get the logging state that provides the stream of events and stages for a log handler. 104 105 Logically collective 106 107 Input Parameter: 108 . h - the `PetscLogHandler` 109 110 Output Parameter: 111 . state - the `PetscLogState` 112 113 Level: developer 114 115 Note: 116 For a log handler started with `PetscLogHandlerStart()`, this will be the PETSc global logging state (`PetscLogGetState()`) 117 118 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogState`, `PetscLogEventBegin()`, `PetscLogHandlerStart()` 119 @*/ 120 PetscErrorCode PetscLogHandlerGetState(PetscLogHandler h, PetscLogState *state) 121 { 122 PetscFunctionBegin; 123 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 124 PetscAssertPointer(state, 2); 125 *state = h->state; 126 PetscFunctionReturn(PETSC_SUCCESS); 127 } 128 129 /*@ 130 PetscLogHandlerEventBegin - Record the beginning of an event in a log handler 131 132 Not collective 133 134 Input Parameters: 135 + h - the `PetscLogHandler` 136 . e - a registered `PetscLogEvent` 137 . o1 - `PetscObject` associated with the event (may be `NULL`) 138 . o2 - `PetscObject` associated with the event (may be `NULL`) 139 . o3 - `PetscObject` associated with the event (may be `NULL`) 140 - o4 - `PetscObject` associated with the event (may be `NULL`) 141 142 Level: developer 143 144 Note: 145 Most users will use `PetscLogEventBegin()`, which will call this function for all handlers registered with `PetscLogHandlerStart()` 146 147 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogEventSync()`, `PetscLogHandlerEventEnd()`, `PetscLogHandlerEventSync()` 148 @*/ 149 PetscErrorCode PetscLogHandlerEventBegin(PetscLogHandler h, PetscLogEvent e, PetscObject o1, PetscObject o2, PetscObject o3, PetscObject o4) 150 { 151 PetscFunctionBegin; 152 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 153 PetscTryTypeMethod(h, eventbegin, e, o1, o2, o3, o4); 154 PetscFunctionReturn(PETSC_SUCCESS); 155 } 156 157 /*@ 158 PetscLogHandlerEventEnd - Record the end of an event in a log handler 159 160 Not collective 161 162 Input Parameters: 163 + h - the `PetscLogHandler` 164 . e - a registered `PetscLogEvent` 165 . o1 - `PetscObject` associated with the event (may be `NULL`) 166 . o2 - `PetscObject` associated with the event (may be `NULL`) 167 . o3 - `PetscObject` associated with the event (may be `NULL`) 168 - o4 - `PetscObject` associated with the event (may be `NULL`) 169 170 Level: developer 171 172 Note: 173 Most users will use `PetscLogEventEnd()`, which will call this function for all handlers registered with `PetscLogHandlerStart()` 174 175 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogEventSync()`, `PetscLogHandlerEventBegin()`, `PetscLogHandlerEventSync()` 176 @*/ 177 PetscErrorCode PetscLogHandlerEventEnd(PetscLogHandler h, PetscLogEvent e, PetscObject o1, PetscObject o2, PetscObject o3, PetscObject o4) 178 { 179 PetscFunctionBegin; 180 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 181 PetscTryTypeMethod(h, eventend, e, o1, o2, o3, o4); 182 PetscFunctionReturn(PETSC_SUCCESS); 183 } 184 185 /*@ 186 PetscLogHandlerEventSync - Synchronize a logging event 187 188 Collective over comm 189 190 Input Parameters: 191 + h - the `PetscLogHandler` 192 . e - a registered `PetscLogEvent` 193 - comm - the communicator over which to synchronize `e` 194 195 Level: developer 196 197 Note: 198 Most users will use `PetscLogEventSync()`, which will call this function for all handlers registered with `PetscLogHandlerStart()` 199 200 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogEventSync()`, `PetscLogHandlerEventBegin()`, `PetscLogHandlerEventEnd()` 201 @*/ 202 PetscErrorCode PetscLogHandlerEventSync(PetscLogHandler h, PetscLogEvent e, MPI_Comm comm) 203 { 204 MPI_Comm h_comm; 205 PetscMPIInt size; 206 207 PetscFunctionBegin; 208 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 209 PetscCall(PetscObjectGetComm((PetscObject)h, &h_comm)); 210 PetscCallMPI(MPI_Comm_size(comm, &size)); 211 if (comm == MPI_COMM_NULL || size == 1) PetscFunctionReturn(PETSC_SUCCESS); // nothing to sync 212 if (PetscDefined(USE_DEBUG)) { 213 PetscMPIInt h_comm_world, compare; 214 PetscCallMPI(MPI_Comm_compare(h_comm, PETSC_COMM_WORLD, &h_comm_world)); 215 PetscCallMPI(MPI_Comm_compare(h_comm, comm, &compare)); 216 // only synchronze if h->comm and comm have the same processes or h->comm is PETSC_COMM_WORLD 217 PetscCheck(h_comm_world != MPI_UNEQUAL || compare != MPI_UNEQUAL, comm, PETSC_ERR_SUP, "PetscLogHandlerSync does not support arbitrary mismatched communicators"); 218 } 219 PetscTryTypeMethod(h, eventsync, e, comm); 220 PetscFunctionReturn(PETSC_SUCCESS); 221 } 222 223 /*@ 224 PetscLogHandlerObjectCreate - Record the creation of an object in a log handler. 225 226 Not collective 227 228 Input Parameters: 229 + h - the `PetscLogHandler` 230 - obj - a newly created `PetscObject` 231 232 Level: developer 233 234 Notes: 235 Most users will use `PetscLogObjectCreate()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`. 236 237 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogHandlerObjectDestroy()` 238 @*/ 239 PetscErrorCode PetscLogHandlerObjectCreate(PetscLogHandler h, PetscObject obj) 240 { 241 PetscFunctionBegin; 242 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 243 PetscTryTypeMethod(h, objectcreate, obj); 244 PetscFunctionReturn(PETSC_SUCCESS); 245 } 246 247 /*@ 248 PetscLogHandlerObjectDestroy - Record the destruction of an object in a log handler. 249 250 Not collective 251 252 Input Parameters: 253 + h - the `PetscLogHandler` 254 - obj - a newly created `PetscObject` 255 256 Level: developer 257 258 Notes: 259 Most users will use `PetscLogObjectDestroy()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`. 260 261 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogHandlerObjectCreate()` 262 @*/ 263 PetscErrorCode PetscLogHandlerObjectDestroy(PetscLogHandler h, PetscObject obj) 264 { 265 PetscFunctionBegin; 266 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 267 PetscTryTypeMethod(h, objectdestroy, obj); 268 PetscFunctionReturn(PETSC_SUCCESS); 269 } 270 271 /*@ 272 PetscLogHandlerStagePush - Begin a new logging stage in a log handler. 273 274 Not collective 275 276 Input Parameters: 277 + h - the `PetscLogHandler` 278 - stage - a registered `PetscLogStage` 279 280 Level: developer 281 282 Notes: 283 Most users will use `PetscLogStagePush()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`. 284 285 This function is called right before the stage is pushed for the handler's `PetscLogState`, so `PetscLogStateGetCurrentStage()` 286 can be used to see what the previous stage was. 287 288 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogHandlerStagePop()` 289 @*/ 290 PetscErrorCode PetscLogHandlerStagePush(PetscLogHandler h, PetscLogStage stage) 291 { 292 PetscFunctionBegin; 293 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 294 PetscTryTypeMethod(h, stagepush, stage); 295 PetscFunctionReturn(PETSC_SUCCESS); 296 } 297 298 /*@ 299 PetscLogHandlerStagePop - End the current logging stage in a log handler. 300 301 Not collective 302 303 Input Parameters: 304 + h - the `PetscLogHandler` 305 - stage - a registered `PetscLogStage` 306 307 Level: developer 308 309 Notes: 310 Most users will use `PetscLogStagePop()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`. 311 312 This function is called right after the stage is popped for the handler's `PetscLogState`, so `PetscLogStateGetCurrentStage()` 313 can be used to see what the next stage will be. 314 315 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogHandlerStagePush()` 316 @*/ 317 PetscErrorCode PetscLogHandlerStagePop(PetscLogHandler h, PetscLogStage stage) 318 { 319 PetscFunctionBegin; 320 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 321 PetscTryTypeMethod(h, stagepop, stage); 322 PetscFunctionReturn(PETSC_SUCCESS); 323 } 324 325 /*@ 326 PetscLogHandlerView - View the data recorded in a log handler. 327 328 Collective 329 330 Input Parameters: 331 + h - the `PetscLogHandler` 332 - viewer - the `PetscViewer` 333 334 Level: developer 335 336 .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogView()` 337 @*/ 338 PetscErrorCode PetscLogHandlerView(PetscLogHandler h, PetscViewer viewer) 339 { 340 PetscFunctionBegin; 341 PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1); 342 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 2); 343 PetscTryTypeMethod(h, view, viewer); 344 PetscFunctionReturn(PETSC_SUCCESS); 345 } 346 347 /*@C 348 PetscLogHandlerGetEventPerfInfo - Get a direct reference to the `PetscEventPerfInfo` of a stage and event 349 350 Not collective 351 352 Input Parameters: 353 + handler - a `PetscLogHandler` 354 . stage - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage) 355 - event - a `PetscLogEvent` 356 357 Output Parameter: 358 . event_info - a pointer to a performance log for `event` during `stage` (or `NULL` if this handler does not use 359 `PetscEventPerfInfo` to record performance data); writing to `event_info` will change the record in 360 `handler` 361 362 Level: developer 363 364 .seealso: [](ch_profiling), `PetscLogEventGetPerfInfo()`, `PETSCLOGHANDLERDEFAULT` 365 @*/ 366 PetscErrorCode PetscLogHandlerGetEventPerfInfo(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event, PetscEventPerfInfo **event_info) 367 { 368 PetscFunctionBegin; 369 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 370 PetscAssertPointer(event_info, 4); 371 *event_info = NULL; 372 PetscTryMethod(handler, "PetscLogHandlerGetEventPerfInfo_C", (PetscLogHandler, PetscLogStage, PetscLogEvent, PetscEventPerfInfo **), (handler, stage, event, event_info)); 373 PetscFunctionReturn(PETSC_SUCCESS); 374 } 375 376 /*@C 377 PetscLogHandlerGetStagePerfInfo - Get a direct reference to the `PetscEventPerfInfo` of a stage 378 379 Not collective 380 381 Input Parameters: 382 + handler - a `PetscLogHandler` 383 - stage - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage) 384 385 Output Parameter: 386 . stage_info - a pointer to a performance log for `stage` (or `NULL` if this handler does not use `PetscEventPerfInfo` 387 to record performance data); writing to `stage_info` will change the record in `handler` 388 389 Level: developer 390 391 .seealso: [](ch_profiling), `PetscLogEventGetPerfInfo()`, `PETSCLOGHANDLERDEFAULT` 392 @*/ 393 PetscErrorCode PetscLogHandlerGetStagePerfInfo(PetscLogHandler handler, PetscLogStage stage, PetscEventPerfInfo **stage_info) 394 { 395 PetscFunctionBegin; 396 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 397 PetscAssertPointer(stage_info, 3); 398 *stage_info = NULL; 399 PetscTryMethod(handler, "PetscLogHandlerGetStagePerfInfo_C", (PetscLogHandler, PetscLogStage, PetscEventPerfInfo **), (handler, stage, stage_info)); 400 PetscFunctionReturn(PETSC_SUCCESS); 401 } 402 403 /*@ 404 PetscLogHandlerSetLogActions - Determines whether actions are logged for a log handler. 405 406 Not Collective 407 408 Input Parameters: 409 + handler - a `PetscLogHandler` 410 - flag - `PETSC_TRUE` if actions are to be logged (ignored if `handler` does not log actions) 411 412 Level: developer 413 414 Notes: 415 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 416 `PetscLogSetLogActions()` to call this function for the default log handler that is connected to the global 417 logging state (`PetscLogGetState()`). 418 419 Logging of actions continues to consume more memory as the program runs. Long running programs should consider 420 turning this feature off. 421 422 .seealso: [](ch_profiling), `PetscLogSetLogActions()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()` 423 @*/ 424 PetscErrorCode PetscLogHandlerSetLogActions(PetscLogHandler handler, PetscBool flag) 425 { 426 PetscFunctionBegin; 427 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 428 PetscTryMethod(handler, "PetscLogHandlerSetLogActions_C", (PetscLogHandler, PetscBool), (handler, flag)); 429 PetscFunctionReturn(PETSC_SUCCESS); 430 } 431 432 /*@ 433 PetscLogHandlerSetLogObjects - Determines whether objects are logged for a log handler. 434 435 Not Collective 436 437 Input Parameters: 438 + handler - a `PetscLogHandler` 439 - flag - `PETSC_TRUE` if objects are to be logged (ignored if `handler` does not log objects) 440 441 Level: developer 442 443 Notes: 444 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 445 `PetscLogSetLogObjects()` to call this function for the default log handler that is connected to the global 446 logging state (`PetscLogGetState()`). 447 448 Logging of objects continues to consume more memory as the program runs. Long running programs should consider 449 turning this feature off. 450 451 .seealso: [](ch_profiling), `PetscLogSetLogObjects()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()` 452 @*/ 453 PetscErrorCode PetscLogHandlerSetLogObjects(PetscLogHandler handler, PetscBool flag) 454 { 455 PetscFunctionBegin; 456 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 457 PetscTryMethod(handler, "PetscLogHandlerSetLogObjects_C", (PetscLogHandler, PetscBool), (handler, flag)); 458 PetscFunctionReturn(PETSC_SUCCESS); 459 } 460 461 PetscErrorCode PetscLogHandlerLogObjectState_Internal(PetscLogHandler handler, PetscObject obj, const char format[], va_list argp) 462 { 463 PetscFunctionBegin; 464 PetscTryMethod(handler, "PetscLogHandlerLogObjectState_C", (PetscLogHandler, PetscObject, const char *, va_list), (handler, obj, format, argp)); 465 PetscFunctionReturn(PETSC_SUCCESS); 466 } 467 468 /*@C 469 PetscLogHandlerLogObjectState - Record information about an object with the default log handler 470 471 Not Collective 472 473 Input Parameters: 474 + handler - a `PetscLogHandler` 475 . obj - the `PetscObject` 476 . format - a printf-style format string 477 - ... - printf arguments to format 478 479 Level: developer 480 481 Note: 482 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 483 `PetscLogObjectState()` to call this function for the default log handler that is connected to the global 484 logging state (`PetscLogGetState()`). 485 486 .seealso: [](ch_profiling), `PetcLogObjectState`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogGetDefaultHandler()` 487 @*/ 488 PetscErrorCode PetscLogHandlerLogObjectState(PetscLogHandler handler, PetscObject obj, const char format[], ...) 489 { 490 va_list argp; 491 492 PetscFunctionBegin; 493 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 494 PetscValidHeader(obj, 2); 495 PetscAssertPointer(format, 3); 496 va_start(argp, format); 497 PetscCall(PetscLogHandlerLogObjectState_Internal(handler, obj, format, argp)); 498 va_end(argp); 499 PetscFunctionReturn(PETSC_SUCCESS); 500 } 501 502 /*@ 503 PetscLogHandlerGetNumObjects - Get the number of objects that were logged with a log handler 504 505 Not Collective 506 507 Input Parameter: 508 . handler - a `PetscLogHandler` 509 510 Output Parameter: 511 . num_objects - the number of objects whose creations and destructions were logged with `handler` 512 (`PetscLogHandlerObjectCreate()` / `PetscLogHandlerObjectDestroy()`), or -1 513 if the handler does not keep track of this number. 514 515 Level: developer 516 517 Note: 518 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. 519 520 .seealso: [](ch_profiling) 521 @*/ 522 PetscErrorCode PetscLogHandlerGetNumObjects(PetscLogHandler handler, PetscInt *num_objects) 523 { 524 PetscFunctionBegin; 525 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 526 PetscAssertPointer(num_objects, 2); 527 PetscTryMethod(handler, "PetscLogHandlerGetNumObjects_C", (PetscLogHandler, PetscInt *), (handler, num_objects)); 528 PetscFunctionReturn(PETSC_SUCCESS); 529 } 530 531 /*@ 532 PetscLogHandlerEventDeactivatePush - Temporarily deactivate a logging event for a log handler 533 534 Not collective 535 536 Input Parameters: 537 + handler - a `PetscLogHandler` 538 . stage - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage) 539 - event - a `PetscLogEvent` 540 541 Level: developer 542 543 Note: 544 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 545 `PetscLogEventDeactivatePush()` to call this function for the default log handler that is connected to the global 546 logging state (`PetscLogGetState()`). 547 548 .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePop()` 549 @*/ 550 PetscErrorCode PetscLogHandlerEventDeactivatePush(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event) 551 { 552 PetscFunctionBegin; 553 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 554 PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePush_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event)); 555 PetscFunctionReturn(PETSC_SUCCESS); 556 } 557 558 /*@ 559 PetscLogHandlerEventDeactivatePop - Undo temporary deactivation a logging event for a log handler 560 561 Not collective 562 563 Input Parameters: 564 + handler - a `PetscLogHandler` 565 . stage - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage) 566 - event - a `PetscLogEvent` 567 568 Level: developer 569 570 Note: 571 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 572 `PetscLogEventDeactivatePop()` to call this function for the default log handler that is connected to the global 573 logging state (`PetscLogGetState()`). 574 575 .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePush()` 576 @*/ 577 PetscErrorCode PetscLogHandlerEventDeactivatePop(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event) 578 { 579 PetscFunctionBegin; 580 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 581 PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePop_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event)); 582 PetscFunctionReturn(PETSC_SUCCESS); 583 } 584 585 /*@ 586 PetscLogHandlerEventsPause - Put event logging into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler 587 588 Not collective 589 590 Input Parameter: 591 . handler - a `PetscLogHandler` 592 593 Level: developer 594 595 Note: 596 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 597 `PetscLogEventsPause()` to call this function for the default log handler that is connected to the global 598 logging state (`PetscLogGetState()`). 599 600 .seealso: [](ch_profiling), `PetscLogHandlerEventsResume()` 601 @*/ 602 PetscErrorCode PetscLogHandlerEventsPause(PetscLogHandler handler) 603 { 604 PetscFunctionBegin; 605 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 606 PetscTryMethod(handler, "PetscLogHandlerEventsPause_C", (PetscLogHandler), (handler)); 607 PetscFunctionReturn(PETSC_SUCCESS); 608 } 609 610 /*@ 611 PetscLogHandlerEventsResume - Resume event logging that had been put into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler 612 613 Not collective 614 615 Input Parameter: 616 . handler - a `PetscLogHandler` 617 618 Level: developer 619 620 Note: 621 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 622 `PetscLogEventsResume()` to call this function for the default log handler that is connected to the global 623 logging state (`PetscLogGetState()`). 624 625 .seealso: [](ch_profiling), `PetscLogHandlerEventsPause()` 626 @*/ 627 PetscErrorCode PetscLogHandlerEventsResume(PetscLogHandler handler) 628 { 629 PetscFunctionBegin; 630 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 631 PetscTryMethod(handler, "PetscLogHandlerEventsResume_C", (PetscLogHandler), (handler)); 632 PetscFunctionReturn(PETSC_SUCCESS); 633 } 634 635 /*@ 636 PetscLogHandlerDump - Dump the records of a log handler to file 637 638 Not collective 639 640 Input Parameters: 641 + handler - a `PetscLogHandler` 642 - sname - the name of the file to dump log data to 643 644 Level: developer 645 646 Note: 647 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 648 `PetscLogDump()` to call this function for the default log handler that is connected to the global 649 logging state (`PetscLogGetState()`). 650 651 .seealso: [](ch_profiling) 652 @*/ 653 PetscErrorCode PetscLogHandlerDump(PetscLogHandler handler, const char sname[]) 654 { 655 PetscFunctionBegin; 656 PetscTryMethod(handler, "PetscLogHandlerDump_C", (PetscLogHandler, const char *), (handler, sname)); 657 PetscFunctionReturn(PETSC_SUCCESS); 658 } 659 660 /*@ 661 PetscLogHandlerStageSetVisible - Set the visiblity of logging stage in `PetscLogHandlerView()` for a log handler 662 663 Not collective 664 665 Input Parameters: 666 + handler - a `PetscLogHandler` 667 . stage - a `PetscLogStage` 668 - isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`) 669 670 Level: developer 671 672 Note: 673 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 674 `PetscLogStageSetVisible()` to call this function for the default log handler that is connected to the global 675 logging state (`PetscLogGetState()`). 676 677 .seealso: [](ch_profiling), `PetscLogHandlerStageGetVisible()` 678 @*/ 679 PetscErrorCode PetscLogHandlerStageSetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool isVisible) 680 { 681 PetscFunctionBegin; 682 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 683 PetscTryMethod(handler, "PetscLogHandlerStageSetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool), (handler, stage, isVisible)); 684 PetscFunctionReturn(PETSC_SUCCESS); 685 } 686 687 /*@ 688 PetscLogHandlerStageGetVisible - Get the visiblity of logging stage in `PetscLogHandlerView()` for a log handler 689 690 Not collective 691 692 Input Parameters: 693 + handler - a `PetscLogHandler` 694 - stage - a `PetscLogStage` 695 696 Output Parameter: 697 . isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`) 698 699 Level: developer 700 701 Note: 702 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 703 `PetscLogStageGetVisible()` to call this function for the default log handler that is connected to the global 704 logging state (`PetscLogGetState()`). 705 706 .seealso: [](ch_profiling), `PetscLogHandlerStageSetVisible()` 707 @*/ 708 PetscErrorCode PetscLogHandlerStageGetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool *isVisible) 709 { 710 PetscFunctionBegin; 711 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 712 PetscTryMethod(handler, "PetscLogHandlerStageGetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool *), (handler, stage, isVisible)); 713 PetscFunctionReturn(PETSC_SUCCESS); 714 } 715