Actual source code: petsctime.h

  1: /*
  2:        Low cost access to system time. This, in general, should not
  3:      be included in user programs.
  4: */
  5: #ifndef PETSCTIME_H
  6: #define PETSCTIME_H

  8: #include <petscsys.h>

 10: /* SUBMANSEC = Sys */

 12: PETSC_EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble *);

 14: /* Global counters */
 15: PETSC_EXTERN PetscLogDouble petsc_BaseTime;

 17: /*MC
 18:    PetscTime - Returns the current time of day in seconds.

 20:    Synopsis:
 21: #include <petsctime.h>
 22:     PetscErrorCode PetscTime(PetscLogDouble *v)

 24:    Not Collective

 26:    Output Parameter:
 27: .  v - time counter

 29:    Usage:
 30:      PetscLogDouble v;
 31:      PetscTime(&v);
 32:      .... perform some calculation ...
 33:      printf("Time for operation %g\n",v);

 35:    Level: developer

 37:    Notes:
 38:    Since the PETSc libraries incorporate timing of phases and operations,
 39:    we do not recommend ever using PetscTime()
 40:    The options database command  -log_view activate
 41:    PETSc library timing. See Users-Manual: ch_profiling for more details.

 43: .seealso: `PetscTimeSubtract()`, `PetscTimeAdd()`, `PetscLogStageRegister()`, `PetscLogEventRegister()`, `PetscLogEventBegin()`, `PetscLogEventEnd()`

 45: M*/

 47: /*MC
 48:    PetscTimeSubtract - Subtracts the current time of day (in seconds) from
 49:    the value v.

 51:    Synopsis:
 52: #include <petsctime.h>
 53:     PetscErrorCode PetscTimeSubtract(PetscLogDouble *v)

 55:    Not Collective

 57:    Input Parameter:
 58: .  v - time counter

 60:    Output Parameter:
 61: .  v - time counter (v = v - current time)

 63:    Level: developer

 65:    Notes:
 66:    Since the PETSc libraries incorporate timing of phases and operations,
 67:    we do not every recommend using PetscTimeSubtract()
 68:    The options database command  -log_view activates
 69:    PETSc library timing.  See Users-Manual: ch_profiling for more details, also
 70:    see PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() for how to register
 71:    stages and events in application codes.

 73: .seealso: `PetscTime()`, `PetscTimeAdd()`, `PetscLogStageRegister()`, `PetscLogEventRegister()`, `PetscLogEventBegin()`, `PetscLogEventEnd()`

 75: M*/

 77: /*MC
 78:    PetscTimeAdd - Adds the current time of day (in seconds) to the value v.

 80:    Synopsis:
 81: #include <petsctime.h>
 82:     PetscErrorCode PetscTimeAdd(PetscLogDouble *v)

 84:    Not Collective

 86:    Input Parameter:
 87: .  v - time counter

 89:    Output Parameter:
 90: .  v - time counter (v = v + current time)

 92:    Level: developer

 94:    Notes:
 95:    Since the PETSc libraries incorporate timing of phases and operations,
 96:    we do not ever recommend using PetscTimeAdd().
 97:    The options database command -log_view activate
 98:    PETSc library timing. See Users-Manual: ch_profiling for more details.

100: .seealso: `PetscTime()`, `PetscTimeSubtract()`, `PetscLogStageRegister()`, `PetscLogEventRegister()`, `PetscLogEventBegin()`, `PetscLogEventEnd()`

102: M*/

104: static inline PetscErrorCode PetscTime(PetscLogDouble *v)
105: {
106:   *v = MPI_Wtime();
107:   return 0;
108: }

110: static inline PetscErrorCode PetscTimeSubtract(PetscLogDouble *v)
111: {
112:   *v -= MPI_Wtime();
113:   return 0;
114: }

116: static inline PetscErrorCode PetscTimeAdd(PetscLogDouble *v)
117: {
118:   *v += MPI_Wtime();
119:   return 0;
120: }

122: #endif