Skip to content

Commit

Permalink
Fix pycodestyle for gantt branch
Browse files Browse the repository at this point in the history
  • Loading branch information
weiya711 committed Oct 5, 2023
1 parent cd75b3e commit a987149
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
18 changes: 10 additions & 8 deletions sam/sim/test/final-apps/test_mat_elemadd_FINAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -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")
Expand Down
19 changes: 9 additions & 10 deletions sam/sim/test/gen_gantt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
5 changes: 2 additions & 3 deletions sam/sim/test/reorder-study/test_reorder_matmul_ikj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion sam/sim/test/reorder-study/test_reorder_matmul_jik.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions sam/sim/test/reorder-study/test_reorder_matmul_kji.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit a987149

Please sign in to comment.