21 #include <petscviewer.h>
23 #include "pism/util/Profiling.hh"
24 #include "pism/util/error_handling.hh"
31 PetscErrorCode ierr = PetscClassIdRegister(
"PISM", &
m_classid);
32 PISM_CHK(ierr,
"PetscClassIdRegister");
37 #if PETSC_VERSION_LT(3,20,0)
38 PetscErrorCode ierr = PetscLogAllBegin();
PISM_CHK(ierr,
"PetscLogAllBegin");
40 PetscErrorCode ierr = PetscLogDefaultBegin();
PISM_CHK(ierr,
"PetscLogAllBegin");
47 PetscViewer log_viewer;
49 ierr = PetscViewerCreate(PETSC_COMM_WORLD, &log_viewer);
52 ierr = PetscViewerSetType(log_viewer, PETSCVIEWERASCII);
53 PISM_CHK(ierr,
"PetscViewerSetType");
55 ierr = PetscViewerFileSetName(log_viewer, filename.c_str());
56 PISM_CHK(ierr,
"PetscViewerFileSetName");
58 ierr = PetscViewerPushFormat(log_viewer, PETSC_VIEWER_ASCII_INFO_DETAIL);
59 PISM_CHK(ierr,
"PetscViewerPushFormat");
61 ierr = PetscViewerSetUp(log_viewer);
64 ierr = PetscLogView(log_viewer);
67 ierr = PetscViewerPopFormat(log_viewer);
68 PISM_CHK(ierr,
"PetscViewerPopFormat");
70 ierr = PetscViewerDestroy(&log_viewer);
71 PISM_CHK(ierr,
"PetscViewerDestroy");
76 PetscLogEvent
event = 0;
81 ierr = PetscLogEventRegister(name,
m_classid, &event);
82 PISM_CHK(ierr,
"PetscLogEventRegister");
87 ierr = PetscLogEventBegin(event, 0, 0, 0, 0);
88 PISM_CHK(ierr,
"PetscLogEventBegin");
95 "cannot end event \"%s\" because it was not started",
99 PetscErrorCode ierr = PetscLogEventEnd(
m_events[name], 0, 0, 0, 0);
104 PetscLogStage stage = 0;
109 ierr = PetscLogStageRegister(name, &stage);
110 PISM_CHK(ierr,
"PetscLogStageRegister");
115 ierr = PetscLogStagePush(stage);
116 PISM_CHK(ierr,
"PetscLogStagePush");
121 PetscErrorCode ierr = PetscLogStagePop();
void begin(const char *name) const
std::map< std::string, PetscLogEvent > m_events
void report(const std::string &filename) const
Save detailed profiling data to a Python script.
void end(const char *name) const
void start() const
Enable PETSc logging.
void stage_end(const char *name) const
void stage_begin(const char *name) const
std::map< std::string, PetscLogStage > m_stages
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
#define PISM_CHK(errcode, name)
#define PISM_ERROR_LOCATION