From f9e66e1bae4e3b16c452e5bea20d1c793e9b94b1 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 21 Jun 2021 15:27:12 -0600 Subject: [PATCH 1/2] [Script] Support benchmarks with same top module names in openfpga flow script; Now each benchmark local run directory has a unique name; --- openfpga_flow/scripts/run_fpga_task.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openfpga_flow/scripts/run_fpga_task.py b/openfpga_flow/scripts/run_fpga_task.py index 5663cc55c..7855a54fd 100644 --- a/openfpga_flow/scripts/run_fpga_task.py +++ b/openfpga_flow/scripts/run_fpga_task.py @@ -309,7 +309,7 @@ def generate_each_task_actions(taskname): for indx, arch in enumerate(archfile_list): for bench in benchmark_list: for lbl, param in bench["script_params"].items(): - flow_run_dir = get_flow_rundir(arch, bench["top_module"], lbl) + flow_run_dir = get_flow_rundir(arch, benchmark_list.index(bench), bench["top_module"], lbl) command = create_run_command( curr_job_dir=flow_run_dir, archfile=arch, @@ -330,11 +330,12 @@ def generate_each_task_actions(taskname): logger.info('Created total %d jobs' % len(flow_run_cmd_list)) return flow_run_cmd_list - -def get_flow_rundir(arch, top_module, flow_params=None): +# Make the directory name unique by including the benchmark index in the list. +# This is because benchmarks may share the same top module names +def get_flow_rundir(arch, bench_index, top_module, flow_params=None): path = [ os.path.basename(arch).replace(".xml", ""), - top_module, + "bench" + str(bench_index) + "_" + top_module, flow_params if flow_params else "common" ] return os.path.abspath(os.path.join(*path)) From fd580bb36f8b7ad5d326a86f269b14f5560d9c92 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 22 Jun 2021 11:45:23 -0600 Subject: [PATCH 2/2] [Script] Update script to keep back compatibility: local run directory is different only for those benchmarks sharing the same top module name --- openfpga_flow/scripts/run_fpga_task.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/openfpga_flow/scripts/run_fpga_task.py b/openfpga_flow/scripts/run_fpga_task.py index 7855a54fd..0cb6612e1 100644 --- a/openfpga_flow/scripts/run_fpga_task.py +++ b/openfpga_flow/scripts/run_fpga_task.py @@ -302,6 +302,13 @@ def generate_each_task_actions(taskname): benchmark_list.append(CurrBenchPara) + # Count the number of duplicated top module name among benchmark + # This is required as flow run directory names for these benchmarks are different than others + # which are uniquified + benchmark_top_module_count = [] + for bench in benchmark_list: + benchmark_top_module_count.append(bench["top_module"]) + # Create OpenFPGA flow run commnad for each combination of # architecture, benchmark and parameters # Create run_job object [arch, bench, run_dir, commnad] @@ -309,7 +316,11 @@ def generate_each_task_actions(taskname): for indx, arch in enumerate(archfile_list): for bench in benchmark_list: for lbl, param in bench["script_params"].items(): - flow_run_dir = get_flow_rundir(arch, benchmark_list.index(bench), bench["top_module"], lbl) + if (benchmark_top_module_count.count(bench["top_module"]) > 1): + flow_run_dir = get_flow_rundir(arch, "bench" + str(benchmark_list.index(bench)) + "_" + bench["top_module"], lbl) + else: + flow_run_dir = get_flow_rundir(arch, bench["top_module"], lbl) + command = create_run_command( curr_job_dir=flow_run_dir, archfile=arch, @@ -332,10 +343,10 @@ def generate_each_task_actions(taskname): # Make the directory name unique by including the benchmark index in the list. # This is because benchmarks may share the same top module names -def get_flow_rundir(arch, bench_index, top_module, flow_params=None): +def get_flow_rundir(arch, top_module, flow_params=None): path = [ os.path.basename(arch).replace(".xml", ""), - "bench" + str(bench_index) + "_" + top_module, + top_module, flow_params if flow_params else "common" ] return os.path.abspath(os.path.join(*path))