Skip to content

Commit

Permalink
regression script update
Browse files Browse the repository at this point in the history
  • Loading branch information
gmx committed Jan 18, 2024
1 parent 5467f58 commit dcb5a1e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 80 deletions.
38 changes: 30 additions & 8 deletions regression/multi_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,46 @@
import getopt
from multiprocessing import Process, Pool
import regression_config as rcfg
import subprocess

def run_case(name, simulator):
def run_case(name, simulator, cfg):
print('Run Case: %s' % name)
vcs = 'make simv-run'
emu = 'make emu_rtl-run'
simulation_prefix = cfg['config']['case_prefix']
shell = ''
if simulator == 'vcs':
shell = vcs + " RUN_BIN=" + name
shell = vcs + " RUN_BIN=" + simulation_prefix + name
elif simulator == 'verilator':
shell = emu + " RUN_BIN=" + name
shell = emu + " RUN_BIN=" + simulation_prefix + name
print(shell)
os.system(shell)

def run_case_timeout(name, simulator, cfg):
print('Run Case: %s' % name)
simulation_prefix = cfg['config']['case_prefix']
comp_dir = os.path.abspath('./') + '/sim/rtl/comp'
simv_dir = os.path.abspath('./') + '/sim/rtl/' + simulation_prefix + name
workload_dir = cfg['config']['workload']
create_simdir = 'mkdir -p ' + simv_dir
creat_simlog = 'touch ' + simv_dir + '/sim.log'
command_ln1 = 'ln -s ' + comp_dir + '/simv ' + simv_dir + '/simv'
command_ln2 = 'ln -s ' + comp_dir + '/simv.daidir ' + simv_dir + '/simv.daidir'
print(creat_simlog)
print(command_ln1)
print(command_ln2)
os.system(create_simdir + '&&' + creat_simlog + '&&' + command_ln1 + '&&' + command_ln2)
run_work_load = '+workload=' + workload_dir + simulation_prefix + name
run_diff = '+diff=' + workload_dir + 'riscv64-spike-so'
run_opts = '-fgp=num_threads:4,num_fsdb_threads:4,allow_less_cores'
run_assert = ['-assert', 'finish_maxfail=30', '-assert', 'global_finish_maxfail=10000', '2>', 'assert.log', '|', 'tee', 'sim.log']
try:
run_proc = subprocess.run(['./simv', run_work_load, run_diff, run_opts] + run_assert, cwd=simv_dir, timeout=10)
except subprocess.TimeoutExpired:
run_proc.kill()
run_proc.wait()

def multi_task_run(task_num, cfg, case_file_list):
path = cfg['config']['case_abs_path']
case_prefix = cfg['config']['case_prefix']
simulator = cfg['config']['simulator']

test_case_list = rcfg.get_case_list('./regression', case_file_list)
Expand All @@ -30,8 +54,6 @@ def multi_task_run(task_num, cfg, case_file_list):
for list_name in test_case_list.keys():
case_list = test_case_list[list_name]
for case in case_list:
case_name = case_prefix + '/' + case
print(case_name)
pool.apply_async(func = run_case, args = (case_name, simulator))
pool.apply_async(func = run_case_timeout, args = (case, simulator, cfg))
pool.close()
pool.join()
38 changes: 5 additions & 33 deletions regression/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,6 @@ def parse_sim_result(file_name):
return [file_name, "This case has not sim_file"]
return [file_name, "Unknown Error!!!!!!"]

def result_record(file_name, case_list):
pass_list = []
fail_list = []
unknown_list = []
for case in case_list:
result = case[1]
if 'PASS' in result:
pass_list.append(case)
elif 'difftest Failed! Please debug it!' in result:
fail_list.append(case)
else:
unknown_list.append(case)
with open(file_name, 'a+') as f:
f.write('This regression passed %d cases:' % len(pass_list) + '\n')
for case in pass_list:
f.write(case[0] + "\t\t\t\t" + case[1] + '\n')

f.write('\n\n\nThis regression failed %d cases:' % len(fail_list) + '\n')
for case in fail_list:
f.write(case[0] + "\t\t\t\t" + case[1] + '\n')

