forked from FLAME-HPC/xparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiming.tmpl
More file actions
33 lines (29 loc) · 768 Bytes
/
Copy pathtiming.tmpl
File metadata and controls
33 lines (29 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* \file timing.c
* \brief Timing routines
*/
#include "header.h"
<?if parallel?>#include <mpi.h><?end if?>
<?if serial?>#include <sys/time.h><?end if?>
/** \fn double get_time(void)
* \brief Returns an elapsed time on the calling processor
* \return Time in seconds since an arbitrary time in the past.
*/
<?if parallel?>
double get_time(void) {
return MPI_Wtime();
}
<?end if?>
<?if serial?>
double get_time(void) {
struct timeval now;
/* in some implementations, clock() wraps round after 36 minutes.
* use gettimeofday() instead, which gives us time since the Epoch
*/
# ifndef S_SPLINT_S
gettimeofday(&now, NULL);
# endif
/* return time in secs */
return now.tv_sec + (now.tv_usec * 1.e-6);
}
<?end if?>