Esempio n. 1
0
def do_work(file,mintime,wayness,lariat_dict):
  retval=(None,None,None,None,None)
  res=plot.get_data(file,mintime,wayness,lariat_dict)
  
  if (res is None):
    return retval

  (ts, ld, tmid,
   read_rate, write_rate, stall_rate, clock_rate, avx_rate, sse_rate, inst_rate,
   meta_rate, l1_rate, l2_rate, l3_rate, load_rate, read_frac, stall_frac) = res

  #  return (scipy.stats.tmean(stall_frac),
  #          scipy.stats.tmean((load_rate - (l1_rate + l2_rate +
  #          l3_rate))/load_rate))

  mean_mem_rate=scipy.stats.tmean(read_rate+write_rate)*64.0
  ename=ld.exc.split('/')[-1]
  ename=tspl_utils.string_shorten(ld.comp_name(ename,ld.equiv_patterns),8)
  if ename=='unknown':
    return retval
  flag=False
  if mean_mem_rate < 75.*1000000000./16.:
    flag=True

  return (scipy.stats.tmean(stall_frac),
          scipy.stats.tmean((load_rate - (l1_rate))/load_rate),
          scipy.stats.tmean(clock_rate/inst_rate),ename,
          flag)
Esempio n. 2
0
def summary_text(ld,ts,maxwidth=55,max_ibrun_lines=45):
  text=''
  cnt = 0
  try:
    runtimes=ld.get_runtimes(ts.j.acct['end_time'])
    for ibr in ld.ld[ld.id]:
      text += 'ibrun ' + str(cnt) + ':\n'
      text+='    Executable: ' + \
             lariat_utils.replace_and_wrap_path_bits(ibr['exec'],
                                                   ld.user,maxwidth,16) + '\n'
      text+='    CWD: ' + \
             lariat_utils.replace_and_wrap_path_bits(ibr['cwd'], 
                                                     ld.user,maxwidth,9) + '\n'
      text+='    Run time: ' + str(float(runtimes[cnt])/3600.) + '\n'
      if len(ibr['pkgT']) > 0:
        text+= '    Linked modules:\n'
      for pkg in ibr['pkgT']:
        text += '        ' + pkg + '\n'
      cnt+=1
  except Exception as e:
    pass

  res=text.split('\n')
  if len(res) > max_ibrun_lines:
    text='...\n'+'\n'.join(res[-max_ibrun_lines:])


  top_text ='Job ID: ' + str(ts.j.id) + ', '
  top_text+='User: '******', '
  top_text+='Job Name: ' + tspl_utils.string_shorten(ts.j.acct['name'],15) + \
             ', '
  top_text+='Queue: ' + ts.queue + '\n'
  top_text+='Start Time: ' + ts.start_date + ', End Time: ' + ts.end_date + '\n'
  top_text+='Status: ' + ts.status + '\n'
  top_text+='Hosts: ' + str(ts.numhosts) + ', Threads: ' + str(ld.threads) + \
             ', Wayness: ' + str(ld.wayness) + '\n'

  text=top_text+text
  
  return text
    
Esempio n. 3
0
def summary_text(ld,ts,maxwidth=55,max_ibrun_lines=45):
  text=''
  cnt = 0
  try:
    runtimes=ld.get_runtimes(ts.j.acct['end_time'])
    for ibr in ld.ld[ld.id]:
      text += 'ibrun ' + str(cnt) + ':\n'
      text+='    Executable: ' + \
             lariat_utils.replace_and_wrap_path_bits(ibr['exec'],
                                                   ld.user,maxwidth,16) + '\n'
      text+='    CWD: ' + \
             lariat_utils.replace_and_wrap_path_bits(ibr['cwd'], 
                                                     ld.user,maxwidth,9) + '\n'
      text+='    Run time: ' + str(float(runtimes[cnt])/3600.) + '\n'
      if len(ibr['pkgT']) > 0:
        text+= '    Linked modules:\n'
      for pkg in ibr['pkgT']:
        text += '        ' + pkg + '\n'
      cnt+=1
  except Exception as e:
    pass

  res=text.split('\n')
  if len(res) > max_ibrun_lines:
    text='...\n'+'\n'.join(res[-max_ibrun_lines:])


  top_text ='Job ID: ' + str(ts.j.id) + ', '
  top_text+='User: '******', '
  top_text+='Job Name: ' + tspl_utils.string_shorten(ts.j.acct['name'],15) + \
             ', '
  top_text+='Queue: ' + ts.queue + '\n'
  top_text+='Start Time: ' + ts.start_date + ', End Time: ' + ts.end_date + '\n'
  top_text+='Status: ' + ts.status + '\n'
  top_text+='Hosts: ' + str(ts.numhosts) + ', Threads: ' + str(ld.threads) + \
             ', Wayness: ' + str(ld.wayness) + '\n'

  text=top_text+text
  
  return text
