Example #1
0
/**
 * @brief
 *      initialize the platform-dependent topology information
 *
 * @return      Void
 *
 */
void
dep_initialize(void)
{

	psec_clk = (float)syssx(RDCLK);

	num_pcpus = syssx(RDAPNUM);
	num_acpus = num_pcpus;
}
Example #2
0
/* platform specific initialization */
void vt_pform_init() {
  unsigned long long val;
  int hostid_retries;
  syssx(HGTIME, &val);
  vt_time_base = val - (val % 10000000000);

  /* 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);
}
Example #3
0
/* local or global wall-clock time */
uint64_t vt_pform_wtime() {
  unsigned long long val;
  syssx(HGTIME, &val);
  return (uint64_t)val - vt_time_base;
}
Example #4
0
/****** uti/os/sge_nprocs() ***************************************************
*  NAME
*     sge_nprocs() -- Number of processors in this machine
*
*  SYNOPSIS
*     int sge_nprocs()
*
*  FUNCTION
*     Use this function to get the number of processors in
*     this machine
*
*  RESULT
*     int - number of procs
*
*  NOTES
*     MT-NOTE: sge_nprocs() is MT safe (SOLARIS, NEC, IRIX, ALPHA, HPUX, LINUX)
******************************************************************************/
int sge_nprocs()
{
    int nprocs=1; /* default */
#if defined(NECSX4) || defined(NECSX5)
    int fd;
    int fsg_id;
    rsg_info_t info;
    char fsg_dev_string[256];
#endif

    /* NEC SX 4/16, NEC SX 4/32 */
#if defined(NECSX4) || defined(NECSX5)
    /*
     * Using RSG values alone is unreliable.
     */
#if 0
    nprocs = 0;
    for (fsg_id=0; fsg_id<32; fsg_id++) {
        sprintf(fsg_dev_string, "/dev/rsg/%d", fsg_id);
        fd = open(fsg_dev_string, O_RDONLY);
        if (fd > 0) {
            if (ioctl(fd, RSG_INFO, &info) == -1) {
                close(fd);
                continue;
            }
            close(fd);

            nprocs += info.cprb.init_cpu;
        }
    }
    if (nprocs == 0) {
        nprocs=1;
    }
#elif 1
#if defined(CNFGAPNUM)
    /*
     * SUPER-UX >= 11.x provides a function.
     */
    nprocs = syssx(CNFGAPNUM);
#else
    {
        /*
         * As with sge_loadmem(), get RB info and tally
         * it up.
         */
        char       fsg_dev_string[256];
        int        fd, fsg_id;
        rsg_id_t   id;
        rsg_info_t info;
        cpurb_t    cpurbs[MAXRBNUM];
        int        i;

        /* initialize */
        for (i = 0; i < MAXRBNUM; i++) {
            memset(&cpurbs[i], 0, sizeof(cpurb_t));
        }

        /* read in RB info (don't be fooled by RSG names) */
        for (fsg_id = 0; fsg_id < MAXRSGNUM; fsg_id++) {
            sprintf(fsg_dev_string, "/dev/rsg/%d", fsg_id);
            fd = open(fsg_dev_string, O_RDONLY);
            if (fd >= 0) {
                if ((ioctl(fd, RSG_ID, &id) == -1) ||
                        (ioctl(fd, RSG_INFO, &info) == -1)) {
                    close(fd);
                    continue;
                }
                close(fd);

                /* copy for later use */
                memcpy(&cpurbs[id.cprbid], &info.cprb, sizeof(cpurb_t));
            }
        }

        nprocs = 0;
        for (i = 0; i < MAXRBNUM; i++) {
            nprocs += cpurbs[i].init_cpu;
        }
    }
#endif /* CNFGAPNUM */
#endif

#endif

#if defined(DARWIN)
    struct host_basic_info cpu_load_data;

    mach_msg_type_number_t host_count = sizeof(cpu_load_data)/sizeof(integer_t);
    mach_port_t host_priv_port = mach_host_self();

    host_info(host_priv_port, HOST_BASIC_INFO , (host_info_t)&cpu_load_data, &host_count);

    nprocs =  cpu_load_data.avail_cpus;

#endif


#ifdef __sgi
    nprocs = sysmp(MP_NPROCS);
#endif

#if defined(ALPHA)
    int start=0;

    getsysinfo(GSI_CPUS_IN_BOX,(char*)&nprocs,sizeof(nprocs),&start);
#endif

#if defined(SOLARIS) || defined(AIX) || defined(LINUX)
    nprocs = sysconf(_SC_NPROCESSORS_ONLN);
#endif

#if defined(__hpux)
    union pstun pstatbuf;
    struct pst_dynamic dinfo;

    pstatbuf.pst_dynamic = &dinfo;
    if (pstat(PSTAT_DYNAMIC,pstatbuf,sizeof(dinfo),NULL,NULL)==-1) {
        perror(MSG_PERROR_PSTATDYNAMIC);
        exit(1);
    }
    nprocs = dinfo.psd_proc_cnt;
#endif

#ifdef CRAY
    nprocs = sysconf(_SC_CRAY_NCPU);
#endif

#if defined(FREEBSD)
    size_t nprocs_len = sizeof(nprocs);

    if (sysctlbyname("hw.ncpu", &nprocs, &nprocs_len, NULL, 0) == -1) {
        nprocs = -1;
    }
#endif

#if defined(NETBSD)
    int mib[2];
    size_t nprocs_len;

    nprocs_len = sizeof(nprocs);
    mib[0]     = CTL_HW;
    mib[1]     = HW_NCPU;

    if (sysctl(mib, sizeof(mib)/sizeof(int), &nprocs, &nprocs_len, NULL, 0) == -1) {
        nprocs = -1;
    }
#endif

#if defined(INTERIX)
    /* TODO: HP: don't set nprocs==-1 to 0, overwrite it with value from
     *       external load sensor.
     */
    nprocs = -1;
#endif

    if (nprocs <= 0) {
        nprocs = 1;
    }

    return nprocs;
}