summaryrefslogtreecommitdiffstats
path: root/smt_analysis
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2021-03-09 19:08:58 -0500
committerJoshua Bakita <jbakita@cs.unc.edu>2021-03-09 19:08:58 -0500
commitbb76227aaea6ba99b3512ffbd228e699c87beb9e (patch)
tree530a624363e30ec32674dcc64ebccfc4f65be5d8 /smt_analysis
parent9ec5cb49c42833360db60806e2a3571f69a858b4 (diff)
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
Diffstat (limited to 'smt_analysis')
-rwxr-xr-xsmt_analysis/computeSMTslowdown.py13
-rwxr-xr-xsmt_analysis/libSMT.py18
2 files changed, 20 insertions, 11 deletions
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]
34if not LEVEL_C_ANALYSIS: 34if not LEVEL_C_ANALYSIS:
35 baseline_times, baseline_sample_cnt, baseline_max_times = load_baseline(sys.argv[3]) 35 baseline_times, baseline_sample_cnt, baseline_max_times = load_baseline(sys.argv[3])
36 paired_times, paired_offsets, name_to_idx, idx_to_name = load_paired(sys.argv[1], sys.argv[2], len(list(baseline_times.keys()))) 36 paired_times, paired_offsets, name_to_idx, idx_to_name = load_paired(sys.argv[1], sys.argv[2], len(list(baseline_times.keys())))
37 for key in baseline_times: 37# for key in baseline_times:
38 print(key,max(baseline_times[key])) 38# print(key,max(baseline_times[key]))
39else: 39else:
40 # Paired times use an abuse of the baseline file format 40 # Paired times use an abuse of the baseline file format
41 baseline_times, baseline_sample_cnt, baseline_max_times = load_baseline(sys.argv[2]) 41 baseline_times, baseline_sample_cnt, baseline_max_times = load_baseline(sys.argv[2])
@@ -94,18 +94,23 @@ for b1 in reliableNames:
94 print("{:>10.3}".format(M), end=" ") 94 print("{:>10.3}".format(M), end=" ")
95 print("") 95 print("")
96# Print some statistics about the distribution 96# Print some statistics about the distribution
97print("Average: {:>5.3} with standard deviation {:>5.3} using `{}`".format(np.mean(M_vals), np.std(M_vals), sample_f.__name__)) 97print("Overall average is {:>5.3} with standard deviation {:>5.3} using `{}`".format(np.mean(M_vals), np.std(M_vals), sample_f.__name__))
98Ms = np.asarray(M_vals, dtype=np.float32) 98Ms = np.asarray(M_vals, dtype=np.float32)
99if not LEVEL_C_ANALYSIS: 99if not LEVEL_C_ANALYSIS:
100 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") 100 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")
101 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") 101 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")
102 M_vals_to_plot = Ms[np.logical_and(Ms > 0, Ms <= 1)] 102 M_vals_to_plot = Ms[np.logical_and(Ms > 0, Ms <= 1)]
103 # Sims' analysis
104 mean = np.mean(list(M_vals_to_plot))
105 std = np.std(list(M_vals_to_plot))
106 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__))
103else: 107else:
104 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") 108 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")
105 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") 109 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")
106 M_vals_to_plot = Ms 110 M_vals_to_plot = Ms
111 # Sims' analysis
112 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__))
107 113
108print("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__))
109print(plt.hist(M_vals_to_plot, bins=10)) 114print(plt.hist(M_vals_to_plot, bins=10))
110 115
111##### BELOW TEXT IS OLD OFFSET CODE (patched) ##### 116##### 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):
38 max_res[s[BENCH_NAME]] = max(int(s[TOTAL_NS]), max_res[s[BENCH_NAME]]) 38 max_res[s[BENCH_NAME]] = max(int(s[TOTAL_NS]), max_res[s[BENCH_NAME]])
39 return res, samples, max_res 39 return res, samples, max_res
40 40
41# Remove the _all prefix if it exists and return the result
42# @param pair_name Name to strip (eg. pointer_all)
43# @returns Stripped name (eg. pointer)
44def strip_pair_postfix(pair_name):
45 if pair_name[-4:] == "_all":
46 return pair_name[:-4]
47 return pair_name
48
41# This parses the result data from paired, threaded timing experiements 49# This parses the result data from paired, threaded timing experiements
42# @param file1 The -A file name 50# @param file1 The -A file name
43# @param file2 The -B file name 51# @param file2 The -B file name
@@ -93,12 +101,8 @@ def load_paired(file1, file2, benchmarkCount):
93 end2 = int(lineArr2[END_S]) * 10**9 + int(lineArr2[END_N]) 101 end2 = int(lineArr2[END_S]) * 10**9 + int(lineArr2[END_N])
94 maxEnd = max(end1, end2) 102 maxEnd = max(end1, end2)
95 # Time actually co-scheduled is minEnd - maxStart, but Sims uses a different model 103 # Time actually co-scheduled is minEnd - maxStart, but Sims uses a different model
96# time[bench1][bench2][int(lineArr1[JOB_NUM])] = maxEnd - minStart
97 time[bench1][bench2][job_idx] = maxEnd - minStart 104 time[bench1][bench2][job_idx] = maxEnd - minStart
98 if lineArr1[SECOND_PROG] == "h264_dec" and lineArr2[JOB_NUM] == 0:
99 print(maxEnd - minStart)
100 # Compute offset: if first job starts at t=0, when does second start? 105 # Compute offset: if first job starts at t=0, when does second start?
101# offset[bench1][bench2][int(lineArr1[JOB_NUM])] = abs(start2-start1)
102 offset[bench1][bench2][job_idx] = abs(start2-start1) 106 offset[bench1][bench2][job_idx] = abs(start2-start1)
103 # Compute some running statistics 107 # Compute some running statistics
104 avg_off += abs(start2-start1) 108 avg_off += abs(start2-start1)
@@ -110,14 +114,14 @@ def load_paired(file1, file2, benchmarkCount):
110 bench2 = bench2 + 1 114 bench2 = bench2 + 1
111 job_idx = 0 115 job_idx = 0
112 else: 116 else:
113 name_to_idx[lineArr1[FIRST_PROG]] = bench1 117 name_to_idx[strip_pair_postfix(lineArr1[FIRST_PROG])] = bench1
114 idx_to_name[bench1] = lineArr1[FIRST_PROG] 118 idx_to_name[bench1] = strip_pair_postfix(lineArr1[FIRST_PROG])
115 bench1 = bench1 + 1 119 bench1 = bench1 + 1
116 bench2 = bench1 # bench1 will never again appear as bench2 120 bench2 = bench1 # bench1 will never again appear as bench2
117 job_idx = 0 121 job_idx = 0
118 else: 122 else:
119 job_idx += 1 123 job_idx += 1
120 print("Average offset is: " + str(avg_off/avg_off_samp) + "ns") 124 print("Average offset is: {:.2f} nanoseconds".format(avg_off/avg_off_samp))
121 return time, offset, name_to_idx, idx_to_name 125 return time, offset, name_to_idx, idx_to_name
122 126
123# Paired times use an abuse of the baseline file format 127# Paired times use an abuse of the baseline file format