Exemplo n.º 1
0
/* platform specific initialization */
void vt_pform_init() {
  int  pid = getpid();
  char exec_proc[512];
  int  hostid_retries;

#if TIMER == TIMER_SWITCH_CLOCK
  int i;
  for (i=0; i<NUMRETRY; i++) {
    if ( (vt_swclk = swclockInit()) != 0 ) break;
  }
#elif TIMER == TIMER_POWER_REALTIME
  timebasestruct_t t;
  read_real_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  vt_time_base = t.tb_high - (t.tb_high & 0xFFFF);
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  /* get full path of executable */
  snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/object/a.out", pid);
  vt_exec = strdup(exec_proc);

  /* get unique numeric SMP-node identifier */
  hostid_retries = 0;
  while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) {
    vt_node_id = gethostid();
  }
  if (!vt_node_id)
    vt_error_msg("Maximum retries (%i) for gethostid exceeded!",
		 VT_MAX_GETHOSTID_RETRIES);
}
/* 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
}
Exemplo n.º 3
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;
      }
    }
  }
}
Exemplo n.º 4
0
/* platform specific initialization */
void vt_pform_init() {
  rts_get_personality(&mybgl, sizeof(BGLPersonality));
#if TIMER == TIMER_RTS_GET_TIMEBASE
  vt_ticks_per_sec = (uint64_t)BGLPersonality_clockHz(&mybgl);
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif
}
Exemplo n.º 5
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
}
Exemplo n.º 6
0
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_RTS_GET_TIMEBASE
  return (uint64_t)rts_get_timebase();
#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
}
Exemplo n.º 7
0
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_GETHRTIME
  return (uint64_t)gethrtime();
#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
}
Exemplo n.º 8
0
/* local or global wall-clock time in seconds */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_BGP_GET_TIMEBASE
  return (uint64_t)_bgp_GetTimeBase();
#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
}
Exemplo n.º 9
0
/* platform specific initialization */
void vt_pform_init() {
  int  pid = getpid();
  char exec_proc[VT_PATH_MAX];
  char exec[VT_PATH_MAX];
  int  exec_len;
  int  hostid_retries;

#if TIMER == TIMER_MMTIMER
  int fd;
  unsigned long femtosecs_per_tick = 0;
  int offset;

  if((fd = open(MMTIMER_FULLNAME, O_RDONLY)) == -1) {
    vt_error_msg("Failed to open " MMTIMER_FULLNAME);
  }

  if ((offset = ioctl(fd, MMTIMER_GETOFFSET, 0)) == -ENOSYS) {
    vt_error_msg("Cannot get mmtimer offset");
  }

  if ((mmdev_timer_addr = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, fd, 0))
       == MAP_FAILED) {
    vt_error_msg("Cannot mmap mmtimer");
  }
  mmdev_timer_addr += offset;

  ioctl(fd, MMTIMER_GETRES, &femtosecs_per_tick);
  mmdev_ticks_per_sec = (uint64_t)(1.0 / (1e-15 * femtosecs_per_tick));

  close(fd);
#elif TIMER == TIMER_CLOCK_GETTIME
  struct timespec tp;
  clock_gettime(CLOCK_REALTIME, &tp);
  vt_time_base = tp.tv_sec - (tp.tv_sec & 0xFF);
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  /* get full path of executable */
  snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/exe", pid);
  exec_len = readlink(exec_proc, exec, sizeof (exec)-1);
  if(exec_len != -1)
  {
    exec[exec_len] = '\0';
    vt_exec = strdup(exec);
  }

  /* get unique numeric SMP-node identifier */
  hostid_retries = 0;
  while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) {
    vt_node_id = gethostid();
  }
  if (!vt_node_id)
    vt_error_msg("Maximum retries (%i) for gethostid exceeded!",
		 VT_MAX_GETHOSTID_RETRIES);
}
Exemplo n.º 10
0
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if 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
}
Exemplo n.º 11
0
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_MMTIMER
  return *mmdev_timer_addr;
#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_PAPI_REAL_CYC
  return vt_metric_real_cyc();
#elif TIMER == TIMER_PAPI_REAL_USEC
  return vt_metric_real_usec() - vt_time_base;
#endif
}
/* platform specific initialization */
void vt_pform_init() {
  Kernel_GetPersonality(&mybgq, sizeof(Personality_t));
#if TIMER == TIMER_GET_TIMEBASE
  vt_ticks_per_sec = (uint64_t)mybgq.Kernel_Config.FreqMHz * 1000000LL;
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  torus_coord[0] = mybgq.Network_Config.Acoord;
  torus_coord[1] = mybgq.Network_Config.Bcoord;
  torus_coord[2] = mybgq.Network_Config.Ccoord;
  torus_coord[3] = mybgq.Network_Config.Dcoord;
  torus_coord[4] = mybgq.Network_Config.Ecoord;
  torus_coord[5] = Kernel_ProcessorID();
}
Exemplo n.º 13
0
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
#if TIMER == TIMER_SWITCH_CLOCK
  int i;
  int64_t t;
  for (i=0; i<NUMRETRY; i++) {
    if ( (t = swclockRead(vt_swclk)) != -1 ) return t;
  }
  return 0;
