void etime_sub (gfc_array_r4 *t, GFC_REAL_4 *result) { GFC_REAL_4 tu, ts, tt, *tp; long user_sec, user_usec, system_sec, system_usec; if (((t->dim[0].ubound + 1 - t->dim[0].lbound)) < 2) runtime_error ("Insufficient number of elements in TARRAY."); if (__time_1 (&user_sec, &user_usec, &system_sec, &system_usec) == 0) { tu = (GFC_REAL_4)(user_sec + 1.e-6 * user_usec); ts = (GFC_REAL_4)(system_sec + 1.e-6 * system_usec); tt = tu + ts; } else { tu = (GFC_REAL_4)-1.0; ts = (GFC_REAL_4)-1.0; tt = (GFC_REAL_4)-1.0; } tp = t->data; *tp = tu; tp += t->dim[0].stride; *tp = ts; *result = tt; }
static inline void __cpu_time_1 (long *sec, long *usec) { #if defined(__MINGW32__) || defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H) long user_sec, user_usec, system_sec, system_usec; __time_1 (&user_sec, &user_usec, &system_sec, &system_usec); *sec = user_sec + system_sec; *usec = user_usec + system_usec; #else /* ! HAVE_GETRUSAGE || ! HAVE_SYS_RESOURCE_H */ #ifdef HAVE_TIMES struct tms buf; times (&buf); *sec = 0; *usec = (buf.tms_utime + buf.tms_stime) * (1000000 / HZ); #else /* ! HAVE_TIMES */ /* We have nothing to go on. Return -1. */ *sec = -1; *usec = 0; #endif /* HAVE_TIMES */ #endif /* __MINGW32__ || HAVE_GETRUSAGE */ }
void dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *result) { GFC_REAL_4 *tp; long user_sec, user_usec, system_sec, system_usec; static long us = 0, uu = 0, ss = 0 , su = 0; GFC_REAL_4 tu, ts, tt; if (((t->dim[0].ubound + 1 - t->dim[0].lbound)) < 2) runtime_error ("Insufficient number of elements in TARRAY."); __gthread_mutex_lock (&dtime_update_lock); if (__time_1 (&user_sec, &user_usec, &system_sec, &system_usec) == 0) { tu = (GFC_REAL_4) ((user_sec - us) + 1.e-6 * (user_usec - uu)); ts = (GFC_REAL_4) ((system_sec - ss) + 1.e-6 * (system_usec - su)); tt = tu + ts; us = user_sec; uu = user_usec; ss = system_sec; su = system_usec; } else { tu = -1; ts = -1; tt = -1; } tp = t->data; *tp = tu; tp += t->dim[0].stride; *tp = ts; *result = tt; __gthread_mutex_unlock (&dtime_update_lock); }