xref: /phasta/phSolver/common/tmrc.c (revision 8746ab438bbda91291f8cdd62b94f8385f2d26f1)
1 #include "tmrc.h"
2 #include <stdio.h>
3 #include <sys/types.h>
4 #include <time.h>
5 
6 #include <sys/time.h>
7 #include <sys/resource.h>
8 #include <unistd.h>
9 
10 #ifdef __bgq__
11 #include "hwi/include/bqc/A2_inlines.h"
12 #endif
13 
TMRC(void)14 double TMRC (void)
15 {
16 
17 #ifdef __bgq__
18 
19    /* use the GetTimeBase function available on BGQ */
20    uint64_t TB  = GetTimeBase();
21    double t1 = 6.25e-10*TB; /* = 1/1.6e9 */
22 
23 #else
24 
25   /* use the gettimeofday function available on any Linux platform */
26 
27   int rc;
28   struct timeval tv;
29   double t1 = 0;
30 
31   rc = gettimeofday (&tv, NULL);
32   if (rc == -1) {
33     fprintf(stderr,"tmrc: gettimeofday\n");
34     return 0.;
35   }
36   t1 =  ((double) tv.tv_sec) + 1.e-6 * ((double) tv.tv_usec);
37 
38 #endif
39 
40   return t1;
41 }
42