예제 #1
0
def init(benchmark, acf=createChoiceSiteMutators, taf=createTunableMutators):
  if config.debug:
    logging.basicConfig(level=logging.DEBUG)
    config.pause_on_crash = True
  if not config.threads:
    config.threads = pbutil.cpuCount()
  for k in filter(len, config.abort_on.split(',')):
    warnings.simplefilter('error', getattr(tunerwarnings,k))
  infoxml = TrainingInfo(pbutil.benchmarkToInfo(benchmark))
  if not config.main:
    config.main = mainname([pbutil.benchmarkToBin(benchmark)])
  tester = CandidateTester(benchmark, config.min_input_size)
  if config.seed is None:
    cfg = defaultConfigFile(pbutil.benchmarkToBin(tester.app))
  else:
    cfg = configtool.ConfigFile(config.seed)
  candidate = Candidate(cfg, infoxml.transform(config.main))
  addMutators(candidate, infoxml.globalsec(), acf, taf)
  addMutators(candidate, infoxml.transform(config.main), acf, taf)
  candidate.addMutator(mutators.MultiMutator(2))
  if not config.delete_output_dir:
    storagedirs.cur.dumpConfig()
    storagedirs.cur.dumpGitStatus()
    storagedirs.cur.saveFile(pbutil.benchmarkToInfo(benchmark))
    storagedirs.cur.saveFile(pbutil.benchmarkToBin(benchmark))
  return candidate, tester
예제 #2
0
def init(benchmark,
         tester_lambda=None,
         pop_lambda=None,
         hlconfig_lambda=None,
         config_lambda=None):
    if config.debug:
        logging.basicConfig(level=logging.DEBUG)
        config.pause_on_crash = True
    if not config.threads:
        config.threads = pbutil.cpuCount()
    for k in filter(len, config.abort_on.split(',')):
        warnings.simplefilter('error', getattr(tunerwarnings, k))
    if hlconfig_lambda is not None:
        hlconfig = hlconfig_lambda()
    else:
        infoxml = TrainingInfo(pbutil.benchmarkToInfo(benchmark))
        hlconfig = HighLevelConfig(infoxml)
    if not config.main:
        if tester_lambda is None and pop_lambda is None and hlconfig_lambda is None:
            config.main = mainname([pbutil.benchmarkToBin(benchmark)])
    if tester_lambda is not None:
        tester = tester_lambda(benchmark, config.min_input_size)
    else:
        tester = CandidateTester(benchmark, config.min_input_size)
    if config_lambda is not None:
        cfg = config_lambda()
    else:
        if config.seed is None:
            cfg = defaultConfigFile(pbutil.benchmarkToBin(tester.app))
        else:
            cfg = configtool.ConfigFile(config.seed)
    candidate = Candidate(cfg)
    if hlconfig_lambda is None:
        if not config.delete_output_dir:
            storagedirs.cur.dumpConfig()
            storagedirs.cur.dumpGitStatus()
            storagedirs.cur.saveFile(pbutil.benchmarkToInfo(benchmark))
            storagedirs.cur.saveFile(pbutil.benchmarkToBin(benchmark))
        if not infoxml.transform(
                config.main).isVariableAccuracy() and config.accuracy_target:
            logging.info("clearing accuracy_target")
            config.accuracy_target = None
    return candidate, tester, hlconfig
