Actual source code: petsctime.h
petsc-3.7.3 2016-08-01
1: /*
2: Low cost access to system time. This, in general, should not
3: be included in user programs.
4: */
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: 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_summary activate
40: PETSc library timing. See Users-Manual: Chapter 13 Profiling for more details.
42: .seealso: PetscTimeSubtract(), PetscTimeAdd(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd()
44: .keywords: Petsc, time
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: 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_summary activates
69: PETSc library timing. See Users-Manual: Chapter 13 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: .keywords: Petsc, time, subtract
76: M*/
78: /*MC
79: PetscTimeAdd - Adds the current time of day (in seconds) to the value v.
81: Synopsis:
82: #include <petsctime.h>
83: PetscTimeAdd(PetscLogDouble *v)
85: Not Collective
87: Input Parameter:
88: . v - time counter
90: Output Parameter:
91: . v - time counter (v = v + current time)
93: Level: developer
95: Notes:
96: Since the PETSc libraries incorporate timing of phases and operations,
97: we do not ever recommend using PetscTimeAdd().
98: The options database command -log_summary activate
99: PETSc library timing. See Users-Manual: Chapter 13 Profiling for more details.
101: .seealso: PetscTime(), PetscTimeSubtract(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd()
103: .keywords: Petsc, time, add
104: M*/
106: PETSC_STATIC_INLINE PetscErrorCode PetscTime(PetscLogDouble *v)
107: {
108: *v = MPI_Wtime();
109: return 0;
110: }
112: PETSC_STATIC_INLINE PetscErrorCode PetscTimeSubtract(PetscLogDouble *v)
113: {
114: *v -= MPI_Wtime();
115: return 0;
116: }
118: PETSC_STATIC_INLINE PetscErrorCode PetscTimeAdd(PetscLogDouble *v)
119: {
120: *v += MPI_Wtime();
121: return 0;
122: }
124: #endif