static void init(void)
{
  FILE *f;
  int s;
  long long tb0; long long us0;
  long long tb1; long long us1;

  f = fopen("/proc/cpuinfo","r");
  if (!f) return 0;

  for (;;) {
    s = fscanf(f," clock : %lf MHz",&cpufrequency);
    if (s > 0) break;
    if (s == 0) s = fscanf(f,"%*[^\n]\n");
    if (s < 0) { cpufrequency = 0; break; }
  }

  fclose(f);
  if (!cpufrequency) return;
  cpufrequency *= 1000000.0;

  tb0 = timebase();
  us0 = microseconds();
  do {
    tb1 = timebase();
    us1 = microseconds();
  } while (us1 - us0 < 10000);
  if (tb1 <= tb0) return;

  tb1 -= tb0;
  us1 -= us0;
  tbcycles = myround((cpufrequency * 0.000001 * (double) us1) / (double) tb1);
}
예제 #2
0
static double guesstbcycles(void)
{
  long long tb0; long long us0;
  long long tb1; long long us1;

  tb0 = timebase();
  us0 = microseconds();
  do {
    tb1 = timebase();
    us1 = microseconds();
  } while (us1 - us0 < 10000 || tb1 - tb0 < 1000);
  if (tb1 <= tb0) return 0;
  tb1 -= tb0;
  us1 -= us0;
  return (cpufrequency * 0.000001 * (double) us1) / (double) tb1;
}
예제 #3
0
static void init(void)
{
  FILE *f;
  long long tb0; long long us0;
  long long tb1; long long us1;

  f = popen("/usr/sbin/lsattr -E -l proc0 -a frequency","r");
  if (!f) return;
  if (fscanf(f,"frequency %lf",&cpufrequency) < 1) cpufrequency = 0;
  pclose(f);
  if (!cpufrequency) return;

  tb0 = timebase();
  us0 = microseconds();
  do {
    tb1 = timebase();
    us1 = microseconds();
  } while (us1 - us0 < 10000);
  if (tb1 <= tb0) return;

  tb1 -= tb0;
  us1 -= us0;
  tbcycles = myround((cpufrequency * 0.000001 * (double) us1) / (double) tb1);
}
예제 #4
0
int main( int argc, char *argv[] )
{
  static float xx[N], yy[N], zz[N], mass[N], vx1[N], vy1[N], vz1[N];
  float fsrrmax2, mp_rsm2, fcoeff, dx1, dy1, dz1;

  char  M1[NC], M2[NC];
  int n, count, i, rank, nprocs;
  unsigned long long tm1, tm2, tm3, tm4, total = 0;
  double t3, elapsed = 0.0, validation, final;

  //MPI_Init( &argc, &argv );
  //MPI_Comm_rank( MPI_COMM_WORLD, &rank );
  //MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
  
  rank = 0;
  nprocs = 1;

  count = 327;

  if ( rank == 0 ) 
  {  
     printf( "count is set %d\n", count );
     printf( "Total MPI ranks %d\n", nprocs );
  } 

#pragma omp parallel
{
  if ( (rank == 0) && (omp_get_thread_num() == 0) )
  {
     printf( "Number of OMP threads %d\n\n", omp_get_num_threads() );
     //printf( "      N         Time,us        Validation result\n" );
  }   
}

#ifdef TIMEBASE
  tm3 = timebase();
#endif

  final = 0.;
예제 #5
0
long long cpucycles_powerpcaix(void)
{
  if (!tbcycles) init();
  return timebase() * tbcycles;
}
예제 #6
0
double timebase_sec(void)
{
	return timebase() / (double)timebase_frequency;
}
예제 #7
0
timing_t get_time_ns() {
    return llround(BGP_NS_PER_CYCLE * timebase());
}
예제 #8
0
long long cpucycles_apple(void)
{
  if (!cpufrequency) init();
  return (timebase() * tbcycles) >> 6;
}