Esempio n. 4
0
  def __init__(self,file,k1,k2,job_data = None):

    if job_data:
      self.j = job_data
    else:
      self.f=open(file)
      try:
        self.j=pickle.load(self.f)
      except EOFError as e:
        raise TSPLException('End of file found for: ' + file)
      self.f.close()

    try: 
      self.wayness=self.j.acct['cores']/self.j.acct['nodes']
    except ZeroDivisionError:
      if VERBOSE: print "Read zero nodes, assuming 16 way for job " + str(self.j.id)
      self.wayness=16
    except KeyError:
      try:
        self.wayness=int(re.findall('\d+',self.j.acct['granted_pe'])[0])
      except AttributeError:
        raise TSPLException("Pickle file broken: " + file)
    except TypeError:
      raise TSPLException('Something is funny with job ' +str(self.j.id) +
                            ' ' + str(self.j.acct['cores']) + ' ' +
                            str(self.j.acct['nodes']))
    except:
      raise TSPLException('Something is funny with file' + file )
    
    """
    try:
      self.wayness=int(re.findall('\d+',self.j.acct['granted_pe'])[0])
    except AttributeError:
      raise TSPLException("Pickle file broken: " + file)
    except KeyError:
      try:
        self.wayness=self.j.acct['cores']/self.j.acct['nodes']
      except ZeroDivisionError:
        if VERBOSE: print "Read zero nodes, assuming 16 way for job " + str(self.j.id)
        self.wayness=16
      except TypeError:
        raise TSPLException('Something is funny with job ' +str(self.j.id) +
                            ' ' + str(self.j.acct['cores']) + ' ' +
                            str(self.j.acct['nodes']))
    """
    try:
      self.queue=self.j.acct['queue']
    except KeyError:
      print 'No queue found'
      self.queue = None

    self.status='Unknown'
    try:
      self.status=self.j.acct['status']
    except KeyError:
      try:
        self.status=self.j.acct['exit_status']
      except KeyError as e:
        pass
      pass

    try:
      self.owner=pwd.getpwuid(int(self.j.acct['uid']))[0]
    except KeyError:
      try:
        self.owner=self.j.acct['owner']
      except Exception as e:
        self.owner=self.j.acct['uid']        
    except Exception as e:
      self.owner=self.j.acct['uid']
      
    self.numhosts=len(self.j.hosts.keys())

    if self.numhosts == 0:
      raise TSPLException('No hosts in job '+ str(self.j.id))

    self.su=float(self.j.acct['end_time'] - self.j.acct['start_time'])* \
            float(self.numhosts*16.0)/3600.0 # Need to refactor the 16 into the
                                        # accounting class

    if isinstance(k1,dict) and isinstance(k2,dict):
      if 'amd64_core' in self.j.hosts.values()[0].stats:
        self.pmc_type='amd64'
      elif 'intel_pmc3' in self.j.hosts.values()[0].stats:
        self.pmc_type='intel'
      elif 'intel_snb' in self.j.hosts.values()[0].stats:
        self.pmc_type='intel_snb'
      
      if self.pmc_type in k1:
        self.k1=k1[self.pmc_type]
        self.k2=k2[self.pmc_type]
      else:
        raise TSPLException(self.pmc_type+
                            ' not supported for job'+str(self.j.id))
      
      
      if not self.k1[0] in self.j.schemas:
        raise TSPLException(self.k1[0]+' not supported for job '+str(self.j.id))

    elif isinstance(k1,list) and isinstance(k2,list):
      self.k1=k1
      self.k2=k2
      
      if not self.k1[0] in self.j.schemas:
        raise TSPLException(self.k1[0]+' not supported for job '+str(self.j.id))
      
    else:
      raise TSPLException('Input types must match and be lists or dicts: ' +
                          str(type(k1)) + ' ' + str(type(k2)))
    try:
      self.t=(self.j.times-self.j.times[0])
    except:
      raise TSPLException('Time series is '+str(self.j.times))


    if len(self.t) == 0:
      raise TSPLException('Time range is 0')

    if len(k1) != len(k2):
      raise TSPLException('Lengths don\'t match')

    self.index=[]

    for i in range(len(self.k1)):
      if self.k1[i] in self.j.schemas and \
      self.k2[i] in self.j.schemas[self.k1[i]]:
        self.index +=  [self.j.get_schema(self.k1[i])[self.k2[i]].index]
      else:
        self.index += [-1]