예제 #3
0
def init(benchmark, tester_lambda=None, pop_lambda=None, hlconfig_lambda=None, config_lambda=None):
  if config.debug:
    logging.basicConfig(level=logging.DEBUG)
    config.pause_on_crash = True
  if not config.threads:
    config.threads = pbutil.cpuCount()
  for k in filter(len, config.abort_on.split(',')):
    warnings.simplefilter('error', getattr(tunerwarnings,k))
  if hlconfig_lambda is not None:
    hlconfig = hlconfig_lambda()
  else:
    infoxml = TrainingInfo(pbutil.benchmarkToInfo(benchmark))
    hlconfig = HighLevelConfig(infoxml)
  if not config.main:
    if tester_lambda is None and pop_lambda is None and hlconfig_lambda is None:
      config.main = mainname([pbutil.benchmarkToBin(benchmark)])
  if tester_lambda is not None:
    tester = tester_lambda(benchmark, config.min_input_size)
  else:
    tester = CandidateTester(benchmark, config.min_input_size)
  if config_lambda is not None:
    cfg = config_lambda()
  else:
    if config.seed is None:
      cfg = defaultConfigFile(pbutil.benchmarkToBin(tester.app))
    else:
      cfg = configtool.ConfigFile(config.seed)
  candidate = Candidate(cfg)
  if hlconfig_lambda is None:
    if not config.delete_output_dir:
      storagedirs.cur.dumpConfig()
      storagedirs.cur.dumpGitStatus()
      storagedirs.cur.saveFile(pbutil.benchmarkToInfo(benchmark))
      storagedirs.cur.saveFile(pbutil.benchmarkToBin(benchmark))
    if not infoxml.transform(config.main).isVariableAccuracy() and config.accuracy_target:
      logging.info("clearing accuracy_target")
      config.accuracy_target = None
  return candidate, tester, hlconfig
예제 #4
0
    return compare

  def cleanup(self):
    if config.cleanup_inputs:
      storagedirs.clearInputs();
      self.inputs=[]

if __name__ == "__main__":
  print "TESTING CANDIDATETESTER"
  pbutil.chdirToPetabricksRoot();
  pbutil.compilePetabricks();
  benchmark=pbutil.normalizeBenchmarkName('multiply')
  pbutil.compileBenchmarks([benchmark])
  tester = CandidateTester(benchmark, 768)
  try:
    candidate = Candidate(defaultConfigFile(pbutil.benchmarkToBin(tester.app)))
    candidate2 = Candidate(defaultConfigFile(pbutil.benchmarkToBin(tester.app)))
    candidate2.config['MatrixMultiplyTransposed_0_lvl1_rule']=1
    tester.test(candidate)
    tester.test(candidate)
    tester.test(candidate)
    tester.test(candidate2)
    tester.test(candidate2)
    tester.test(candidate2)
    print candidate.metrics[0]
    print candidate2.metrics[0]
    print str(candidate.metrics[0][768])
    print str(candidate2.metrics[0][768])
    c=tester.comparer(0, .95, 25)
    print c(candidate, candidate2)
    print candidate.metrics[0][768].sameChance(candidate2.metrics[0][768])
예제 #5
0
    return cmpobj(a,b)

  def cleanup(self):
    if config.cleanup_inputs:
      storagedirs.clearInputs();
      self.inputs=[]

if __name__ == "__main__":
  print "TESTING CANDIDATETESTER"
  pbutil.chdirToPetabricksRoot();
  pbutil.compilePetabricks();
  benchmark=pbutil.normalizeBenchmarkName('multiply')
  pbutil.compileBenchmarks([benchmark])
  tester = CandidateTester(benchmark, 768)
  try:
    candidate = Candidate(defaultConfigFile(pbutil.benchmarkToBin(tester.app)))
    candidate2 = Candidate(defaultConfigFile(pbutil.benchmarkToBin(tester.app)))
    candidate2.config['MatrixMultiplyTransposed_0_lvl1_rule']=1
    tester.test(candidate)
    tester.test(candidate)
    tester.test(candidate)
    tester.test(candidate2)
    tester.test(candidate2)
    tester.test(candidate2)
    print candidate.metrics[0]
    print candidate2.metrics[0]
    print str(candidate.metrics[0][768])
    print str(candidate2.metrics[0][768])
    c=tester.comparer(0, .95, 25)
    print c(candidate, candidate2)
    print candidate.metrics[0][768].sameChance(candidate2.metrics[0][768])