示例#1
0
static int
opal_timer_aix_open(void)
{
#ifdef HAVE_PM_CYCLES
  opal_timer_aix_freq = pm_cycles();
  opal_timer_aix_freq_mhz = opal_timer_aix_freq / 1000000;
#else
  opal_timer_aix_freq_mhz = 0;
  opal_timer_aix_freq = 0;
#endif

  return OPAL_SUCCESS;
}
示例#2
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
}