コード例 #1
0
def in_test_single_pgm(N=1):
  test_len = [12]
  fout = open("report_in_12.txt", "w")
  fout.write("Benchmark | Cycle Counts | Algorithm Runtime (s)| Sample Sizes | Passes \n")

  from gym_hls.envs.chstone_bm import get_all9
  bms = get_all9() 
  for bm in bms: 
    for length in test_len:
      envs = []
      i = 0
      pgm, path  = bm
      print("Program: {}".format(pgm))
      env_config = {
        'pgm':pgm,
        'pgm_dir':path,
        'run_dir':'run_'+pgm.replace(".c",""),
        'normalize':False,
        'orig_and_normalize':False,
        'log_obs_reward':False,
        'verbose':False,
        }
      envs.append(Env(env_config))
      i = i+1
      begin = time.time()
      (passes, timings, sample_size) = runInsertionN(envs, N, length=length, sort=True)
      end = time.time()
      print("Best individuals are: {}".format(passes[0]))
      print("Cycles: {}".format(timings[0]))
      compile_time =end - begin
      print("Compile Time: %d"%(int(compile_time)))
      fout.write("{}|{}|{}|{}|{}".format(pgm, timings[0], compile_time, sample_size, passes[0]))
コード例 #2
0
ファイル: parse_log.py プロジェクト: gloaming2dawn/autophase
def parse_log(algo="a3c"):
    from gym_hls.envs.chstone_bm import get_chstone, get_others, get_all9
    bms = get_all9()
    fout = open("report_" + algo + ".txt", "w")
    for i, bm in enumerate(bms):
        pgm, _ = bm
        pgm = pgm.replace(".c", "")
        #pgm = str(i)
        min_cycle, sample_size, actual_sample_size, threads = get_min(
            "run_{}_{}_".format(algo, pgm))
        fout.write("{}|{}|{}|{}|{}\n".format(pgm, min_cycle, sample_size,
                                             actual_sample_size, threads))

    fout.close()
コード例 #3
0
from __future__ import print_function
#import adddeps  # fix sys.path

from gym_hls.envs.hls_env import HLSEnv

import pickle

if __name__ == '__main__':
    from gym_hls.envs.chstone_bm import get_chstone, get_others, get_all9
    bms = get_all9()

    algo_pass = {}
    #algo_pass['autotuner'] = [18, 7, 37, 31, 38, 17, 2, 6, 23, 21, 24, 41, 19, 20, 33, 11, 44, 26, 4, 34, 27, 32, 8, 22, 36]
    #algo_pass['ga'] = [0, 1, 43, 1, 1, 0, 25, 1, 23, 16, 0, 0, 0, 33, 0, 18, 16, 0, 37, 0, 35, 0, 1, 0, 1, 14, 14, 0, 23, 1, 44, 0, 1, 33, 1, 1, 28, 0, 1, 0, 0, 0, 0, 1, 2]
    #algo_pass['greedy'] = [23, 20, 34, 11, 33, 10, 32]
    #algo_pass['greedy'] = [23, 20, 34, 11, 33, 10, 32,  9, 31,  8, 30,  7, 29,  6, 28,  5, 27]

    # Train on random
    #algo_pass['greedy'] =  [10,  8, 15, 11,  6, 13, 10,  7, 11,  3, 13,  7,  7,  7,  7,  7]
    #algo_pass['opentuner'] = [15, 14, 10, 8, 6, 5, 13, 7, 0]
    #algo_pass['ga'] = [4, 1, 0, 8, 11, 1, 2, 15, 13, 11, 11, 2, 1, 4, 13, 1]
    algo_pass['ga'] = [13, 9, 15, 10, 14, 7, 5, 14, 15, 6, 0, 11, 13, 4, 15, 4]

    for algo, passes in algo_pass.items():

        fout = open(algo + ".csv", "w")
        for i, bm in enumerate(bms):
            pgm, files = bm
            env_configs = {}
            env_configs['pgm'] = pgm
            env_configs['pgm_dir'] = files