/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_CYCLE_COUNTER
# ifdef _CRAYC
    return (uint64_t)_rtc();
# else
    uint64_t clock_value;
    uint32_t low = 0;
    uint32_t high = 0;
    asm volatile ("rdtsc" : "=a" (low), "=d" (high));
    clock_value = ((uint64_t)high << 32) | (uint64_t)low;
    return clock_value;
# endif
#elif TIMER == TIMER_CLOCK_GETTIME
  struct timespec tp;
  clock_gettime(CLOCK_REALTIME, &tp);
  return ((tp.tv_sec - vt_time_base) * 1000000000LL) + tp.tv_nsec;
#elif TIMER == TIMER_GETTIMEOFDAY
  struct timeval tp;
  gettimeofday(&tp, 0);
  return ((tp.tv_sec - vt_time_base) * 1000000LL) + tp.tv_usec;
#elif TIMER == TIMER_PAPI_REAL_CYC
  return vt_metric_real_cyc();
#elif TIMER == TIMER_PAPI_REAL_USEC
  return vt_metric_real_usec() - vt_time_base;
#endif
}
Beispiel #2
0
/* platform specific initialization */
void vt_pform_init() {
  struct timeval tp;
  static ApTeam_t app;
  int i;

#if TIMER == TIMER_RTC
  vt_ticks_per_sec = (uint64_t)sysconf(_SC_SV2_USER_TIME_RATE);
# pragma omp parallel
  {
    gettimeofday(&tp, 0);
    vt_rtc_base = _rtc();
  }
#elif TIMER == TIMER_GETTIMEOFDAY
  gettimeofday(&tp, 0);
  vt_time_base = tp.tv_sec - (tp.tv_sec & 0xFFFF);
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  if (apteamctl(ApTeam_Status, 0, 0, &app) == 1) {
    vt_mspmode = (app.flags & APTEAM_MSP);
    app.pes = (ApPe_t*)malloc(app.pecount * sizeof(ApPe_t));
    if (apteamctl(ApTeam_Status, 0, 0, &app) == 1) {
      for (i=0; i<_num_pes(); i++) {
        if (_my_pe() == app.pes[i].lpe) vt_nodeid = (long)app.pes[i].place;
      }
    }
  }
}
Beispiel #3
0
timef_(void)
#endif
{
	static int64	initial_rt = -1; /* Clock value from initial call */
	int64		rt, rtdif;
	double		retval;

#ifdef	_UNICOS
        if (_sec_per_clock == 0.0)
                _sec_per_clock = 1.0 / (double) sysconf(_SC_CLK_TCK);

	rt	= _rtc();
#else
	{
        struct timeval  buf;
	struct timezone	buf2;
	(void) gettimeofday (&buf, &buf2);
        rt = (long long)buf.tv_sec * 1000000LL + buf.tv_usec;
	}
#endif

	if (initial_rt < 0) {
		initial_rt	= rt;
		rtdif		= 0;
		/*
		 * force rtdif to 0 to prevent anomalies due to possible
		 * race conditions between 2 or more tasks calling TIMEF
		 * concurrently on the initial call.
		 */
	}
	else
		rtdif		= rt - initial_rt;

/*
 *	On pre-7.0 UNICOS CX/CEA systems and on all CRAY-2 systems the 
 *	real-time hardware clock is set to 0 on reboot.  If a restarted 
 *	process had called TIMEF before the system was brought down 
 *	and then after reboot, a negative difference in the real-time 
 *	clock value would be observed.  To minimize the impact of
 *	wrong timings being returned, we return 0 when this situation is 
 *	detected.
 */
	if (rtdif < 0) {
		initial_rt	= rt;
		rtdif		= 0;
	}

	retval	= (double) rtdif * MSECPERCLK;

#ifdef	_UNICOS
	if (_numargs() > 0)
		*time	= (_f_real) retval;
#endif

	return( (_f_real) retval);
}
Beispiel #4
0
/* cray timers */
void metric_read_craytimers(int tid, int idx, double values[]) {
#ifdef  CRAY_TIMERS
#ifdef TAU_CATAMOUNT /* for Cray XT3 */
  values[idx] = dclock() * 1.0e6;
#else /* for Cray X1 */
  long long tick = _rtc();
  values[idx] = (double)tick / HZ;
#endif /* TAU_CATAMOUNT */
#endif /* CRAY_TIMERS */
}
Beispiel #5
0
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_RTC
  return (uint64_t)_rtc() - vt_rtc_base;
#elif TIMER == TIMER_GETTIMEOFDAY
  struct timeval tp;
  gettimeofday(&tp, 0);
  return ((tp.tv_sec - vt_time_base) * 1e6) + tp.tv_usec;
#elif TIMER == TIMER_PAPI_REAL_CYC
  return vt_metric_real_cyc();
#elif TIMER == TIMER_PAPI_REAL_USEC
  return vt_metric_real_usec() - vt_time_base;
#endif
}
Beispiel #6
0
/*
 * _glio_delay
 *
 * Delay for nano nanoseconds.   This is useful in polling loops.
 */
void
_glio_delay(int nano)
{

#ifdef	__mips
	struct timespec ts;

	ts.tv_sec	= 0;
	ts.tv_nsec	= nano;
	nanosleep(&ts, NULL);
#else
	float	hertz;
	long	ticks, start;
	hertz	= IRTC_RATE();

	ticks	= hertz * (float)nano / 1000000000.0;

	start	= _rtc();
	/* if the clock goes backwards, stop spinning */
	while (_rtc() < (start+ticks) && _rtc() >= start) 
		continue;
#endif
	return;
}
Beispiel #7
0
_f_real
SECONDR(_f_real *time)
{
	double	timeval;

	if (_sec_per_clock == 0.0)
		_sec_per_clock = (double)1.0 / (double)__hertz;

	timeval = (double) _rtc() * _sec_per_clock;

	if (_numargs() > 0)
		*time	= (_f_real) timeval;

	return( (_f_real) timeval);
}
Beispiel #8
0
void
_mtcpu()
{
	struct stkstat	stats;		/* Stack statistics struct */
	double	waltime, clks, percent;

	/* Print total clocks run, wallclock time, and % of machine used */

	waltime	= (double) (_rtc() - _rtstart) / (double) CLK_TCK;
	clks	= _second();
	percent	= (waltime > 0.0) ?
			(100.0 * clks / (waltime * (double) ZQMAXCPU)) : 0.0;

	if (waltime >= 0.0) {
		if (percent > 0.05 && percent < 99.9999)
			(void) fprintf(stderr,
			" CPU: %.3fs,  Wallclock: %.3fs,  %.1f%% of %d-CPU Machine\n",
				clks, waltime, percent, ZQMAXCPU);
		else
			(void) fprintf(stderr,
				" CPU: %.3fs,  Wallclock: %.3fs\n", clks,
				waltime);

	}
	else
		/*
		 *  If system reboot after checkpoint, value of wallclock time
	  	 *  may be negative.  Kernel mod only fixes CX/CEA systems.
		 *  Problem can still occur for Cray-2 systems.  Do not give
		 *  bad wallclock value.
		 */
		(void) fprintf(stderr, " CPU: %.3fs\n", clks);

	/* Print memory/stack hi-water marks and number of overflows */

	STKSTAT(&stats);

	(void) fprintf(stderr,
		" Memory HWM: %d, Stack HWM: %d, Stack segment expansions: %d\n",
		$memhwm, MSWM, SOVFL);

	return;
}