Exemplo n.º 1
0
int ProbeThrottle()
/*
 * RETURNS: 1 if cpu throttling is detected, 0 otherwise
 */
{
   int iret=0;
   int imax=0, imin=0, icur=0;
   char res[1024];

/*
 * If cpufreq directory doesn't exist, guess no throttling.  If
 * cpufreq exists, and cur Mhz < max, throttling is enabled,
 * throttling also enabled if governer is not "performance", and min freq
 * is less than max
 */
   if (!CmndOneLine(NULL,
       "cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", res) )
   {
      imax = GetFirstInt(res);
      assert(!CmndOneLine(NULL,
             "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", res));
      imin = GetFirstInt(res);
      assert(!CmndOneLine(NULL,
             "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", res));
      icur = GetFirstInt(res);
      assert(!CmndOneLine(NULL,
             "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", res));
      if (icur < imax)
         iret = 1;
      else if (!strstr(res, "performance") && imin < imax)
         iret = 1;
   }
   return(iret);
}
Exemplo n.º 2
0
int ProbeNCPU()
{
   int ncpu = 0;
   char *reslns, res[1024];

   if (!CmndOneLine(NULL, "uname -X | fgrep NumCPU", res))
      ncpu = GetFirstInt(res);
   else if (!CmndOneLine(NULL, "/bin/uname -X | fgrep NumCPU", res))
      ncpu = GetFirstInt(res);
   return(ncpu);
}
Exemplo n.º 3
0
int ProbeNCPU()
{
   int ncpu = 0;
   char *reslns, res[1024];

   if (!CmndOneLine(NULL,
          "hinv -c processor | fgrep Processor | fgrep -v 'CPU:'", res))
      ncpu = GetFirstInt(res);
   return(ncpu);
}
Exemplo n.º 4
0
int ProbeMhz()
{
   int mhz=0;
   char res[1024];
   if (!CmndOneLine(NULL, "fgrep 'cpu MHz' /proc/cpuinfo", res))
      mhz = GetFirstInt(res);
   if (!mhz &&
       !CmndOneLine(NULL, "cat /proc/cpuinfo | fgrep clock | fgrep MHz", res))
      mhz = GetLastInt(res);
   return(mhz);
}
Exemplo n.º 5
0
int ConfirmPtrbits(enum OSTYPE OS0, enum ASMDIA asmd0, char *targ0,
                   char *flag, char *find, int *sure)
/*
 * Retries pointer width probe using -m64; OK to fail: use prior val in that
 * case
 */
{
   char osname[128];
   char *cmnd, *res, *targ;
   char *frm="make IRunArchInfo_%s MYFLAGS=\"-m64 -DATL_OS_%s -DATL_%s\" args=\"%s\" %s | fgrep '%s'";
   enum OSTYPE OS;
   enum ASMDIA asmd;
   int i, iret=0;

   *sure = 0;
   asmd = (asmd0 > ASM_None && asmd0 < NASMD) ? asmd0 : gas_x86_32;
   OS = (OS0 > OSOther && OS0 < NOS) ? OS0 : OSLinux;
   i = (OS == OSOSX) ? OSFreeBSD : OS;
   assert(strlen(osnam[i]) < 128);
   strlowcpy(osname, osnam[i]);
   if (targ0)
   {
      i = strlen(targ0) + 24;
      targ = malloc(sizeof(char)*i);
      assert(targ);
      sprintf(targ, "atlrun=atlas_runX targ=%s", targ0);
   }
   else
   {
      targ = malloc(sizeof(char));
      assert(targ);
      targ[0] = '\0';
   }

/*
 * Try OS-specific probe, compiling with -m64 (assumes gcc workalike)
 */
   i = 1 + strlen(frm) + strlen(osnam) + strlen(osnam[OS]) +
       strlen(ASMNAM[asmd]) + strlen(flag) + strlen(targ) + strlen(find);
   cmnd = malloc(i*sizeof(char));
   assert(cmnd);
   sprintf(cmnd, frm, osname, osnam[OS], ASMNAM[asmd], flag, targ, find);
   free(targ);
   res = atlsys_1L(NULL, cmnd, 0, 0);
   free(cmnd);
   if (res)
   {
      iret = GetFirstInt(res);
      *sure = GetLastInt(res);
      free(res);
   }
   return(iret);
}
Exemplo n.º 6
0
int ProbeNCPU()
{
   int ncpu = 0;
   char *res;

   res = atlsys_1L(NULL,
                   "hinv -c processor | fgrep Processor | fgrep -v 'CPU:'",
                   0, 0);
   if (res)
   {
      ncpu = GetFirstInt(res);
      free(res);
   }
   return(ncpu);
}
Exemplo n.º 7
0
int ProbeOneInt(enum OSTYPE OS0, enum ASMDIA asmd0, char *targ0,
                char *flag, char *find, int *sure)
