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