Esempio n. 1
0
/* bgl/bgp timers */
void metric_read_bgtimers(int tid, int idx, double values[]) {
#ifdef TAU_BGL
  static double bgl_clockspeed = 0.0;

  if (bgl_clockspeed == 0.0) {
    BGLPersonality mybgl;
    rts_get_personality(&mybgl, sizeof(BGLPersonality));
    bgl_clockspeed = 1.0e6 / (double)BGLPersonality_clockHz(&mybgl);
  }
  values[idx] = (rts_get_timebase() * bgl_clockspeed);
#endif /* TAU_BGL */

#ifdef TAU_BGP
#ifdef BGP_TIMERS
  static double bgp_clockspeed = 0.0;

  if (bgp_clockspeed == 0.0) {
    _BGP_Personality_t mybgp;
    Kernel_GetPersonality(&mybgp, sizeof(_BGP_Personality_t));
    bgp_clockspeed = 1.0 / (double)BGP_Personality_clockMHz(&mybgp);
  }
  values[idx] =  (_bgp_GetTimeBase() * bgp_clockspeed);
#else /* TAU_BGPTIMERS */
  printf("TAU: Error: You must specify -BGPTIMERS at configure time\n");
  values[idx] = 0;
#endif /* TAU_BGPTIMERS */
#endif /* TAU_BGP */
}
Esempio n. 2
0
/* platform specific initialization */
void vt_pform_init() {
  Kernel_GetPersonality(&mybgp, sizeof(_BGP_Personality_t));
#if TIMER == TIMER_BGP_GET_TIMEBASE
  vt_ticks_per_sec = (uint64_t)BGP_Personality_clockMHz(&mybgp) * 1000000LL;
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif
}
Esempio n. 3
0
void
set_freq(  )
{
#if defined(_AIX)
	/* pm_cycles() returns cycles per sec --> frequency is cycles per micro-sec */
	frequency = ( long long ) pm_cycles(  ) / 1000000;
#elif defined(__bgp__)
	_BGP_Personality_t bgp;
	frequency = ( long long ) BGP_Personality_clockMHz( &bgp );
#elif defined(_WIN32)
#elif defined(__APPLE__)
	int mib[2];
	size_t len = sizeof ( frequency );
	unsigned long long freq;

	mib[0] = CTL_HW;
	mib[1] = HW_CPU_FREQ;
	if ( 0 > sysctl( mib, 2, &freq, &len, NULL, 0 ) )
		frequency = -1;
	else
		frequency = freq;
#else
	char maxargs[PAPI_HUGE_STR_LEN], *s;
	float mhz = 0.0;
	FILE *f;

	if ( ( f = fopen( "/proc/cpuinfo", "r" ) ) != NULL ) {
		rewind( f );
		s = search_cpu_info( f, "clock", maxargs );

		if ( !s ) {
			rewind( f );
			s = search_cpu_info( f, "cpu MHz", maxargs );
		}

		if ( s )
			sscanf( s + 1, "%f", &mhz );

		frequency = ( long long ) mhz;
		fclose( f );
	}
#endif
 
#ifndef _WIN32
	if ( frequency == -1 )
		frequency = ( long long ) compute_freq(  );
#endif
}