Esempio n. 1
0
def findCandidates(search_path):
  """Determine Candidate attributes from file name."""

  archs = arch.getArchitectures()
  pes = [arch.getCpu(a) for a in archs]

  candidates = dict()
  for c in os.listdir(search_path):
    name, ext = os.path.splitext(c)
    atts = dict()
    for att in name.split('_'):
      multipleSimulations = re.match('ms([0-9]+)', att)
      order = re.match('O([0-9]+)', att)
      if multipleSimulations:
        atts['multipleSimulations'] = int(multipleSimulations.group(1))
      elif order:
        atts['order'] = int(order.group(1))
      elif att.lower() in ['s', 'd']:
        atts['precision'] = att.lower()
      elif att.lower() in pes:
        atts['pe'] = att.lower()
      else:
        atts['equations'] = att
    candidates[c] = Candidate(atts)
  return candidates
Esempio n. 2
0
def guessMemoryLayout(env):
    script_dir = os.path.dirname(os.path.abspath(__file__))
    path = os.path.join(script_dir, '..', 'auto_tuning', 'config')

    # from least to most
    importance = [
        'precision', 'equations', 'order', 'pe', 'multipleSimulations'
    ]
    values = {
        'precision': env['arch'][0].lower(),
        'equations': env['equations'].lower(),
        'order': int(env['order']),
        'pe': arch.getCpu(env['arch']),
        'multipleSimulations': int(env['multipleSimulations'])
    }

    candidates = findCandidates(search_path=path)
    bestFit = max(candidates.keys(),
                  key=lambda key: candidates[key].score(values))
    bestScore = candidates[bestFit].score(values)

    if bestScore == 0:
        print(
            'WARNING: No suitable memory layout found. (Will fall back to all dense.)'
        )
        bestFit = 'dense.xml'
    print('Using memory layout {}'.format(bestFit))
    return os.path.join(path, bestFit)
Esempio n. 3
0
def findCandidates():
  """Determine Candidate attributes from file name."""

  archs = arch.getArchitectures()
  pes = [arch.getCpu(a) for a in archs]

  path = os.path.join('auto_tuning', 'config')
  candidates = dict()
  for c in os.listdir(path):
    name, ext = os.path.splitext(c)
    atts = dict()
    for att in name.split('_'):
      multipleSimulations = re.match('ms([0-9]+)', att)
      order = re.match('O([0-9]+)', att)
      if multipleSimulations:
        atts['multipleSimulations'] = int(multipleSimulations.group(1))
      elif order:
        atts['order'] = int(order.group(1))
      elif att.lower() in ['s', 'd']:
        atts['precision'] = att.lower()
      elif att.lower() in pes:
        atts['pe'] = att.lower()
      else:
        atts['equations'] = att
    candidates[c] = Candidate(atts)
  return candidates
Esempio n. 4
0
def guessMemoryLayout(env):    
  path = os.path.join('auto_tuning', 'config')

  # from least to most
  importance = ['precision', 'equations', 'order', 'pe', 'multipleSimulations']
  values = {
    'precision': env['arch'][0].lower(),
    'equations': env['equations'].lower(),
    'order': int(env['order']),
    'pe': arch.getCpu(env['arch']),
    'multipleSimulations': int(env['multipleSimulations'])
  }

  candidates = findCandidates()
  bestFit = max(candidates.keys(), key=lambda key: candidates[key].score(values))
  bestScore = candidates[bestFit].score(values)

  if bestScore == 0:
    print('WARNING: No suitable memory layout found. (Will fall back to all dense.)')
    bestFit = 'dense.xml'
  print('Using memory layout {}'.format(bestFit))
  return os.path.join(path, bestFit)