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