#elif TIMER == TIMER_POWER_REALTIME
  timebasestruct_t t;
  read_real_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  return ((t.tb_high - vt_time_base) * 1e9) + t.tb_low;
#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
}
Exemplo n.º 14
0
/* platform specific initialization */
void vt_pform_init() {
  int hostid_retries;

#if TIMER == TIMER_GETTIMEOFDAY
  struct timeval tp;
  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

  /* get unique numeric SMP-node identifier */
  hostid_retries = 0;
  while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) {
    vt_node_id = gethostid();
  }
  if (!vt_node_id)
    vt_error_msg("Maximum retries (%i) for gethostid exceeded!",
		 VT_MAX_GETHOSTID_RETRIES);
}
Exemplo n.º 15
0
/* platform specific initialization */
void vt_pform_init() {
  int  pid = getpid();
  char exec_proc[VT_PATH_MAX];
  char exec[VT_PATH_MAX];
  int  exec_len;
  int  hostid_retries;

#if TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  /* get full path of executable */
  snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/path/a.out", pid);
  exec_len = readlink(exec_proc, exec, sizeof (exec)-1);
  if(exec_len != -1)
  {
    exec[exec_len] = '\0';
    vt_exec = strdup(exec);
  }

  /* get unique numeric SMP-node identifier */
  hostid_retries = 0;
  while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) {
    vt_node_id = gethostid();
  }
  if (!vt_node_id)
  {
    vt_error_msg("Maximum retries (%i) for gethostid exceeded!",
		 VT_MAX_GETHOSTID_RETRIES);
  }
  else
  {
    char* nodename = vt_pform_node_name();
    vt_node_id = (long)vt_hash((uint8_t*)nodename, strlen(nodename),
			       (uint32_t)vt_node_id);
  }
}
/* platform specific initialization */
void vt_pform_init() {
  int  pid = getpid();
  char exec_proc[VT_PATH_MAX];
  char exec[VT_PATH_MAX];
  int  exec_len;

#if TIMER == TIMER_CYCLE_COUNTER
  FILE *cpuinfofp;
  char line[1024];
  if ((cpuinfofp = fopen(VT_PROCDIR "cpuinfo", "r")) == NULL)
    vt_error_msg("Cannot open file %s: %s", VT_PROCDIR"cpuinfo",
		 strerror(errno));
  while (fgets(line, sizeof (line), cpuinfofp))
  {
    if (!strncmp("cpu MHz", line, 7))
    {
      strtok(line, ":");

      vt_ticks_per_sec =
	strtol((char*) strtok(NULL, " \n"), (char**) NULL, 0) * 1000000LL;
    }
    else if (!strncmp("timebase", line, 8))
    {
      strtok(line, ":");

      vt_ticks_per_sec =
	strtol((char*) strtok(NULL, " \n"), (char**) NULL, 0);
    }
  }
  fclose(cpuinfofp);
#elif TIMER == TIMER_CLOCK_GETTIME
  struct timespec tp;
  clock_gettime(CLOCK_REALTIME, &tp);
  vt_time_base = tp.tv_sec - (tp.tv_sec & 0xFF);
#elif TIMER == TIMER_GETTIMEOFDAY
  struct timeval tp;
  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

  /* get unique numeric/string SMP-node identifier */
  {
    char buf[256];
    ssize_t bytes;
    int fd;

    /* get numeric identifier */
    fd = open(VT_PROCDIR"cray_xt/nid", O_RDONLY);
    if (fd < 0) vt_error_msg("Cannot open file "VT_PROCDIR"cray_xt/nid: %s",
      strerror(errno));
    bytes = read(fd, buf, 256);
    if (bytes <= 0) vt_error_msg("Cannot read file "VT_PROCDIR"cray_xt/nid: %s",
      strerror(errno));
    close(fd);
    vt_node_id = atol(buf);
    
    /* get string identifier */
    fd = open(VT_PROCDIR"cray_xt/cname", O_RDONLY);
    if (fd < 0) vt_error_msg("Cannot open file "VT_PROCDIR"cray_xt/cname: %s",
      strerror(errno));
    bytes = read(fd, buf, 256);
    if (bytes <= 0) vt_error_msg("Cannot read file "VT_PROCDIR"cray_xt/cname: %s",
      strerror(errno));
    close(fd);
    vt_node_name = strdup(buf);
  }

  /* get full path of executable */
  snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/exe", pid);
  exec_len = readlink(exec_proc, exec, sizeof (exec)-1);
  if(exec_len != -1)
  {
    exec[exec_len] = '\0';
    vt_exec = strdup(exec);
  }
}