f.write('\n\n\n%d cases had an unknown error:' % len(unknown_list) + '\n')
for case in unknown_list:
f.write(case[0] + "\t\t\t\t" + case[1] + '\n')

f.write('\n\n\nThis regression runs a total of %d cases\n' % len(case_list))
f.write('passing rate: %.2f' % (len(pass_list) / len(case_list)))
f.close()

def res_analysis(cfg, test_list):
sim_prefix = ''
if cfg['config']['simulator'] == "verilator":
Expand All @@ -67,7 +38,7 @@ def res_analysis(cfg, test_list):
for list_name in test_case_list.keys():
case_list = test_case_list[list_name]
for case in case_list:
sim_name = sim_prefix + '/' + case
sim_name = sim_prefix + case
result = parse_sim_result(sim_name + '/sim.log')
results.append(result)

Expand All @@ -94,6 +65,7 @@ def res_analysis(cfg, test_list):
f.write(case + '\n')
f.write("---------------------------------------------------------------------------------------------\n\n")
f.close()
return analysis_res

def only_fault_link(cfg, test_list):
sim_prefix = ''
Expand All @@ -107,7 +79,7 @@ def only_fault_link(cfg, test_list):
for list_name in test_case_list.keys():
case_list = test_case_list[list_name]
for case in case_list:
sim_name = sim_prefix + '/' + case
sim_name = sim_prefix + case
result = parse_sim_result(sim_name + '/sim.log')
results.append(result)

Expand All @@ -122,13 +94,13 @@ def only_fault_link(cfg, test_list):
analysis_res[res].append(keyword)

cfg_file = os.path.abspath("./regression/analysis_info.toml")
cfg = toml.load(cfg_file)
cfg_analysis = toml.load(cfg_file)
os.system('rm -rf ./only_failed/*')
for res_type in analysis_res.keys():
if res_type == 'Unknown Error!!!!!!' or res_type == 'difftest failed':
res_list = analysis_res[res_type]
for case in res_list:
bin_name = case.split('/')
print(bin_name[-2])
link = 'ln -s /home/simulation_path/' + bin_name[-2] + ' /home/simulation_path/only_failed'
link = 'ln -s ' + os.path.abspath('./') + '/sim/rtl/' + cfg['config']['case_prefix'] + bin_name[-2] + ' ' + os.path.abspath('./') + '/only_failed'
os.system(link)
13 changes: 3 additions & 10 deletions regression/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
import multi_task
import record

def parse_case_list(file_name):
with open(file_name, 'r') as f:
case_list = f.readlines()
return case_list
return []

def main():
simulator = ""
cfg = rcfg.parse_config('./regression')
test_list = []
if cfg['config']['sim_mode'] == 'part':
Expand All @@ -23,10 +16,10 @@ def main():
test_list = cfg['case']['list']
print(test_list)
sim_num = cfg['config']['sim_num']
multi_task.multi_task_run(sim_num, cfg, test_list)
record.res_analysis(cfg, test_list)
#multi_task.multi_task_run(sim_num, cfg, test_list)
exec_res = record.res_analysis(cfg, test_list)
print(exec_res)
record.only_fault_link(cfg, test_list)


if __name__ == '__main__':
main()
30 changes: 1 addition & 29 deletions regression/regression_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@
import sys
from pprint import pprint


'''
'case': { 'vector': {'list': ['valu',
'vcompare',
'vfix',
'vfp',
'vmac',
'vmask',
'vnarrow',
'vpermutation',
'vreduction',
'vwiden'
]
}
},
'config': { 'case_path': 'vcase',
'part_list': ['vmask', 'vpermutation'],
'sim_mode': 'part',
'simulator': 'verilator'
}
'''

def case_list_check(all_list, part_list):
for part in part_list:
if part not in all_list:
Expand Down Expand Up @@ -77,8 +53,4 @@ def get_case_list(path, test_list):
case_list[test_name] = []
line = line.replace('\n', '').replace('\r', '')
case_list[test_name].append(line)
return case_list

# test_list = parse_config()['config']['part_list']
# list_out = get_case_list('./', test_list)
# print(list_out)
return case_list

0 comments on commit dcb5a1e

Please sign in to comment.