Skip to content

Fixing the generated vtr_flow.sh scripts #1733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dev/pylint_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@


class TermColor:
""" Terminal codes for printing in color """
"""Terminal codes for printing in color"""

# pylint: disable=too-few-public-methods

Expand All @@ -105,14 +105,14 @@ class TermColor:


def error(*msg, returncode=-1):
""" Print an error message and exit program """
"""Print an error message and exit program"""

print(TermColor.RED + "ERROR:", " ".join(str(item) for item in msg), TermColor.END)
sys.exit(returncode)


def expand_paths():
""" Build a list of all python files to process by going through 'paths_to_lint' """
"""Build a list of all python files to process by going through 'paths_to_lint'"""

paths = []
for (path, is_recursive) in paths_to_lint:
Expand Down
12 changes: 6 additions & 6 deletions run_reg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


def vtr_command_argparser(prog=None):
""" Parses the arguments of run_reg_test """
"""Parses the arguments of run_reg_test"""

description = textwrap.dedent(
"""
Expand Down Expand Up @@ -205,7 +205,7 @@ def vtr_command_main(arg_list, prog=None):


def display_qor(reg_test):
""" Display the qor tests script files to be run outside of this script """
"""Display the qor tests script files to be run outside of this script"""
test_dir = paths.regression_tests_path / reg_test
if not (test_dir / "qor_geomean.txt").is_file():
print("QoR results do not exist ({}/qor_geomean.txt)".format(str(test_dir)))
Expand Down Expand Up @@ -250,7 +250,7 @@ def display_qor(reg_test):


def run_odin_test(args, test_name):
""" Run ODIN II test with given test name """
"""Run ODIN II test with given test name"""
odin_reg_script = [
str(paths.odin_verify_path),
"--clean",
Expand Down Expand Up @@ -294,7 +294,7 @@ def run_odin_test(args, test_name):


def collect_task_list(reg_test):
""" create a list of task files """
"""create a list of task files"""
task_list_filepath = paths.tasks_path / "regression_tests" / reg_test / "task_list.txt"
if not task_list_filepath.is_file():
raise IOError("Test does not exist: {}".format(reg_test))
Expand All @@ -316,7 +316,7 @@ def run_tasks(args, task_lists):


def parse_single_test(task_lists, check=True, calculate=True, create=False):
""" parse the test results """
"""parse the test results"""
vtr_task_cmd = ["-l"] + [task_lists]
if check:
vtr_task_cmd += ["-check_golden"]
Expand All @@ -330,7 +330,7 @@ def parse_single_test(task_lists, check=True, calculate=True, create=False):


def print_header(heading, divider="=", print_first_line=True):
""" Print heading formated in the center of two lines """
"""Print heading formated in the center of two lines"""
if print_first_line:
print(divider * len(heading) * 2)
print(" " * int((len(heading) / 2)), end="")
Expand Down
4 changes: 2 additions & 2 deletions vtr_flow/scripts/flow_script_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ VTR_MEMORY_ESTIMATE_HUMAN_READABLE="{human_readable_memory}"

#The IO redirection occurs in a sub-shell,
#so we need to exit it with the correct code
exit \$?
exit $?

}} |& tee vtr_flow.out
#End I/O redirection
Expand All @@ -24,4 +24,4 @@ VTR_MEMORY_ESTIMATE_HUMAN_READABLE="{human_readable_memory}"
#To get the correct exit status we need to exit with the
#status of the first element in the pipeline (i.e. the real
#command run above)
exit \${{PIPESTATUS[0]}}
exit ${{PIPESTATUS[0]}}
46 changes: 23 additions & 23 deletions vtr_flow/scripts/python_libs/vtr/log_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class ParsePattern:
""" Pattern for parsing log files """
"""Pattern for parsing log files"""

def __init__(self, name, filename, regex_str, default_value=None):
self._name = name
Expand All @@ -27,44 +27,44 @@ def __init__(self, name, filename, regex_str, default_value=None):
self._default_value = default_value

def name(self):
""" Return name of what is being parsed for """
"""Return name of what is being parsed for"""
return self._name

def filename(self):
""" Log filename to parse """
"""Log filename to parse"""
return self._filename

def regex(self):
""" Regex expression to use for parsing """
"""Regex expression to use for parsing"""
return self._regex

def default_value(self):
""" Return the default parse value """
"""Return the default parse value"""
return self._default_value


class PassRequirement(abc.ABC):
""" Used to check if a parsed value passes an expression """
"""Used to check if a parsed value passes an expression"""

def __init__(self, metric):
self._metric = metric
self._type = type

def metric(self):
""" Return pass matric """
"""Return pass matric"""
return self._metric

@abc.abstractmethod
def type(self):
""" Return the type of requirement checking """
"""Return the type of requirement checking"""

@abc.abstractmethod
def check_passed(self, golden_value, check_value, check_string="golden value"):
""" Return whether the check passed """
"""Return whether the check passed"""


class EqualPassRequirement(PassRequirement):
""" Used to check if parsed value is equal to golden value """
"""Used to check if parsed value is equal to golden value"""

def type(self):
return "Equal"
Expand All @@ -82,7 +82,7 @@ def check_passed(self, golden_value, check_value, check_string="golden value"):


class RangePassRequirement(PassRequirement):
""" Used to check if parsed value is within a range """
"""Used to check if parsed value is within a range"""

def __init__(self, metric, min_value=None, max_value=None):
super().__init__(metric)
Expand All @@ -97,15 +97,15 @@ def type(self):
return "Range"

def min_value(self):
""" Get min value of golden range """
"""Get min value of golden range"""
return self._min_value

def max_value(self):
""" Get max value of golden range """
"""Get max value of golden range"""
return self._max_value

def check_passed(self, golden_value, check_value, check_string="golden value"):
""" Check if parsed value is within a range or equal to golden value """
"""Check if parsed value is within a range or equal to golden value"""

if golden_value is None or check_value is None:
if golden_value is None and check_value is None:
Expand Down Expand Up @@ -165,7 +165,7 @@ def check_passed(self, golden_value, check_value, check_string="golden value"):


class RangeAbsPassRequirement(PassRequirement):
""" Check if value is in some relative ratio range, or below some absolute value """
"""Check if value is in some relative ratio range, or below some absolute value"""

def __init__(self, metric, min_value=None, max_value=None, abs_threshold=None):
super().__init__(metric)
Expand All @@ -178,19 +178,19 @@ def __init__(self, metric, min_value=None, max_value=None, abs_threshold=None):
self._abs_threshold = abs_threshold

def type(self):
""" Return requirement type """
"""Return requirement type"""
return "Range"

def min_value(self):
""" Return min value of ratio range """
"""Return min value of ratio range"""
return self._min_value

def max_value(self):
""" Return max value of ratio range """
"""Return max value of ratio range"""
return self._max_value

def abs_threshold(self):
""" Get absolute threshold """
"""Get absolute threshold"""
return self._abs_threshold

def check_passed(self, golden_value, check_value, check_string="golden value"):
Expand Down Expand Up @@ -267,27 +267,27 @@ def check_passed(self, golden_value, check_value, check_string="golden value"):


class ParseResults:
""" This class contains all parse results and metrics """
"""This class contains all parse results and metrics"""

PRIMARY_KEYS = ("architecture", "circuit", "script_params")

def __init__(self):
self._metrics = OrderedDict()

def add_result(self, arch, circuit, parse_result, script_param=None):
""" Add new parse result for given arch/circuit pair """
"""Add new parse result for given arch/circuit pair"""
script_param = load_script_param(script_param)
self._metrics[(arch, circuit, script_param)] = parse_result

def metrics(self, arch, circuit, script_param=None):
""" Return individual metric based on the architechure, circuit and script"""
"""Return individual metric based on the architechure, circuit and script"""
script_param = load_script_param(script_param)
if (arch, circuit, script_param) in self._metrics:
return self._metrics[(arch, circuit, script_param)]
return None

def all_metrics(self):
""" Return all metric results """
"""Return all metric results"""
return self._metrics


Expand Down
16 changes: 8 additions & 8 deletions vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def parse_task(config, config_jobs, flow_metrics_basename=FIRST_PARSE_FILE):


def parse_files(config_jobs, run_dir, flow_metrics_basename=FIRST_PARSE_FILE):
""" Parse the result files from the give jobs """
"""Parse the result files from the give jobs"""
task_parse_results_filepath = str(PurePath(run_dir) / flow_metrics_basename)
with open(task_parse_results_filepath, "w") as out_f:

Expand Down Expand Up @@ -262,7 +262,7 @@ def parse_files(config_jobs, run_dir, flow_metrics_basename=FIRST_PARSE_FILE):


def create_golden_results_for_tasks(configs):
""" Runs create_golden_results_for_task on all of the give configuration """
"""Runs create_golden_results_for_task on all of the give configuration"""

for config in configs:
create_golden_results_for_task(config)
Expand All @@ -281,7 +281,7 @@ def create_golden_results_for_task(config):


def check_golden_results_for_tasks(configs):
""" runs check_golden_results_for_task on all the input configurations """
"""runs check_golden_results_for_task on all the input configurations"""
num_qor_failures = 0

print("\nCalculating QoR results...")
Expand Down Expand Up @@ -347,7 +347,7 @@ def check_two_files(
first_name="task",
second_name="golden",
):
""" Compare two files results """
"""Compare two files results"""
first_results = load_parse_results(first_results_filepath)
second_results = load_parse_results(second_results_filepath)
# Verify that the architecture and circuit are specified
Expand Down Expand Up @@ -461,7 +461,7 @@ def check_two_files(


def summarize_qor(configs):
""" Summarize the Qor results """
"""Summarize the Qor results"""

first = True
task_path = Path(configs[0].config_dir).parent
Expand All @@ -483,7 +483,7 @@ def summarize_qor(configs):


def calc_geomean(args, configs):
""" caclulate and ouput the geomean values to the geomean file """
"""caclulate and ouput the geomean values to the geomean file"""
first = False
task_path = Path(configs[0].config_dir).parent
if len(configs) > 1 or (task_path.parent / "task_list.txt").is_file():
Expand Down Expand Up @@ -533,7 +533,7 @@ def calc_geomean(args, configs):


def calculate_individual_geo_mean(lines, index, geo_mean, num):
""" Calculate an individual line of parse results goe_mean """
"""Calculate an individual line of parse results goe_mean"""
previous_value = None
for line in lines:
line = line.split("\t")[4:]
Expand All @@ -551,7 +551,7 @@ def calculate_individual_geo_mean(lines, index, geo_mean, num):


def find_latest_run_dir(config):
""" Find the latest run directory for given configuration """
"""Find the latest run directory for given configuration"""
task_dir = find_task_dir(config)

run_dir = get_latest_run_dir(task_dir)
Expand Down
25 changes: 3 additions & 22 deletions vtr_flow/scripts/python_libs/vtr/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def find_longest_task_description(configs):


# pylint: disable=too-many-branches
def create_jobs(args, configs, longest_name=0, longest_arch_circuit=0, after_run=False):
def create_jobs(args, configs, after_run=False):
"""
Create the jobs to be executed depending on the configs.
"""
Expand Down Expand Up @@ -409,8 +409,6 @@ def create_jobs(args, configs, longest_name=0, longest_arch_circuit=0, after_run
qor_parse_command,
work_dir,
run_dir,
longest_name,
longest_arch_circuit,
golden_results,
)
)
Expand All @@ -428,8 +426,6 @@ def create_jobs(args, configs, longest_name=0, longest_arch_circuit=0, after_run
qor_parse_command,
work_dir,
run_dir,
longest_name,
longest_arch_circuit,
golden_results,
)
)
Expand All @@ -449,8 +445,6 @@ def create_job(
qor_parse_command,
work_dir,
run_dir,
longest_name,
longest_arch_circuit,
golden_results,
):
"""
Expand All @@ -459,21 +453,7 @@ def create_job(
param_string = "common" + (("_" + param.replace(" ", "_")) if param else "")
if not param:
param = "common"
# determine spacing for nice output
num_spaces_before = int((longest_name - len(config.task_name))) + 8
num_spaces_after = int((longest_arch_circuit - len(work_dir + "/{}".format(param_string))))
cmd += [
"-name",
"{}:{}{}/{}{}".format(
config.task_name,
" " * num_spaces_before,
work_dir,
param_string,
" " * num_spaces_after,
),
]

cmd += ["-temp_dir", run_dir + "/{}".format(param_string)]

expected_min_w = ret_expected_min_w(circuit, arch, golden_results, param)
expected_min_w = (
int(expected_min_w * args.minw_hint_factor)
Expand Down Expand Up @@ -514,6 +494,7 @@ def create_job(
]
current_qor_parse_command.insert(0, run_dir + "/{}".format(load_script_param(param)))
current_cmd = cmd.copy()
current_cmd += ["-temp_dir", run_dir + "/{}".format(param_string)]
if param_string != "common":
current_cmd += param.split(" ")
return Job(
Expand Down
2 changes: 1 addition & 1 deletion vtr_flow/scripts/python_libs/vtr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def check_cmd(command):


def pretty_print_table(file, border=False):
""" Convert file to a pretty, easily read table """
"""Convert file to a pretty, easily read table"""
table = PrettyTable()
table.border = border
reader = None
Expand Down
Loading