1 /* 2 Low cost access to system time. This, in general, should not 3 be included in user programs. 4 */ 5 6 #if !defined(PETSCTIME_H) 7 #define PETSCTIME_H 8 #include <petscsys.h> 9 10 PETSC_EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*); 11 12 /* Global counters */ 13 PETSC_EXTERN PetscLogDouble petsc_BaseTime; 14 15 /*MC 16 PetscTime - Returns the current time of day in seconds. 17 18 Synopsis: 19 #include <petsctime.h> 20 PetscErrorCode PetscTime(PetscLogDouble *v) 21 22 Not Collective 23 24 Output Parameter: 25 . v - time counter 26 27 Usage: 28 PetscLogDouble v; 29 PetscTime(&v); 30 .... perform some calculation ... 31 printf("Time for operation %g\n",v); 32 33 Level: developer 34 35 Notes: 36 Since the PETSc libraries incorporate timing of phases and operations, 37 we do not recommend ever using PetscTime() 38 The options database command -log_view activate 39 PETSc library timing. See Users-Manual: ch_profiling for more details. 40 41 .seealso: PetscTimeSubtract(), PetscTimeAdd(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() 42 43 M*/ 44 45 /*MC 46 PetscTimeSubtract - Subtracts the current time of day (in seconds) from 47 the value v. 48 49 Synopsis: 50 #include <petsctime.h> 51 PetscErrorCode PetscTimeSubtract(PetscLogDouble *v) 52 53 Not Collective 54 55 Input Parameter: 56 . v - time counter 57 58 Output Parameter: 59 . v - time counter (v = v - current time) 60 61 Level: developer 62 63 Notes: 64 Since the PETSc libraries incorporate timing of phases and operations, 65 we do not every recommend using PetscTimeSubtract() 66 The options database command -log_view activates 67 PETSc library timing. See Users-Manual: ch_profiling for more details, also 68 see PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() for how to register 69 stages and events in application codes. 70 71 .seealso: PetscTime(), PetscTimeAdd(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() 72 73 M*/ 74 75 /*MC 76 PetscTimeAdd - Adds the current time of day (in seconds) to the value v. 77 78 Synopsis: 79 #include <petsctime.h> 80 PetscErrorCode PetscTimeAdd(PetscLogDouble *v) 81 82 Not Collective 83 84 Input Parameter: 85 . v - time counter 86 87 Output Parameter: 88 . v - time counter (v = v + current time) 89 90 Level: developer 91 92 Notes: 93 Since the PETSc libraries incorporate timing of phases and operations, 94 we do not ever recommend using PetscTimeAdd(). 95 The options database command -log_view activate 96 PETSc library timing. See Users-Manual: ch_profiling for more details. 97 98 .seealso: PetscTime(), PetscTimeSubtract(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() 99 100 M*/ 101 102 PETSC_STATIC_INLINE PetscErrorCode PetscTime(PetscLogDouble *v) 103 { 104 *v = MPI_Wtime(); 105 return 0; 106 } 107 108 PETSC_STATIC_INLINE PetscErrorCode PetscTimeSubtract(PetscLogDouble *v) 109 { 110 *v -= MPI_Wtime(); 111 return 0; 112 } 113 114 PETSC_STATIC_INLINE PetscErrorCode PetscTimeAdd(PetscLogDouble *v) 115 { 116 *v += MPI_Wtime(); 117 return 0; 118 } 119 120 #endif 121