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 PetscTime(PetscLogDouble *v) 21 22 Not Collective 23 24 Output Parameter: 25 . v - time counter 26 27 28 Usage: 29 PetscLogDouble v; 30 PetscTime(&v); 31 .... perform some calculation ... 32 printf("Time for operation %g\n",v); 33 34 Level: developer 35 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. 41 42 .seealso: PetscTimeSubtract(), PetscTimeAdd(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() 43 44 .keywords: Petsc, time 45 M*/ 46 47 /*MC 48 PetscTimeSubtract - Subtracts the current time of day (in seconds) from 49 the value v. 50 51 Synopsis: 52 #include <petsctime.h> 53 PetscTimeSubtract(&PetscLogDouble *v) 54 55 Not Collective 56 57 Input Parameter: 58 . v - time counter 59 60 Output Parameter: 61 . v - time counter (v = v - current time) 62 63 Level: developer 64 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. 72 73 .seealso: PetscTime(), PetscTimeAdd(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() 74 75 .keywords: Petsc, time, subtract 76 M*/ 77 78 /*MC 79 PetscTimeAdd - Adds the current time of day (in seconds) to the value v. 80 81 Synopsis: 82 #include <petsctime.h> 83 PetscTimeAdd(PetscLogDouble *v) 84 85 Not Collective 86 87 Input Parameter: 88 . v - time counter 89 90 Output Parameter: 91 . v - time counter (v = v + current time) 92 93 Level: developer 94 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_view activate 99 PETSc library timing. See Users-Manual: ch_profiling for more details. 100 101 .seealso: PetscTime(), PetscTimeSubtract(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() 102 103 .keywords: Petsc, time, add 104 M*/ 105 106 PETSC_STATIC_INLINE PetscErrorCode PetscTime(PetscLogDouble *v) 107 { 108 *v = MPI_Wtime(); 109 return 0; 110 } 111 112 PETSC_STATIC_INLINE PetscErrorCode PetscTimeSubtract(PetscLogDouble *v) 113 { 114 *v -= MPI_Wtime(); 115 return 0; 116 } 117 118 PETSC_STATIC_INLINE PetscErrorCode PetscTimeAdd(PetscLogDouble *v) 119 { 120 *v += MPI_Wtime(); 121 return 0; 122 } 123 124 #endif 125 126 127 128