/*
 * Handles calls to all available backend probes that return one int,
 * keeps trying them until out of probes or one returns good (non-zero) value
 */
{
   char osname[128];
   char *cmnd, *res, *frm, *targ;
   enum OSTYPE OS;
   enum ASMDIA asmd;
   int i, iret=0;

   *sure = 0;
   asmd = (asmd0 > ASM_None && asmd0 < NASMD) ? asmd0 : gas_x86_32;
   OS = (OS0 > OSOther && OS0 < NOS) ? OS0 : OSLinux;
   if (OS == OSOSX)
      strlowcpy(osname, osnam[OSFreeBSD]);
   else if (OSIsWin(OS))
      strcpy(osname, "win");
   else
      strlowcpy(osname, osnam[OS]);
   if (targ0)
   {
      i = strlen(targ0) + 24;
      targ = malloc(sizeof(char)*i);
      assert(targ);
      sprintf(targ, "atlrun=atlas_runX targ=%s", targ0);
   }
   else
   {
      targ = malloc(sizeof(char));
      assert(targ);
      targ[0] = '\0';
   }

/*
 * If Assembler right or unspecified, try x86 probe
 */
   if (asmd == gas_x86_32 || asmd == gas_x86_64)
   {
      frm = "make IRunArchInfo_x86 MYFLAGS=\"-DATL_OS_%s -DATL_%s\" args=\"%s\" %s | fgrep '%s'";
      i = strlen(frm) + strlen(osnam[OS]) + strlen(ASMNAM[asmd]) + strlen(flag)
          + strlen(targ) + strlen(find) + 1;
      cmnd = malloc(sizeof(char)*i);
      assert(cmnd);
      sprintf(cmnd, frm, osnam[OS], ASMNAM[asmd], flag, targ, find);
      res = atlsys_1L(NULL, cmnd, 0, 0);
      if (res)
      {
         iret = GetFirstInt(res);
         *sure = GetLastInt(res);
         free(res);
      }
      free(cmnd);
   }
/*
 * If that didn't work, try OS-specific probe
 */
   if (!iret)
   {
      frm = "make IRunArchInfo_%s MYFLAGS=\"-DATL_OS_%s -DATL_%s\" args=\"%s\" %s | fgrep '%s'";
      i = 1 + strlen(frm) + strlen(osname) + 3+strlen(osnam[OS]) +
          strlen(ASMNAM[asmd]) + strlen(flag) + strlen(targ) + strlen(find);
      cmnd = malloc(sizeof(char)*i);
      assert(cmnd);
      sprintf(cmnd, frm, osname, osnam[OS], ASMNAM[asmd], flag, targ, find);
      res = atlsys_1L(NULL, cmnd, 0, 0);
      if (res)
      {
         iret = GetFirstInt(res);
         *sure = GetLastInt(res);
         free(res);
      }
      free(cmnd);
   }
   return(iret);
}