From bb76227aaea6ba99b3512ffbd228e699c87beb9e Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 9 Mar 2021 19:08:58 -0500 Subject: Analysis Scripts: Cleanup computeSMTslowdown.py and libSMT.py - Don't print superfluous data - Remove some commented-out code - Print summary statistics in a format more similar to that used in the paper - Automatically strip the `_all` postfix from the paired benchmarks --- smt_analysis/computeSMTslowdown.py | 13 +++++++++---- smt_analysis/libSMT.py | 18 +++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'smt_analysis') diff --git a/smt_analysis/computeSMTslowdown.py b/smt_analysis/computeSMTslowdown.py index 805def1..ba9fa84 100755 --- a/smt_analysis/computeSMTslowdown.py +++ b/smt_analysis/computeSMTslowdown.py @@ -34,8 +34,8 @@ OK_PAIRS_ONLY = len(sys.argv) > 4 and "--cij-ok" in sys.argv[4] if not LEVEL_C_ANALYSIS: baseline_times, baseline_sample_cnt, baseline_max_times = load_baseline(sys.argv[3]) paired_times, paired_offsets, name_to_idx, idx_to_name = load_paired(sys.argv[1], sys.argv[2], len(list(baseline_times.keys()))) - for key in baseline_times: - print(key,max(baseline_times[key])) +# for key in baseline_times: +# print(key,max(baseline_times[key])) else: # Paired times use an abuse of the baseline file format baseline_times, baseline_sample_cnt, baseline_max_times = load_baseline(sys.argv[2]) @@ -94,18 +94,23 @@ for b1 in reliableNames: print("{:>10.3}".format(M), end=" ") print("") # Print some statistics about the distribution -print("Average: {:>5.3} with standard deviation {:>5.3} using `{}`".format(np.mean(M_vals), np.std(M_vals), sample_f.__name__)) +print("Overall average is {:>5.3} with standard deviation {:>5.3} using `{}`".format(np.mean(M_vals), np.std(M_vals), sample_f.__name__)) Ms = np.asarray(M_vals, dtype=np.float32) if not LEVEL_C_ANALYSIS: print(np.sum(Ms <= 0), "of", len(M_vals), "M_i:j values are at most zero -", 100*np.sum(Ms <= 0)/len(M_vals), "percent") print(np.sum(Ms > 1), "of", len(M_vals), "M_i:j values are greater than one -", 100*np.sum(Ms > 1)/len(M_vals), "percent") M_vals_to_plot = Ms[np.logical_and(Ms > 0, Ms <= 1)] + # Sims' analysis + mean = np.mean(list(M_vals_to_plot)) + std = np.std(list(M_vals_to_plot)) + print("For {} of {} M_i:j values in (0, 1], average: {:>5.3} with std. dev. {:>4.3} (coeff. var. {:>4.3}) using `{}`".format(len(M_vals_to_plot), len(M_vals), mean, std, std/mean, sample_f.__name__)) else: print(np.sum(Ms <= 1), "of", len(M_vals), "M_i:j values are at most one -", 100*np.sum(Ms <= 1)/len(M_vals), "percent") print(np.sum(Ms > 2), "of", len(M_vals), "M_i:j values are greater than two -", 100*np.sum(Ms > 2)/len(M_vals), "percent") M_vals_to_plot = Ms + # Sims' analysis + print("For {} of {} M_i:j values in (1, 2], average: {:>5.3} with std. dev. {:>4.3} (coeff. var. {:>4.3}) using `{}`".format(len(M_vals_to_plot), len(M_vals), np.mean(list(M_vals_to_plot)), np.std(list(M_vals_to_plot)), np.mean(list(M_vals_to_plot))/np.std(list(M_vals_to_plot)), sample_f.__name__)) -print("Using Sim's analysis, average: {:>5.3} with standard deviation {:>5.3} using `{}`".format(np.mean(list(M_vals_to_plot)), np.std(list(M_vals_to_plot)), sample_f.__name__)) print(plt.hist(M_vals_to_plot, bins=10)) ##### BELOW TEXT IS OLD OFFSET CODE (patched) ##### diff --git a/smt_analysis/libSMT.py b/smt_analysis/libSMT.py index cca2fce..c0b5178 100755 --- a/smt_analysis/libSMT.py +++ b/smt_analysis/libSMT.py @@ -38,6 +38,14 @@ def load_baseline(f): max_res[s[BENCH_NAME]] = max(int(s[TOTAL_NS]), max_res[s[BENCH_NAME]]) return res, samples, max_res +# Remove the _all prefix if it exists and return the result +# @param pair_name Name to strip (eg. pointer_all) +# @returns Stripped name (eg. pointer) +def strip_pair_postfix(pair_name): + if pair_name[-4:] == "_all": + return pair_name[:-4] + return pair_name + # This parses the result data from paired, threaded timing experiements # @param file1 The -A file name # @param file2 The -B file name @@ -93,12 +101,8 @@ def load_paired(file1, file2, benchmarkCount): end2 = int(lineArr2[END_S]) * 10**9 + int(lineArr2[END_N]) maxEnd = max(end1, end2) # Time actually co-scheduled is minEnd - maxStart, but Sims uses a different model -# time[bench1][bench2][int(lineArr1[JOB_NUM])] = maxEnd - minStart time[bench1][bench2][job_idx] = maxEnd - minStart - if lineArr1[SECOND_PROG] == "h264_dec" and lineArr2[JOB_NUM] == 0: - print(maxEnd - minStart) # Compute offset: if first job starts at t=0, when does second start? -# offset[bench1][bench2][int(lineArr1[JOB_NUM])] = abs(start2-start1) offset[bench1][bench2][job_idx] = abs(start2-start1) # Compute some running statistics avg_off += abs(start2-start1) @@ -110,14 +114,14 @@ def load_paired(file1, file2, benchmarkCount): bench2 = bench2 + 1 job_idx = 0 else: - name_to_idx[lineArr1[FIRST_PROG]] = bench1 - idx_to_name[bench1] = lineArr1[FIRST_PROG] + name_to_idx[strip_pair_postfix(lineArr1[FIRST_PROG])] = bench1 + idx_to_name[bench1] = strip_pair_postfix(lineArr1[FIRST_PROG]) bench1 = bench1 + 1 bench2 = bench1 # bench1 will never again appear as bench2 job_idx = 0 else: job_idx += 1 - print("Average offset is: " + str(avg_off/avg_off_samp) + "ns") + print("Average offset is: {:.2f} nanoseconds".format(avg_off/avg_off_samp)) return time, offset, name_to_idx, idx_to_name # Paired times use an abuse of the baseline file format -- cgit v1.2.2