formatted
This commit is contained in:
parent
23e8a4f857
commit
e796e460ae
|
@ -67,10 +67,14 @@ parser.add_argument(
|
||||||
)
|
)
|
||||||
parser.add_argument("--config", help="Override default configuration")
|
parser.add_argument("--config", help="Override default configuration")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--test_run", action="store_true", help="Dummy run shows final generated VPR commands"
|
"--test_run",
|
||||||
|
action="store_true",
|
||||||
|
help="Dummy run shows final generated VPR commands",
|
||||||
)
|
)
|
||||||
parser.add_argument("--debug", action="store_true", help="Run script in debug mode")
|
parser.add_argument("--debug", action="store_true", help="Run script in debug mode")
|
||||||
parser.add_argument("--continue_on_fail", action="store_true", help="Exit script with return code")
|
parser.add_argument(
|
||||||
|
"--continue_on_fail", action="store_true", help="Exit script with return code"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--show_thread_logs", action="store_true", help="Skips logs from running thread"
|
"--show_thread_logs", action="store_true", help="Skips logs from running thread"
|
||||||
)
|
)
|
||||||
|
@ -83,14 +87,24 @@ task_script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
script_env_vars = {
|
script_env_vars = {
|
||||||
"PATH": {
|
"PATH": {
|
||||||
"OPENFPGA_FLOW_PATH": task_script_dir,
|
"OPENFPGA_FLOW_PATH": task_script_dir,
|
||||||
"VPR_ARCH_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "openfpga_flow", "vpr_arch"),
|
"VPR_ARCH_PATH": os.path.join(
|
||||||
"OF_ARCH_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "openfpga_flow", "openfpga_arch"),
|
"${PATH:OPENFPGA_PATH}", "openfpga_flow", "vpr_arch"
|
||||||
"OPENFPGA_SHELLSCRIPT_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "openfpga_flow", "OpenFPGAShellScripts"),
|
),
|
||||||
"BENCH_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "openfpga_flow", "benchmarks"),
|
"OF_ARCH_PATH": os.path.join(
|
||||||
|
"${PATH:OPENFPGA_PATH}", "openfpga_flow", "openfpga_arch"
|
||||||
|
),
|
||||||
|
"OPENFPGA_SHELLSCRIPT_PATH": os.path.join(
|
||||||
|
"${PATH:OPENFPGA_PATH}", "openfpga_flow", "OpenFPGAShellScripts"
|
||||||
|
),
|
||||||
|
"BENCH_PATH": os.path.join(
|
||||||
|
"${PATH:OPENFPGA_PATH}", "openfpga_flow", "benchmarks"
|
||||||
|
),
|
||||||
"TECH_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "openfpga_flow", "tech"),
|
"TECH_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "openfpga_flow", "tech"),
|
||||||
"SPICENETLIST_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "SpiceNetlists"),
|
"SPICENETLIST_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "SpiceNetlists"),
|
||||||
"VERILOG_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "VerilogNetlists"),
|
"VERILOG_PATH": os.path.join("${PATH:OPENFPGA_PATH}", "VerilogNetlists"),
|
||||||
"OPENFPGA_PATH": os.path.abspath(os.path.join(task_script_dir, os.pardir, os.pardir)),
|
"OPENFPGA_PATH": os.path.abspath(
|
||||||
|
os.path.join(task_script_dir, os.pardir, os.pardir)
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||||
|
@ -238,7 +252,8 @@ def generate_each_task_actions(taskname):
|
||||||
missing_section = list(set(required_sec) - set(task_conf.sections()))
|
missing_section = list(set(required_sec) - set(task_conf.sections()))
|
||||||
if missing_section:
|
if missing_section:
|
||||||
clean_up_and_exit(
|
clean_up_and_exit(
|
||||||
"Missing sections %s" % " ".join(missing_section) + " in task configuration file"
|
"Missing sections %s" % " ".join(missing_section)
|
||||||
|
+ " in task configuration file"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Declare varibles to access sections
|
# Declare varibles to access sections
|
||||||
|
@ -259,7 +274,9 @@ def generate_each_task_actions(taskname):
|
||||||
clean_up_and_exit("Found duplicate architectures in config file")
|
clean_up_and_exit("Found duplicate architectures in config file")
|
||||||
|
|
||||||
# Get Flow information
|
# Get Flow information
|
||||||
logger.info('Running "%s" flow', GeneralSection.get("fpga_flow", fallback="yosys_vpr"))
|
logger.info(
|
||||||
|
'Running "%s" flow', GeneralSection.get("fpga_flow", fallback="yosys_vpr")
|
||||||
|
)
|
||||||
|
|
||||||
# Check if specified benchmark files exist
|
# Check if specified benchmark files exist
|
||||||
benchmark_list = []
|
benchmark_list = []
|
||||||
|
@ -273,7 +290,8 @@ def generate_each_task_actions(taskname):
|
||||||
files = glob.glob(eachpath)
|
files = glob.glob(eachpath)
|
||||||
if not len(files):
|
if not len(files):
|
||||||
clean_up_and_exit(
|
clean_up_and_exit(
|
||||||
("No files added benchmark %s" % bech_name) + " with path %s " % (eachpath)
|
("No files added benchmark %s" % bech_name)
|
||||||
|
+ " with path %s " % (eachpath)
|
||||||
)
|
)
|
||||||
bench_files += files
|
bench_files += files
|
||||||
|
|
||||||
|
@ -309,11 +327,15 @@ def generate_each_task_actions(taskname):
|
||||||
|
|
||||||
yosys_params_common = {}
|
yosys_params_common = {}
|
||||||
for param in yosys_params:
|
for param in yosys_params:
|
||||||
yosys_params_common[param.upper()] = SynthSection.get("bench_" + param + "_common")
|
yosys_params_common[param.upper()] = SynthSection.get(
|
||||||
|
"bench_" + param + "_common"
|
||||||
|
)
|
||||||
|
|
||||||
# Individual benchmark configuration
|
# Individual benchmark configuration
|
||||||
CurrBenchPara["files"] = bench_files
|
CurrBenchPara["files"] = bench_files
|
||||||
CurrBenchPara["top_module"] = SynthSection.get(bech_name + "_top", fallback="top")
|
CurrBenchPara["top_module"] = SynthSection.get(
|
||||||
|
bech_name + "_top", fallback="top"
|
||||||
|
)
|
||||||
CurrBenchPara["ys_script"] = SynthSection.get(
|
CurrBenchPara["ys_script"] = SynthSection.get(
|
||||||
bech_name + "_yosys", fallback=ys_for_task_common
|
bech_name + "_yosys", fallback=ys_for_task_common
|
||||||
)
|
)
|
||||||
|
@ -338,7 +360,8 @@ def generate_each_task_actions(taskname):
|
||||||
if GeneralSection.getboolean("power_analysis"):
|
if GeneralSection.getboolean("power_analysis"):
|
||||||
if not SynthSection.get(bech_name + "_act"):
|
if not SynthSection.get(bech_name + "_act"):
|
||||||
clean_up_and_exit(
|
clean_up_and_exit(
|
||||||
"Missing argument %s" % (bech_name + "_act") + "for vpr_blif flow"
|
"Missing argument %s" % (bech_name + "_act")
|
||||||
|
+ "for vpr_blif flow"
|
||||||
)
|
)
|
||||||
CurrBenchPara["activity_file"] = SynthSection.get(bech_name + "_act")
|
CurrBenchPara["activity_file"] = SynthSection.get(bech_name + "_act")
|
||||||
else:
|
else:
|
||||||
|
@ -346,7 +369,9 @@ def generate_each_task_actions(taskname):
|
||||||
if not SynthSection.get(bech_name + "_act"):
|
if not SynthSection.get(bech_name + "_act"):
|
||||||
CurrBenchPara["activity_file"] = bech_name + "_act"
|
CurrBenchPara["activity_file"] = bech_name + "_act"
|
||||||
else:
|
else:
|
||||||
CurrBenchPara["activity_file"] = SynthSection.get(bech_name + "_act")
|
CurrBenchPara["activity_file"] = SynthSection.get(
|
||||||
|
bech_name + "_act"
|
||||||
|
)
|
||||||
|
|
||||||
# Check if base verilog file exists
|
# Check if base verilog file exists
|
||||||
if not SynthSection.get(bech_name + "_verilog"):
|
if not SynthSection.get(bech_name + "_verilog"):
|
||||||
|
@ -388,7 +413,10 @@ def generate_each_task_actions(taskname):
|
||||||
if benchmark_top_module_count.count(bench["top_module"]) > 1:
|
if benchmark_top_module_count.count(bench["top_module"]) > 1:
|
||||||
flow_run_dir = get_flow_rundir(
|
flow_run_dir = get_flow_rundir(
|
||||||
arch,
|
arch,
|
||||||
"bench" + str(benchmark_list.index(bench)) + "_" + bench["top_module"],
|
"bench"
|
||||||
|
+ str(benchmark_list.index(bench))
|
||||||
|
+ "_"
|
||||||
|
+ bench["top_module"],
|
||||||
lbl,
|
lbl,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -399,7 +427,7 @@ def generate_each_task_actions(taskname):
|
||||||
archfile=arch,
|
archfile=arch,
|
||||||
benchmark_obj=bench,
|
benchmark_obj=bench,
|
||||||
param=param,
|
param=param,
|
||||||
task_conf=task_conf
|
task_conf=task_conf,
|
||||||
)
|
)
|
||||||
command += ["--flow_config", curr_task_conf_file]
|
command += ["--flow_config", curr_task_conf_file]
|
||||||
flow_run_cmd_list.append(
|
flow_run_cmd_list.append(
|
||||||
|
@ -515,7 +543,14 @@ def create_run_command(curr_job_dir, archfile, benchmark_obj, param, task_conf):
|
||||||
def strip_child_logger_info(line):
|
def strip_child_logger_info(line):
|
||||||
try:
|
try:
|
||||||
logtype, message = line.split(" - ", 1)
|
logtype, message = line.split(" - ", 1)
|
||||||
lognumb = {"CRITICAL": 50, "ERROR": 40, "WARNING": 30, "INFO": 20, "DEBUG": 10, "NOTSET": 0}
|
lognumb = {
|
||||||
|
"CRITICAL": 50,
|
||||||
|
"ERROR": 40,
|
||||||
|
"WARNING": 30,
|
||||||
|
"INFO": 20,
|
||||||
|
"DEBUG": 10,
|
||||||
|
"NOTSET": 0,
|
||||||
|
}
|
||||||
logger.log(lognumb[logtype.strip().upper()], message)
|
logger.log(lognumb[logtype.strip().upper()], message)
|
||||||
except:
|
except:
|
||||||
logger.info(line)
|
logger.info(line)
|
||||||
|
@ -558,7 +593,11 @@ def run_single_script(s, eachJob, job_list):
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
eachJob["endtime"] = time.time()
|
eachJob["endtime"] = time.time()
|
||||||
timediff = timedelta(seconds=(eachJob["endtime"] - eachJob["starttime"]))
|
timediff = timedelta(seconds=(eachJob["endtime"] - eachJob["starttime"]))
|
||||||
timestr = humanize.naturaldelta(timediff) if "humanize" in sys.modules else str(timediff)
|
timestr = (
|
||||||
|
humanize.naturaldelta(timediff)
|
||||||
|
if "humanize" in sys.modules
|
||||||
|
else str(timediff)
|
||||||
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
"%s Finished with returncode %d, Time Taken %s ",
|
"%s Finished with returncode %d, Time Taken %s ",
|
||||||
thread_name,
|
thread_name,
|
||||||
|
@ -575,7 +614,9 @@ def run_actions(job_list):
|
||||||
thread_list = []
|
thread_list = []
|
||||||
for _, eachjob in enumerate(job_list):
|
for _, eachjob in enumerate(job_list):
|
||||||
t = threading.Thread(
|
t = threading.Thread(
|
||||||
target=run_single_script, name=eachjob["name"], args=(thread_sema, eachjob, job_list)
|
target=run_single_script,
|
||||||
|
name=eachjob["name"],
|
||||||
|
args=(thread_sema, eachjob, job_list),
|
||||||
)
|
)
|
||||||
t.start()
|
t.start()
|
||||||
thread_list.append(t)
|
thread_list.append(t)
|
||||||
|
@ -584,9 +625,9 @@ def run_actions(job_list):
|
||||||
|
|
||||||
|
|
||||||
def collect_results(job_run_list):
|
def collect_results(job_run_list):
|
||||||
'''
|
"""
|
||||||
Collect performance numbers from vpr_stat.result file
|
Collect performance numbers from vpr_stat.result file
|
||||||
'''
|
"""
|
||||||
task_result = []
|
task_result = []
|
||||||
for run in job_run_list:
|
for run in job_run_list:
|
||||||
if not run["status"]:
|
if not run["status"]:
|
||||||
|
@ -598,7 +639,9 @@ def collect_results(job_run_list):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Read and merge result file
|
# Read and merge result file
|
||||||
vpr_res = ConfigParser(allow_no_value=True, interpolation=ExtendedInterpolation())
|
vpr_res = ConfigParser(
|
||||||
|
allow_no_value=True, interpolation=ExtendedInterpolation()
|
||||||
|
)
|
||||||
vpr_result_file = os.path.join(run["run_dir"], "vpr_stat.result")
|
vpr_result_file = os.path.join(run["run_dir"], "vpr_stat.result")
|
||||||
vpr_res.read_file(open(vpr_result_file, encoding="UTF-8"))
|
vpr_res.read_file(open(vpr_result_file, encoding="UTF-8"))
|
||||||
result = OrderedDict()
|
result = OrderedDict()
|
||||||
|
@ -614,8 +657,11 @@ def collect_results(job_run_list):
|
||||||
colnames = sorted(list(set(colnames)))
|
colnames = sorted(list(set(colnames)))
|
||||||
if len(task_result) > 0:
|
if len(task_result) > 0:
|
||||||
with open("task_result.csv", "w", encoding="UTF-8", newline="") as csvfile:
|
with open("task_result.csv", "w", encoding="UTF-8", newline="") as csvfile:
|
||||||
writer = csv.DictWriter(csvfile, extrasaction="ignore",
|
writer = csv.DictWriter(
|
||||||
fieldnames=["name", "TotalRunTime"] + colnames)
|
csvfile,
|
||||||
|
extrasaction="ignore",
|
||||||
|
fieldnames=["name", "TotalRunTime"] + colnames,
|
||||||
|
)
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
for each in task_result:
|
for each in task_result:
|
||||||
writer.writerow(each)
|
writer.writerow(each)
|
||||||
|
|
Loading…
Reference in New Issue