From e4e4bb635650055a94112250b71c111096f1263e Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 19 Jun 2019 11:50:31 +0200 Subject: Makefile in test/monniaux that generates the compilation time graphs --- Asmblockdeps.patch | 20 -------- PostpassSchedulingOracle.patch | 33 ------------- test/monniaux/Asmblockdeps.patch | 20 ++++++++ test/monniaux/PostpassSchedulingOracle.patch | 33 +++++++++++++ test/monniaux/build_benches.sh | 15 ++++-- test/monniaux/gencompile.py | 70 +++++++++++----------------- 6 files changed, 90 insertions(+), 101 deletions(-) delete mode 100644 Asmblockdeps.patch delete mode 100644 PostpassSchedulingOracle.patch create mode 100644 test/monniaux/Asmblockdeps.patch create mode 100644 test/monniaux/PostpassSchedulingOracle.patch diff --git a/Asmblockdeps.patch b/Asmblockdeps.patch deleted file mode 100644 index a2d8c7be..00000000 --- a/Asmblockdeps.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- extraction/Asmblockdeps.ml 2019-06-13 15:06:55.493592984 +0200 -+++ Asmblockdeps.mod.ml 2019-06-13 15:04:55.900122958 +0200 -@@ -2243,5 +2243,15 @@ - - (** val bblock_simub : bblock -> bblock -> bool **) - --let bblock_simub = -- pure_bblock_simu_test true -+let bblock_simub bb tbb = -+ let nb_instructions = Camlcoq.Z.to_int64 @@ Asmvliw.size bb -+ in let start_time = (Gc.major(); (Unix.times ()).Unix.tms_utime) -+ in let simub = pure_bblock_simu_test true bb tbb -+ in let refer = ref false -+ in begin -+ for i = 1 to 1000-1 do -+ refer := (if i > 0 then pure_bblock_simu_test true bb tbb else false); (* dumb i > 0 test to lure warning 35 *) -+ done; -+ Printf.printf "%Ld: %f\n" nb_instructions ((Unix.times ()).Unix.tms_utime -. start_time); -+ simub -+ end diff --git a/PostpassSchedulingOracle.patch b/PostpassSchedulingOracle.patch deleted file mode 100644 index 71c44350..00000000 --- a/PostpassSchedulingOracle.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/mppa_k1c/PostpassSchedulingOracle.ml b/mppa_k1c/PostpassSchedulingOracle.ml -index 2fc561e..d3748e8 100644 ---- a/mppa_k1c/PostpassSchedulingOracle.ml -+++ b/mppa_k1c/PostpassSchedulingOracle.ml -@@ -829,7 +829,7 @@ let print_bb oc bb = - let asm_instructions = Asm.unfold_bblock bb - in List.iter (print_inst oc) asm_instructions - --let do_schedule bb = -+let real_do_schedule bb = - let problem = build_problem bb - in let solution = (if !Clflags.option_fpostpass_sched = "ilp" then - validated_scheduler cascaded_scheduler -@@ -850,6 +850,19 @@ let do_schedule bb = - end; - bundles) - -+let do_schedule bb = -+ let nb_instructions = Camlcoq.Z.to_int64 @@ Asmvliw.size bb -+ in let start_time = (Gc.major(); (Unix.times ()).Unix.tms_utime) -+ in let sched = real_do_schedule bb -+ in let refer = ref sched -+ in begin -+ for i = 1 to 100-1 do -+ refer := (if i > 0 then real_do_schedule bb else real_do_schedule bb); -+ done; -+ Printf.printf "%Ld: %f\n" nb_instructions ((Unix.times ()).Unix.tms_utime -. start_time); -+ sched -+ end -+ - (** - * Dumb schedule if the above doesn't work - *) diff --git a/test/monniaux/Asmblockdeps.patch b/test/monniaux/Asmblockdeps.patch new file mode 100644 index 00000000..a2d8c7be --- /dev/null +++ b/test/monniaux/Asmblockdeps.patch @@ -0,0 +1,20 @@ +--- extraction/Asmblockdeps.ml 2019-06-13 15:06:55.493592984 +0200 ++++ Asmblockdeps.mod.ml 2019-06-13 15:04:55.900122958 +0200 +@@ -2243,5 +2243,15 @@ + + (** val bblock_simub : bblock -> bblock -> bool **) + +-let bblock_simub = +- pure_bblock_simu_test true ++let bblock_simub bb tbb = ++ let nb_instructions = Camlcoq.Z.to_int64 @@ Asmvliw.size bb ++ in let start_time = (Gc.major(); (Unix.times ()).Unix.tms_utime) ++ in let simub = pure_bblock_simu_test true bb tbb ++ in let refer = ref false ++ in begin ++ for i = 1 to 1000-1 do ++ refer := (if i > 0 then pure_bblock_simu_test true bb tbb else false); (* dumb i > 0 test to lure warning 35 *) ++ done; ++ Printf.printf "%Ld: %f\n" nb_instructions ((Unix.times ()).Unix.tms_utime -. start_time); ++ simub ++ end diff --git a/test/monniaux/PostpassSchedulingOracle.patch b/test/monniaux/PostpassSchedulingOracle.patch new file mode 100644 index 00000000..71c44350 --- /dev/null +++ b/test/monniaux/PostpassSchedulingOracle.patch @@ -0,0 +1,33 @@ +diff --git a/mppa_k1c/PostpassSchedulingOracle.ml b/mppa_k1c/PostpassSchedulingOracle.ml +index 2fc561e..d3748e8 100644 +--- a/mppa_k1c/PostpassSchedulingOracle.ml ++++ b/mppa_k1c/PostpassSchedulingOracle.ml +@@ -829,7 +829,7 @@ let print_bb oc bb = + let asm_instructions = Asm.unfold_bblock bb + in List.iter (print_inst oc) asm_instructions + +-let do_schedule bb = ++let real_do_schedule bb = + let problem = build_problem bb + in let solution = (if !Clflags.option_fpostpass_sched = "ilp" then + validated_scheduler cascaded_scheduler +@@ -850,6 +850,19 @@ let do_schedule bb = + end; + bundles) + ++let do_schedule bb = ++ let nb_instructions = Camlcoq.Z.to_int64 @@ Asmvliw.size bb ++ in let start_time = (Gc.major(); (Unix.times ()).Unix.tms_utime) ++ in let sched = real_do_schedule bb ++ in let refer = ref sched ++ in begin ++ for i = 1 to 100-1 do ++ refer := (if i > 0 then real_do_schedule bb else real_do_schedule bb); ++ done; ++ Printf.printf "%Ld: %f\n" nb_instructions ((Unix.times ()).Unix.tms_utime -. start_time); ++ sched ++ end ++ + (** + * Dumb schedule if the above doesn't work + *) diff --git a/test/monniaux/build_benches.sh b/test/monniaux/build_benches.sh index 123f4c82..a8f1b1a5 100755 --- a/test/monniaux/build_benches.sh +++ b/test/monniaux/build_benches.sh @@ -1,3 +1,5 @@ +#!/usr/bin/bash + TMPFILE=/tmp/1513times.txt source benches.sh @@ -5,9 +7,14 @@ source benches.sh rm -f commands.txt rm -f $TMPFILE for bench in $benches; do - #echo "(cd $bench && make -j5 $1)" >> commands.txt - (cd $bench && make -j20 $1) | grep -P "\d+: \d+\.\d+" >> $TMPFILE + if [ "$1" == "" ]; then + (cd $bench && make -j20) + else + (cd $bench && make -j20) | grep -P "\d+: \d+\.\d+" >> $TMPFILE + fi done -cat $TMPFILE | sort -n -k 1 > compile_times.txt -#cat commands.txt | xargs -n1 -I{} -P4 bash -c '{}' +if [ "$1" != "" ]; then + cat $TMPFILE | sort -n -k 1 > $1 +fi + diff --git a/test/monniaux/gencompile.py b/test/monniaux/gencompile.py index faa7bdd8..789bd4fa 100755 --- a/test/monniaux/gencompile.py +++ b/test/monniaux/gencompile.py @@ -9,58 +9,40 @@ from typing import * # Reading data ## -if len(sys.argv) != 2: - raise Exception("Only 1 argument should be given to this script: the file with the compile times") -data_file = sys.argv[1] +if len(sys.argv) != 4: + raise Exception("Three arguments are expected: the verifier times, the oracle times, and the output PDF") +_, verifier_file, oracle_file, output_file = sys.argv -coords: List[Tuple[int, float]] = [] -with open(data_file, "r") as f: - for line in f: - nb_inst_s, time_s = line.split(":") - coords.append((int(nb_inst_s), float(time_s))) +def get_coords(filename: str) -> List[Tuple[int, float]]: + coords = [] + with open(filename, "r") as f: + for line in f: + nb_inst_s, time_s = line.split(":") + coords.append((int(nb_inst_s), float(time_s))) + return coords + +verifier_coords = get_coords(verifier_file) +oracle_coords = get_coords(oracle_file) ## # Generating PDF ## fig, ax = plt.subplots() -x = [coord[0] for coord in coords] -y = [coord[1] for coord in coords] -plt.plot(x, y, "b+") -ax.set_ylabel("Time x1000 (s)") -ax.set_title("Verification time") -ax.set_xlabel("Size of basic blocks") +def do_plot(coords: List[Tuple[int, float]], style: str, label: str): + x = [coord[0] for coord in coords] + y = [coord[1] for coord in coords] + plt.plot(x, y, style, label=label) -plt.savefig("compile-times.pdf") +plt.xscale("log") +plt.yscale("log") +do_plot(verifier_coords, "b+", "Verifier") +do_plot(oracle_coords, "g+", "Oracle") +ax.set_ylabel("Time x1000 (s)") +ax.set_title("Compilation time") +ax.set_xlabel("Size of basic blocks") +ax.legend() -#def generate_file(f: str, cols: List[str]) -> None: -# ind = np.arange(len(df[cols[0]])) -# -# width = 0.25 # the width of the bars -# -# compilers = extract_compilers(cols) -# start_inds = subdivide_interv(ind, ind+2*width, len(compilers)) -# heights: Dict[str, List[float]] = make_relative_heights(df, cols) -# -# fig, ax = plt.subplots() -# rects = [] -# for i, compiler in enumerate(compilers): -# rects.append(ax.bar(start_inds[i], heights[compiler], width, color=colors[i], label=compiler)) -# -# # Add some text for labels, title and custom x-axis tick labels, etc. -# ax.set_ylabel('Cycles (%)') -# ax.set_yticklabels(['{:,.0%}'.format(x) for x in ax.get_yticks()]) -# ax.set_title('TITLE') -# ax.set_xticks(ind) -# ax.set_xticklabels(benches) -# ax.legend() -# -# plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right') -# plt.xticks(size=5) -# -# plt.savefig(f) -# -#generate_file("measures-host.pdf", host_measures_cols) -#generate_file("measures-k1c.pdf", k1c_measures_cols) +plt.savefig(output_file) -- cgit