###    self.index=[ self.j.get_schema(self.k1[i])[self.k2[i]].index
###                 for i in range(len(self.k1))]

    g=self.j.hosts[self.j.hosts.keys()[0]]
    self.size=len(g.stats[self.k1[0]].values()[0])

    d=datetime.datetime.fromtimestamp(self.j.acct['start_time'])
    self.start_date=d.strftime('%Y-%m-%d %H:%M:%S')
    d=datetime.datetime.fromtimestamp(self.j.acct['end_time'])
    self.end_date=d.strftime('%Y-%m-%d %H:%M:%S')

    self.title='ID: %(ID)s, u: %(u)s, q: %(queue)s, N: %(name)s, '\
                'D: %(date)s, NH: %(nh)d' % \
           { 'ID' : self.j.id,'u': self.owner, 'queue': self.queue,
             'name': tspl_utils.string_shorten(self.j.acct['name'],15),
             'nh' : self.numhosts,
             'date': self.end_date }

    # Create an array of dictionaries of lists initialized and constructed using
    # derived class methods for the keys of interest.
    # self.index embedds the location of self.k2 in the sechma
    try:
      self.data=[]
      for i in range(len(self.k1)):
        self.data.append({})
        for k in self.j.hosts.keys():
          h=self.j.hosts[k]
          self.data[i][k]=self.data_init()
          try:
            for s in h.stats[self.k1[i]].values():
              self.data_assign(self.data[i][k],s[:,self.index[i]])
          except KeyError:
            continue
            
    except Exception as e:
      exc_type, exc_obj, exc_tb = sys.exc_info()
      fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
      if VERBOSE: print(exc_type, fname, exc_tb.tb_lineno)
