diff --git a/sam/sim/test/final-apps/test_mat_elemadd_FINAL.py b/sam/sim/test/final-apps/test_mat_elemadd_FINAL.py index 5648a816..c286a41d 100644 --- a/sam/sim/test/final-apps/test_mat_elemadd_FINAL.py +++ b/sam/sim/test/final-apps/test_mat_elemadd_FINAL.py @@ -16,10 +16,10 @@ import csv from sam.sim.test.gen_gantt import gen_gantt - cwd = os.getcwd() formatted_dir = os.getenv('SUITESPARSE_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) + # csv file path @pytest.mark.suitesparse @@ -63,7 +63,8 @@ def test_mat_elemadd_FINAL(samBench, ssname, cast, check_gold, report_stats, bac fiberlookup_Ci_11 = CompressedCrdRdScan(crd_arr=C_crd0, seg_arr=C_seg0, debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) unioni_9 = Union2(debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) - fiberwrite_X0_2 = CompressWrScan(seg_size=2, size=2 * len(B_crd0), fill=fill, debug=debug_sim, statistics=report_stats, + fiberwrite_X0_2 = CompressWrScan(seg_size=2, size=2 * len(B_crd0), fill=fill, debug=debug_sim, + statistics=report_stats, back_en=backpressure, depth=int(depth)) fiberlookup_Bj_7 = CompressedCrdRdScan(crd_arr=B_crd1, seg_arr=B_seg1, debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) @@ -72,8 +73,10 @@ def test_mat_elemadd_FINAL(samBench, ssname, cast, check_gold, report_stats, bac unionj_6 = Union2(debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) fiberwrite_X1_1 = CompressWrScan(seg_size=2 * len(B_crd0) + 1, size=2 * len(B_vals), fill=fill, debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) - arrayvals_B_4 = Array(init_arr=B_vals, debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) - arrayvals_C_5 = Array(init_arr=C_vals, debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) + arrayvals_B_4 = Array(init_arr=B_vals, debug=debug_sim, statistics=report_stats, back_en=backpressure, + depth=int(depth)) + arrayvals_C_5 = Array(init_arr=C_vals, debug=debug_sim, statistics=report_stats, back_en=backpressure, + depth=int(depth)) add_3 = Add2(debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) fiberwrite_Xvals_0 = ValsWrScan(size=2 * len(B_vals), fill=fill, debug=debug_sim, statistics=report_stats, back_en=backpressure, depth=int(depth)) @@ -197,13 +200,12 @@ def bench(): sample_dict = fiberwrite_Xvals_0.return_statistics() for k in sample_dict.keys(): extra_info["fiberwrite_Xvals_0" + "/" + k] = sample_dict[k] - + # code for generating csv, gantt chart, txt file - extra_info["backpressure"]=backpressure - extra_info["depth"]=depth + extra_info["backpressure"] = backpressure + extra_info["depth"] = depth gen_gantt(extra_info, "mat_elemadd") - if check_gold: print("Checking gold...") check_gold_mat_elemadd(ssname, debug_sim, cast, out_crds, out_segs, out_vals, "ss01") diff --git a/sam/sim/test/gen_gantt.py b/sam/sim/test/gen_gantt.py index df124ecf..453a0553 100644 --- a/sam/sim/test/gen_gantt.py +++ b/sam/sim/test/gen_gantt.py @@ -37,26 +37,25 @@ def gen_gantt(extra_info, testname): start_list.insert(0, start_c) duration_list.insert(0, finish_c - start_c) - - back_depth = 'N' # assume there is no back pressure for default + back_depth = 'N' # assume there is no back pressure for default if "backpressure" in extra_info.keys() and extra_info["backpressure"]: back_depth = extra_info["depth"] - + # Writing cycle info to csv file - with open(testname + '_' + extra_info["dataset"] + '_back_'+back_depth+'.csv', 'w', newline='') as file: + with open(testname + '_' + extra_info["dataset"] + '_back_' + back_depth + '.csv', 'w', newline='') as file: writer = csv.writer(file) - writer.writerow(["block","start","finish","duration","valid_ops"]) + writer.writerow(["block", "start", "finish", "duration", "valid_ops"]) for idx, block in reversed(list(enumerate(block_list))): - writer.writerow([block, start_list[idx], finish_list[idx], duration_list[idx],'-']) - + writer.writerow([block, start_list[idx], finish_list[idx], duration_list[idx], '-']) + # Print all the statistics to a text file - text_file = open(testname + '_' + extra_info["dataset"] + '_back_'+back_depth+".txt","w") + text_file = open(testname + '_' + extra_info["dataset"] + '_back_' + back_depth + ".txt", "w") for k in extra_info.keys(): if "/" in k: - text_file.write(k+": "+str(extra_info[k])+"\n") + text_file.write(k + ": " + str(extra_info[k]) + "\n") text_file.close() # Creating gantt chart plt.barh(y=block_list, width=duration_list, left=start_list) - file_name = testname + '_' + extra_info["dataset"] + "_back_"+back_depth+".png" + file_name = testname + '_' + extra_info["dataset"] + "_back_" + back_depth + ".png" plt.savefig(file_name, bbox_inches="tight") diff --git a/sam/sim/test/reorder-study/test_reorder_matmul_ikj.py b/sam/sim/test/reorder-study/test_reorder_matmul_ikj.py index 0350a3ae..80347a06 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_ikj.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_ikj.py @@ -20,7 +20,7 @@ cwd = os.getcwd() formatted_dir = os.getenv('SUITESPARSE_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) -#formatted_dir = os.getenv('FROSTT_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) +# formatted_dir = os.getenv('FROSTT_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) synthetic_dir = os.getenv('SYNTHETIC_PATH', default=os.path.join(cwd, 'synthetic')) @@ -33,7 +33,6 @@ @pytest.mark.synth # @pytest.mark.parametrize("sparsity", [0.95]) def test_reorder_matmul_ikj(samBench, ssname, check_gold, report_stats, debug_sim, cast, backpressure, depth, fill=0): - B_dirname = os.path.join(formatted_dir, ssname, "matmul_kij") B_shape_filename = os.path.join(B_dirname, "tensor_B_mode_shape") B_shape = read_inputs(B_shape_filename) @@ -267,7 +266,7 @@ def bench(): sample_dict = arrayvals_C_8.return_statistics() for k in sample_dict.keys(): extra_info["arrayvals_C_8" + "_" + k] = sample_dict[k] - + gen_gantt(extra_info, "matmul_ikj") if check_gold: diff --git a/sam/sim/test/reorder-study/test_reorder_matmul_jik.py b/sam/sim/test/reorder-study/test_reorder_matmul_jik.py index c80a322f..6afbe6df 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_jik.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_jik.py @@ -249,7 +249,7 @@ def bench(): sample_dict = arrayvals_C_6.return_statistics() for k in sample_dict.keys(): extra_info["arrayvals_C_6" + "_" + k] = sample_dict[k] - + gen_gantt(extra_info, "matmul_jik") if check_gold: diff --git a/sam/sim/test/reorder-study/test_reorder_matmul_kji.py b/sam/sim/test/reorder-study/test_reorder_matmul_kji.py index 2dce7d6e..60284171 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_kji.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_kji.py @@ -33,7 +33,6 @@ @pytest.mark.synth @pytest.mark.parametrize("sparsity", [0.95]) def test_reorder_matmul_kji(samBench, sparsity, check_gold, debug_sim, backpressure, depth, fill=0): - # DCSC B_dirname = os.path.join(synthetic_dir, f"matrix/DCSC/B_random_sp_{sparsity}/") B_shape_filename = os.path.join(B_dirname, "tensor_B_mode_shape") @@ -233,7 +232,6 @@ def bench(): extra_info["tensor_B_shape"] = B_shape extra_info["tensor_C_shape"] = C_shape - sample_dict = intersectk_16.return_statistics() for k in sample_dict.keys(): extra_info["intersectk_16" + "_" + k] = sample_dict[k] @@ -269,7 +267,7 @@ def bench(): sample_dict = arrayvals_B_6.return_statistics() for k in sample_dict.keys(): extra_info["arrayvals_B_6" + "_" + k] = sample_dict[k] - + gen_gantt(extra_info, "matmul_kji") if check_gold: