From c765b364be859d7c8aa0448ead146098a9c5060a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 18 Jun 2024 13:52:07 +0200 Subject: [PATCH 1/3] add script to check for changes in complexity job output --- .../check_for_changes.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 ci/complexity_measurements/check_for_changes.py diff --git a/ci/complexity_measurements/check_for_changes.py b/ci/complexity_measurements/check_for_changes.py new file mode 100644 index 0000000000..50ddde2212 --- /dev/null +++ b/ci/complexity_measurements/check_for_changes.py @@ -0,0 +1,76 @@ +import argparse +import csv +import sys +import numpy as np + + +THRESH = 0.01 +COLS = [ + [3, 5, 7, 9], # wmops_all + [3,5,7,8,10,12,13,15,17], # ram_all + [3,5,7,9,11,13,15,17,19], # rom_all +] + + +def main(args): + linewise_logfiles = [args.wmops_logfile, args.ram_logfile, args.rom_logfile] + changes_found_linewise = any([check_linewise_logfile(f, c) for f, c in zip(linewise_logfiles, COLS)]) + + per_op_logfiles = [(args.per_op_wmops_logfile_curr, args.per_op_wmops_logfile_prev), (args.per_op_ram_logfile_curr, args.per_op_ram_logfile_prev), (args.per_op_rom_logfile_curr, args.per_op_rom_logfile_prev)] + changes_found_per_op = any([compare_per_operating_point_logfiles(c, p) for c, p in per_op_logfiles]) + + if changes_found_linewise: + print("Global max of WMOPS, RAM or ROM changed") + + if changes_found_per_op: + print("Some other operating point changed") + + return int(changes_found_linewise or changes_found_per_op) + + +def check_linewise_logfile(filepath, cols): + with open(filepath) as f: + contents = [line for line in csv.reader(f, delimiter=" ")] + + curr = contents[-1] + prev = contents[-2] + + change_ratios = [abs(float(curr[i]) / float(prev[i]) - 1) > THRESH for i in cols] + changes_found = any(change_ratios) + + return changes_found + + +def compare_per_operating_point_logfiles(file_curr, file_prev): + + dtypes = [("mode", None), ("enc", float), ("dec", float), ("total", float)] + curr = np.genfromtxt(file_curr, delim=";", dtype=None, skip_header=1) + prev = np.genfromtxt(file_prev, delim=";", dtype=None, skip_header=1) + + columns = [d[0] for d in dtypes] + curr_sorted = np.sort(curr, axis=0, order=columns) + prev_sorted = np.sort(prev, axis=0, order=columns) + + changes_found = False + for col in columns: + diff = np.abs(curr_sorted[col] / prev_sorted[col] - 1) + if np.any(diff > THRESH): + changes_found = True + + return changes_found + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("wmops_logfile") + parser.add_argument("ram_logfile") + parser.add_argument("rom_logfile") + parser.add_argument("per_op_wmops_logfile_curr") + parser.add_argument("per_op_wmops_logfile_prev") + parser.add_argument("per_op_ram_logfile_curr") + parser.add_argument("per_op_ram_logfile_prev") + parser.add_argument("per_op_rom_logfile_curr") + parser.add_argument("per_op_rom_logfile_prev") + args = parser.parse_args() + + sys.exit(main(args)) -- GitLab From def75eb763d4402bd04ae92e4613c5f3c9f2b61a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 18 Jun 2024 13:52:51 +0200 Subject: [PATCH 2/3] remove stuff per operating point as not useful --- .../check_for_changes.py | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/ci/complexity_measurements/check_for_changes.py b/ci/complexity_measurements/check_for_changes.py index 50ddde2212..f43396260f 100644 --- a/ci/complexity_measurements/check_for_changes.py +++ b/ci/complexity_measurements/check_for_changes.py @@ -16,16 +16,10 @@ def main(args): linewise_logfiles = [args.wmops_logfile, args.ram_logfile, args.rom_logfile] changes_found_linewise = any([check_linewise_logfile(f, c) for f, c in zip(linewise_logfiles, COLS)]) - per_op_logfiles = [(args.per_op_wmops_logfile_curr, args.per_op_wmops_logfile_prev), (args.per_op_ram_logfile_curr, args.per_op_ram_logfile_prev), (args.per_op_rom_logfile_curr, args.per_op_rom_logfile_prev)] - changes_found_per_op = any([compare_per_operating_point_logfiles(c, p) for c, p in per_op_logfiles]) - if changes_found_linewise: print("Global max of WMOPS, RAM or ROM changed") - if changes_found_per_op: - print("Some other operating point changed") - - return int(changes_found_linewise or changes_found_per_op) + return int(changes_found_linewise) def check_linewise_logfile(filepath, cols): @@ -41,36 +35,11 @@ def check_linewise_logfile(filepath, cols): return changes_found -def compare_per_operating_point_logfiles(file_curr, file_prev): - - dtypes = [("mode", None), ("enc", float), ("dec", float), ("total", float)] - curr = np.genfromtxt(file_curr, delim=";", dtype=None, skip_header=1) - prev = np.genfromtxt(file_prev, delim=";", dtype=None, skip_header=1) - - columns = [d[0] for d in dtypes] - curr_sorted = np.sort(curr, axis=0, order=columns) - prev_sorted = np.sort(prev, axis=0, order=columns) - - changes_found = False - for col in columns: - diff = np.abs(curr_sorted[col] / prev_sorted[col] - 1) - if np.any(diff > THRESH): - changes_found = True - - return changes_found - - if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("wmops_logfile") parser.add_argument("ram_logfile") parser.add_argument("rom_logfile") - parser.add_argument("per_op_wmops_logfile_curr") - parser.add_argument("per_op_wmops_logfile_prev") - parser.add_argument("per_op_ram_logfile_curr") - parser.add_argument("per_op_ram_logfile_prev") - parser.add_argument("per_op_rom_logfile_curr") - parser.add_argument("per_op_rom_logfile_prev") args = parser.parse_args() sys.exit(main(args)) -- GitLab From 65f4c2d584197e473e8687a35ab1156c7a78e502 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 18 Jun 2024 14:06:13 +0200 Subject: [PATCH 3/3] add check for changes into getWmops.sh --- ci/complexity_measurements/getWmops.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ci/complexity_measurements/getWmops.sh b/ci/complexity_measurements/getWmops.sh index 22ca8335fb..c069e2d57b 100755 --- a/ci/complexity_measurements/getWmops.sh +++ b/ci/complexity_measurements/getWmops.sh @@ -86,4 +86,9 @@ ${scriptDir}/parseNewsletterRom.py ${wmopsFilenameFlc}_PROM.csv ${wmopsFilenameF # generate java script from database tcsh ${scriptDir}/genWebpageData_Rom.csh ${destDir}/wmops/log_rom_all.txt ${destDir}/wmops/graphs_rom_flc.js Graphs_ROM -exit $ret_val \ No newline at end of file +python3 ${scriptDir}/check_for_changes.py ${destDir}/wmops/log_wmops_all.txt ${destDir}/wmops/log_ram_all.txt ${destDir}/wmops/log_rom_all.txt +if [ "$?" != "0" ]; then + ret_val=1 +fi + +exit $ret_val -- GitLab