Esempio n. 5
0
    def __init__(self, file, k1, k2, job_stats=None):

        if job_stats:
            self.j = job_stats
        else:
            self.f = open(file)
            try:
                self.j = pickle.load(self.f)
            except EOFError as e:
                raise TSPLException('End of file found for: ' + file)
            self.f.close()

        try:
            self.wayness = int(re.findall('\d+', self.j.acct['granted_pe'])[0])
        except AttributeError:
            raise TSPLException("Pickle file broken: " + file)
        except KeyError:
            try:
                self.wayness = self.j.acct['cores'] / self.j.acct['nodes']
            except ZeroDivisionError:
                print "Read zero nodes, assuming 16 way for job " + str(
                    self.j.id)
                self.wayness = 16
            except TypeError:
                raise TSPLException('Something is funny with job ' +
                                    str(self.j.id) + ' ' +
                                    str(self.j.acct['cores']) + ' ' +
                                    str(self.j.acct['nodes']))

        try:
            self.queue = self.j.acct['queue']
        except KeyError:
            print 'No queue found'
            self.queue = None

        self.status = 'Unknown'
        try:
            self.status = self.j.acct['status']
        except KeyError:
            try:
                self.status = self.j.acct['exit_stats']
            except KeyError as e:
                pass
            pass

        try:
            self.owner = self.j.acct['owner']
        except KeyError:
            try:
                import pwd
                self.owner = pwd.getpwuid(int(self.j.acct['uid']))[0]
            except Exception as e:
                self.owner = self.j.acct['uid']

        self.numhosts = len(self.j.hosts.keys())

        if self.numhosts == 0:
            raise TSPLException('No hosts in job ' + str(self.j.id))

        self.su=float(self.j.acct['end_time'] - self.j.acct['start_time'])* \
                float(self.numhosts*16.0)/3600.0 # Need to refactor the 16 into the
        # accounting class

        if isinstance(k1, dict) and isinstance(k2, dict):
            if 'amd64_core' in self.j.hosts.values()[0].stats:
                self.pmc_type = 'amd64'
            elif 'intel_pmc3' in self.j.hosts.values()[0].stats:
                self.pmc_type = 'intel'
            elif 'intel_snb' in self.j.hosts.values()[0].stats:
                self.pmc_type = 'intel_snb'

            if self.pmc_type in k1:
                self.k1 = k1[self.pmc_type]
                self.k2 = k2[self.pmc_type]
            else:
                raise TSPLException(self.pmc_type + ' not supported for job' +
                                    str(self.j.id))

            if not self.k1[0] in self.j.schemas:
                raise TSPLException(self.k1[0] + ' not supported for job ' +
                                    str(self.j.id))

        elif isinstance(k1, list) and isinstance(k2, list):
            self.k1 = k1
            self.k2 = k2

            if not self.k1[0] in self.j.schemas:
                raise TSPLException(self.k1[0] + ' not supported for job ' +
                                    str(self.j.id))

        else:
            raise TSPLException(
                'Input types must match and be lists or dicts: ' +
                str(type(k1)) + ' ' + str(type(k2)))

        self.t = (self.j.times - self.j.times[0])

        if len(k1) != len(k2):
            raise TSPLException('Lengths don\'t match')

        self.index = []

        for i in range(len(self.k1)):
            if self.k1[i] in self.j.schemas and \
            self.k2[i] in self.j.schemas[self.k1[i]]:
                self.index += [self.j.get_schema(self.k1[i])[self.k2[i]].index]
            else:
                self.index += [-1]

###    self.index=[ self.j.get_schema(self.k1[i])[self.k2[i]].index
###                 for i in range(len(self.k1))]

        g = self.j.hosts[self.j.hosts.keys()[0]]
        self.size = len(g.stats[self.k1[0]].values()[0])

        d = datetime.datetime.fromtimestamp(self.j.acct['start_time'])
        self.start_date = d.strftime('%Y-%m-%d %H:%M:%S')
        d = datetime.datetime.fromtimestamp(self.j.acct['end_time'])
        self.end_date = d.strftime('%Y-%m-%d %H:%M:%S')

        self.title='ID: %(ID)s, u: %(u)s, q: %(queue)s, N: %(name)s, '\
                    'D: %(date)s, NH: %(nh)d' % \
               { 'ID' : self.j.id,'u': self.owner, 'queue': self.queue,
                 'name': tspl_utils.string_shorten(self.j.acct['name'],15),
                 'nh' : self.numhosts,
                 'date': self.end_date }

        # Create an array of dictionaries of lists initialized and constructed using
        # derived class methods for the keys of interest.
        # self.index embedds the location of self.k2 in the sechma
        try:
            self.data = []
            for i in range(len(self.k1)):
                self.data.append({})
                for k in self.j.hosts.keys():
                    h = self.j.hosts[k]
                    self.data[i][k] = self.data_init()
                    try:
                        for s in h.stats[self.k1[i]].values():
                            self.data_assign(self.data[i][k], s[:,
                                                                self.index[i]])
                    except KeyError:
                        continue

        except Exception as e:
            import sys
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)