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 /*@ 377 PetscLogHandlerSetLogActions - Determines whether actions are logged for a log handler. 378 379 Not Collective 380 381 Input Parameters: 382 + handler - a `PetscLogHandler` 383 - flag - `PETSC_TRUE` if actions are to be logged (ignored if `handler` does not log actions) 384 385 Level: developer 386 387 Notes: 388 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 389 `PetscLogSetLogActions()` to call this function for the default log handler that is connected to the global 390 logging state (`PetscLogGetState()`). 391 392 Logging of actions continues to consume more memory as the program runs. Long running programs should consider 393 turning this feature off. 394 395 .seealso: [](ch_profiling), `PetscLogSetLogActions()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()` 396 @*/ 397 PetscErrorCode PetscLogHandlerSetLogActions(PetscLogHandler handler, PetscBool flag) 398 { 399 PetscFunctionBegin; 400 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 401 PetscTryMethod(handler, "PetscLogHandlerSetLogActions_C", (PetscLogHandler, PetscBool), (handler, flag)); 402 PetscFunctionReturn(PETSC_SUCCESS); 403 } 404 405 /*@ 406 PetscLogHandlerSetLogObjects - Determines whether objects are logged for a log handler. 407 408 Not Collective 409 410 Input Parameters: 411 + handler - a `PetscLogHandler` 412 - flag - `PETSC_TRUE` if objects are to be logged (ignored if `handler` does not log objects) 413 414 Level: developer 415 416 Notes: 417 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 418 `PetscLogSetLogObjects()` to call this function for the default log handler that is connected to the global 419 logging state (`PetscLogGetState()`). 420 421 Logging of objects continues to consume more memory as the program runs. Long running programs should consider 422 turning this feature off. 423 424 .seealso: [](ch_profiling), `PetscLogSetLogObjects()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()` 425 @*/ 426 PetscErrorCode PetscLogHandlerSetLogObjects(PetscLogHandler handler, PetscBool flag) 427 { 428 PetscFunctionBegin; 429 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 430 PetscTryMethod(handler, "PetscLogHandlerSetLogObjects_C", (PetscLogHandler, PetscBool), (handler, flag)); 431 PetscFunctionReturn(PETSC_SUCCESS); 432 } 433 434 PetscErrorCode PetscLogHandlerLogObjectState_Internal(PetscLogHandler handler, PetscObject obj, const char format[], va_list argp) 435 { 436 PetscFunctionBegin; 437 PetscTryMethod(handler, "PetscLogHandlerLogObjectState_C", (PetscLogHandler, PetscObject, const char *, va_list), (handler, obj, format, argp)); 438 PetscFunctionReturn(PETSC_SUCCESS); 439 } 440 441 /*@C 442 PetscLogHandlerLogObjectState - Record information about an object with the default log handler 443 444 Not Collective 445 446 Input Parameters: 447 + handler - a `PetscLogHandler` 448 . obj - the `PetscObject` 449 . format - a printf-style format string 450 - ... - printf arguments to format 451 452 Level: developer 453 454 Note: 455 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 456 `PetscLogObjectState()` to call this function for the default log handler that is connected to the global 457 logging state (`PetscLogGetState()`). 458 459 .seealso: [](ch_profiling), `PetcLogObjectState`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogGetDefaultHandler()` 460 @*/ 461 PetscErrorCode PetscLogHandlerLogObjectState(PetscLogHandler handler, PetscObject obj, const char format[], ...) 462 { 463 va_list argp; 464 465 PetscFunctionBegin; 466 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 467 PetscValidHeader(obj, 2); 468 PetscAssertPointer(format, 3); 469 va_start(argp, format); 470 PetscCall(PetscLogHandlerLogObjectState_Internal(handler, obj, format, argp)); 471 va_end(argp); 472 PetscFunctionReturn(PETSC_SUCCESS); 473 } 474 475 /*@ 476 PetscLogHandlerGetNumObjects - Get the number of objects that were logged with a log handler 477 478 Not Collective 479 480 Input Parameter: 481 . handler - a `PetscLogHandler` 482 483 Output Parameter: 484 . num_objects - the number of objects whose creations and destructions were logged with `handler` 485 (`PetscLogHandlerObjectCreate()` / `PetscLogHandlerObjectDestroy()`), or -1 486 if the handler does not keep track of this number. 487 488 Level: developer 489 490 Note: 491 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. 492 493 .seealso: [](ch_profiling) 494 @*/ 495 PetscErrorCode PetscLogHandlerGetNumObjects(PetscLogHandler handler, PetscInt *num_objects) 496 { 497 PetscFunctionBegin; 498 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 499 PetscAssertPointer(num_objects, 2); 500 PetscTryMethod(handler, "PetscLogHandlerGetNumObjects_C", (PetscLogHandler, PetscInt *), (handler, num_objects)); 501 PetscFunctionReturn(PETSC_SUCCESS); 502 } 503 504 /*@ 505 PetscLogHandlerEventDeactivatePush - Temporarily deactivate a logging event for a log handler 506 507 Not collective 508 509 Input Parameters: 510 + handler - a `PetscLogHandler` 511 . stage - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage) 512 - event - a `PetscLogEvent` 513 514 Level: developer 515 516 Note: 517 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 518 `PetscLogEventDeactivatePush()` to call this function for the default log handler that is connected to the global 519 logging state (`PetscLogGetState()`). 520 521 .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePop()` 522 @*/ 523 PetscErrorCode PetscLogHandlerEventDeactivatePush(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event) 524 { 525 PetscFunctionBegin; 526 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 527 PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePush_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event)); 528 PetscFunctionReturn(PETSC_SUCCESS); 529 } 530 531 /*@ 532 PetscLogHandlerEventDeactivatePop - Undo temporary deactivation 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 `PetscLogEventDeactivatePop()` to call this function for the default log handler that is connected to the global 546 logging state (`PetscLogGetState()`). 547 548 .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePush()` 549 @*/ 550 PetscErrorCode PetscLogHandlerEventDeactivatePop(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event) 551 { 552 PetscFunctionBegin; 553 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 554 PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePop_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event)); 555 PetscFunctionReturn(PETSC_SUCCESS); 556 } 557 558 /*@ 559 PetscLogHandlerEventsPause - Put event logging into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler 560 561 Not collective 562 563 Input Parameter: 564 . handler - a `PetscLogHandler` 565 566 Level: developer 567 568 Note: 569 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 570 `PetscLogEventsPause()` to call this function for the default log handler that is connected to the global 571 logging state (`PetscLogGetState()`). 572 573 .seealso: [](ch_profiling), `PetscLogHandlerEventsResume()` 574 @*/ 575 PetscErrorCode PetscLogHandlerEventsPause(PetscLogHandler handler) 576 { 577 PetscFunctionBegin; 578 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 579 PetscTryMethod(handler, "PetscLogHandlerEventsPause_C", (PetscLogHandler), (handler)); 580 PetscFunctionReturn(PETSC_SUCCESS); 581 } 582 583 /*@ 584 PetscLogHandlerEventsResume - Resume event logging that had been put into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler 585 586 Not collective 587 588 Input Parameter: 589 . handler - a `PetscLogHandler` 590 591 Level: developer 592 593 Note: 594 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 595 `PetscLogEventsResume()` to call this function for the default log handler that is connected to the global 596 logging state (`PetscLogGetState()`). 597 598 .seealso: [](ch_profiling), `PetscLogHandlerEventsPause()` 599 @*/ 600 PetscErrorCode PetscLogHandlerEventsResume(PetscLogHandler handler) 601 { 602 PetscFunctionBegin; 603 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 604 PetscTryMethod(handler, "PetscLogHandlerEventsResume_C", (PetscLogHandler), (handler)); 605 PetscFunctionReturn(PETSC_SUCCESS); 606 } 607 608 /*@ 609 PetscLogHandlerDump - Dump the records of a log handler to file 610 611 Not collective 612 613 Input Parameters: 614 + handler - a `PetscLogHandler` 615 - sname - the name of the file to dump log data to 616 617 Level: developer 618 619 Note: 620 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 621 `PetscLogDump()` to call this function for the default log handler that is connected to the global 622 logging state (`PetscLogGetState()`). 623 624 .seealso: [](ch_profiling) 625 @*/ 626 PetscErrorCode PetscLogHandlerDump(PetscLogHandler handler, const char sname[]) 627 { 628 PetscFunctionBegin; 629 PetscTryMethod(handler, "PetscLogHandlerDump_C", (PetscLogHandler, const char *), (handler, sname)); 630 PetscFunctionReturn(PETSC_SUCCESS); 631 } 632 633 /*@ 634 PetscLogHandlerStageSetVisible - Set the visiblity of logging stage in `PetscLogHandlerView()` for a log handler 635 636 Not collective 637 638 Input Parameters: 639 + handler - a `PetscLogHandler` 640 . stage - a `PetscLogStage` 641 - isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`) 642 643 Level: developer 644 645 Note: 646 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 647 `PetscLogStageSetVisible()` to call this function for the default log handler that is connected to the global 648 logging state (`PetscLogGetState()`). 649 650 .seealso: [](ch_profiling), `PetscLogHandlerStageGetVisible()` 651 @*/ 652 PetscErrorCode PetscLogHandlerStageSetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool isVisible) 653 { 654 PetscFunctionBegin; 655 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 656 PetscTryMethod(handler, "PetscLogHandlerStageSetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool), (handler, stage, isVisible)); 657 PetscFunctionReturn(PETSC_SUCCESS); 658 } 659 660 /*@ 661 PetscLogHandlerStageGetVisible - Get 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 669 Output Parameter: 670 . isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`) 671 672 Level: developer 673 674 Note: 675 The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not. You can use 676 `PetscLogStageGetVisible()` to call this function for the default log handler that is connected to the global 677 logging state (`PetscLogGetState()`). 678 679 .seealso: [](ch_profiling), `PetscLogHandlerStageSetVisible()` 680 @*/ 681 PetscErrorCode PetscLogHandlerStageGetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool *isVisible) 682 { 683 PetscFunctionBegin; 684 PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1); 685 PetscTryMethod(handler, "PetscLogHandlerStageGetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool *), (handler, stage, isVisible)); 686 PetscFunctionReturn(PETSC_SUCCESS); 687 } 688