Actual source code: petsctime.h

petsc-3.14.6 2021-03-30
Report Typos and Errors
  1: /*
  2:        Low cost access to system time. This, in general, should not
  3:      be included in user programs.
  4: */

  6: #if !defined(PETSCTIME_H)
  7: #define PETSCTIME_H
  8: #include <petscsys.h>

 10: PETSC_EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*);

 12: /* Global counters */
 13: PETSC_EXTERN PetscLogDouble petsc_BaseTime;

 15: /*MC
 16:    PetscTime - Returns the current time of day in seconds.

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

 22:    Not Collective

 24:    Output Parameter:
 25: .  v - time counter


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

 34:    Level: developer

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

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

 44: M*/

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

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

 54:    Not Collective

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

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

 62:    Level: developer

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

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

 74: M*/

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

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

 83:    Not Collective

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

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

 91:    Level: developer

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

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

101: M*/

103: PETSC_STATIC_INLINE PetscErrorCode PetscTime(PetscLogDouble *v)
104: {
105:   *v = MPI_Wtime();
106:   return 0;
107: }

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

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

121: #endif