diff --git a/.gitignore b/.gitignore index e3c498b9..0df30951 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ cmake-build-*/ # Generated SAM Graphs *.gv +venv/ + # Generated images *.svg *.png diff --git a/environment.yml b/environment.yml index 991dd271..9b648d7c 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: aha +name: sam channels: - pytorch - anaconda @@ -201,4 +201,4 @@ dependencies: - statsmodels==0.13.2 - threadpoolctl==3.1.0 - traitlets==5.3.0 -prefix: /home/oliviahsu/miniconda3/envs/aha +prefix: ~/Anaconda3/envs/sam diff --git a/sam/sim/src/accumulator.py b/sam/sim/src/accumulator.py index a3500369..43cb8e5e 100644 --- a/sam/sim/src/accumulator.py +++ b/sam/sim/src/accumulator.py @@ -40,11 +40,6 @@ def set_backpressure(self, backpressure): if not backpressure: self.ready_backpressure = False - def fifo_available(self, br=""): - if self.backpressure_en: - return self.fifo_avail - return True - def update_ready(self): if self.backpressure_en: if len(self.in_val) > self.depth: @@ -52,11 +47,6 @@ def update_ready(self): else: self.fifo_avail = True - def add_child(self, child=None, branch=""): - if self.backpressure_en and child is not None: - self.backpressure.append(child) - self.branch.append(branch) - def update(self): self.update_ready() self.update_done() @@ -202,7 +192,7 @@ def update(self): if self.debug: if self.seen_done or self.done: print(self.seen_done, self.done) - print("@@@", self.outer_crdpt, self.inner_crdpt, self.in_val, self.emit_output, + print("current point value", self.outer_crdpt, self.inner_crdpt, self.in_val, self.emit_output, self.curr_in_outer_crdpt, self.curr_in_inner_crdpt, self.curr_val) self.print_debug() if len(self.in_val) > 0 and self.in_val[0] == "D": @@ -239,12 +229,6 @@ def update(self): self.curr_in_inner_crdpt = self.inner_crdpt.pop(0) ocrd = self.outer_crdpt.pop(0) - # if self.curr_in_val == 'D': - # print(self.curr_in_val, self.curr_in_inner_crdpt, ocrd) - # assert self.curr_in_val == "D" and self.curr_in_inner_crdpt == "D" and ocrd == "D" - # print("######", ocrd, self.curr_in_outer_crdpt, self.curr_in_inner_crdpt, self.emit_output) - # print(self.in_val, self.outer_crdpt, self.inner_crdpt, ocrd - # self.curr_in_outer_crdpt, self.curr_in_inner_crdpt, self.curr_in_val) emit_output = ocrd != self.curr_in_outer_crdpt and self.curr_in_outer_crdpt is not None and \ self.curr_in_outer_crdpt != "D" if emit_output: @@ -271,17 +255,11 @@ def update(self): self.seen_done = True else: self.storage[self.curr_in_outer_crdpt] = {self.curr_in_inner_crdpt: self.valtype(self.curr_in_val)} - # if self.curr_in_outer_crdpt == "D": - # print("__________", self.emit_output, self.seen_done) if len(self.emit_output) > 0: fiber = self.emit_output[0] self.curr_outer_crdpt = fiber[0] - # print("===, ", self.storage) - # print(fiber) - # print(self.emit_output) - # print(self.storage[self.curr_outer_crdpt].keys(), fiber[1]) self.curr_inner_crdpt = min( [item for item in self.storage[self.curr_outer_crdpt].keys() if item > fiber[1]]) self.curr_val = self.storage[self.curr_outer_crdpt][self.curr_inner_crdpt] @@ -433,26 +411,6 @@ def set_backpressure(self, backpressure): if not backpressure: self.ready_backpressure = False - # FIXME: (owhsu) This code is unreachable - def fifo_available(self, br=""): - assert False - if self.backpressure_en: - if br == "inner": - # and len(self.in_inner_crdpt) > self.depth: - return self.fifo_avail_inner - if br == "outer": # and len(self.in_outer_crdpt) > self.depth: - return self.fifo_avail_outer # return False - if br == "val": # and len(self.in_val) > self.depth: - return self.fifo_avail_val # return False - # return True - return True - - def add_child(self, child=None, branch=""): - if self.backpressure_en: - if child is not None: - self.backpressure.append(child) - self.branch.append(branch) - def update_ready(self): if self.backpressure_en: if len(self.in_inner_crdpt) > self.depth: @@ -480,16 +438,13 @@ def update(self): print(self.in_outer_crdpt, self.in_inner_crdpt, self.in_val) print(self.crdpt_spacc.print_debug()) print(self.crdpt_converter.print_debug()) - if self.done: + if self.done and self.memory_model_en: f1, f2, f3 = self.crdpt_spacc.return_fifo() f4, f5 = self.crdpt_converter.return_fifo() self.crdpt_spacc = SparseCrdPtAccumulator1(maxdim=self.temp_maxdim, valtype=self.temp_valtype, fifos=[f1, f2, f3]) self.crdpt_converter = CrdPtConverter(last_level=self.temp_last_level, fifos=[f4, f5]) - # FIXME: (owhsu) self.data_ready not defined in init - if self.backpressure_en: - self.data_ready = True if len(self.in_outer_crdpt) > 0 or len(self.in_inner_crdpt) > 0: self.block_start = False @@ -509,7 +464,7 @@ def update(self): self.crdpt_spacc.set_val(self.in_val.pop(0)) self.crdpt_spacc.update() - print(">>>>>>>>>>>>SPACC:", self.crdpt_spacc.out_outer_crdpt(), self.crdpt_spacc.out_inner_crdpt()) + # print(">>>>>>>>>>>>SPACC:", self.crdpt_spacc.out_outer_crdpt(), self.crdpt_spacc.out_inner_crdpt()) self.crdpt_converter.set_outer_crdpt(self.crdpt_spacc.out_outer_crdpt()) self.crdpt_converter.set_inner_crdpt(self.crdpt_spacc.out_inner_crdpt()) @@ -854,12 +809,6 @@ def set_backpressure(self, backpressure): if not backpressure: self.ready_backpressure = False - def add_child(self, child=None, branch=""): - if self.backpressure_en: - if child is not None: - self.backpressure.append(child) - self.branch.append(branch) - def update_ready(self): if self.backpressure_en: if len(self.in0_crdpt) > self.depth: @@ -881,7 +830,7 @@ def update(self): if self.backpressure_en: self.data_valid = False if (self.backpressure_en and self.check_backpressure()) or not self.backpressure_en: - if self.done: + if self.done and self.memory_model_en: f1, f2, f3 = self.crdpt_spacc.return_fifo() f4, f5 = self.crdpt_converter.return_fifo() self.crdpt_spacc = SparseCrdPtAccumulator2(maxdim=self.temp_maxdim, valtype=self.temp_valtype, diff --git a/sam/sim/src/array.py b/sam/sim/src/array.py index c05a017f..669baef9 100644 --- a/sam/sim/src/array.py +++ b/sam/sim/src/array.py @@ -44,15 +44,10 @@ def set_fifo(self, fifo): def get_fifo(self): return self.load_addrs - def add_child(self, child, branch=""): - if self.backpressure_en: - if child is not None: - self.backpressure.append(child) - self.branch.append(branch) - def set_path(self, path): self.path = path + # FIXME(ritvik): fix the initialization of array def reintilialize_arrs(self, load_vals, fifo): self.arr = load_vals self.set_fifo(fifo) @@ -111,12 +106,6 @@ def update(self): self.store(store_tup[0], store_tup[1]) self.store_en = False - def fifo_available(self, br=""): - if self.backpressure_en: - if len(self.load_addrs) > 1: - return False - return True - def update_ready(self): if self.backpressure_en: if len(self.load_addrs) > self.depth: diff --git a/sam/sim/src/base.py b/sam/sim/src/base.py index 38eaa778..0a0c6b02 100644 --- a/sam/sim/src/base.py +++ b/sam/sim/src/base.py @@ -67,7 +67,7 @@ def larger_stkn(a, b): class Primitive(ABC): - def __init__(self, debug=False, statistics=False, name="", back_en=False, **kwargs): + def __init__(self, debug=False, statistics=False, name="", back_en=False, memory_model_en=False, **kwargs): self.name = name self.done = False self.debug = debug @@ -78,6 +78,7 @@ def __init__(self, debug=False, statistics=False, name="", back_en=False, **kwar self.get_stats = statistics self.backpressure_en = back_en + self.memory_model_en = memory_model_en def out_done(self): return self.done diff --git a/sam/sim/src/joiner.py b/sam/sim/src/joiner.py index 51089e73..488c7bee 100644 --- a/sam/sim/src/joiner.py +++ b/sam/sim/src/joiner.py @@ -57,11 +57,6 @@ def update_ready(self): else: self.fifo_avail_in2 = True - def add_child(self, child=None, branch=""): - if self.backpressure_en: - self.backpressure.append(child) - self.branches.append(branch) - def set_in1(self, in_ref1, in_crd1, parent=None): if in_ref1 != '' and in_crd1 != '' and in_ref1 is not None and in_crd1 is not None: # print(in_ref1, " ", in_crd1) diff --git a/sam/sim/src/rd_scanner.py b/sam/sim/src/rd_scanner.py index fb17f949..e1556f1f 100644 --- a/sam/sim/src/rd_scanner.py +++ b/sam/sim/src/rd_scanner.py @@ -44,18 +44,6 @@ def out_crd(self, child=None): if (self.backpressure_en and self.data_valid) or not self.backpressure_en: return self.curr_crd - def add_child(self, child, branch=""): - if self.backpressure_en and child is not None: - self.backpressure.append(child) - self.branches.append(branch) - - def fifo_available(self, br=""): - if self.backpressure_en: - return self.fifo_avail - # and len(self.in_ref) > self.depth: - # return False - return True - def update_ready(self): if self.backpressure_en: if len(self.in_ref) > self.depth: @@ -92,11 +80,11 @@ def __init__(self, dim=0, depth=4, **kwargs): def update(self): self.update_done() self.update_ready() - if len(self.in_ref) > 0: - self.block_start = False if self.backpressure_en: self.data_valid = False if (self.backpressure_en and self.check_backpressure()) or not self.backpressure_en: + if len(self.in_ref) > 0: + self.block_start = False if self.backpressure_en: self.data_valid = True if self.emit_tkn and len(self.in_ref) > 0: @@ -246,6 +234,7 @@ def __init__(self, crd_arr=[], seg_arr=[], skip=True, depth=1, tile_size=None, f if fifo is not None: self.set_fifo(fifo) + # FIXME (Ritvik): Use reinitialize array isntead of redeclaring the rd scanner def reinitialize_arrs(self, seg_arr, crd_arr, fifo): # assert False self.start_addr = 0 @@ -281,11 +270,6 @@ def set_fifo(self, fifo): def get_fifo(self): return self.in_ref - def fifo_available(self, br=""): - if self.backpressure_en and len(self.in_ref) > self.depth: - return False - return True - def set_in_ref(self, in_ref, parent=None): if in_ref != '' and in_ref is not None: self.in_ref.append(in_ref) @@ -366,6 +350,9 @@ def update(self): if (self.backpressure_en and self.check_backpressure()) or not self.backpressure_en: if self.backpressure_en: self.data_valid = True + if len(self.in_ref) > 0: + self.block_start = False + # Process skip token first and save if len(self.in_crd_skip) > 0 and self.skip_processed: self.curr_skip = self.in_crd_skip.pop(0) diff --git a/sam/sim/src/repeater.py b/sam/sim/src/repeater.py index 66ccfebe..956506ad 100644 --- a/sam/sim/src/repeater.py +++ b/sam/sim/src/repeater.py @@ -52,11 +52,6 @@ def update_ready(self): else: self.fifo_avail_repeat = True - def add_child(self, child=None, branch=""): - if self.backpressure_en: - self.backpressure.append(child) - self.branches.append(branch) - def update(self): self.update_done() self.update_ready() @@ -359,11 +354,6 @@ def update_ready(self): else: self.fifo_avail = True - def add_child(self, child=None, branch=""): - if self.backpressure_en: - self.backpressure.append(child) - self.branches.append(branch) - # input can either be coordinates or references def set_istream(self, istream, parent=None): if istream != '' and istream is not None: diff --git a/sam/sim/src/wr_scanner.py b/sam/sim/src/wr_scanner.py index 9de01c2e..e835dc07 100644 --- a/sam/sim/src/wr_scanner.py +++ b/sam/sim/src/wr_scanner.py @@ -164,12 +164,8 @@ def update(self): self.update_ready() if self.done: return - # self.arr.print_debug(name="vals") - # self.seg_arr.print_debug(name="seg") if self.debug: print("RESET WR SCAN ", self.input) - # self.reset() - # self.done = False if self.debug: print("post reset: ", self.arr.out_done()) diff --git a/sam/sim/test/advanced-simulator/test_matmul_ikj_tile_pipeline_final.py b/sam/sim/test/advanced-simulator/test_matmul_ikj_tile_pipeline_final.py index 0d97bf04..19ffe48a 100755 --- a/sam/sim/test/advanced-simulator/test_matmul_ikj_tile_pipeline_final.py +++ b/sam/sim/test/advanced-simulator/test_matmul_ikj_tile_pipeline_final.py @@ -30,7 +30,8 @@ ) @pytest.mark.suitesparse def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report_stats, - skip_empty, yaml_name, nbuffer, backpressure, depth, nnz_value, fill=0): + skip_empty, yaml_name, nbuffer, backpressure, depth, memory_model, nnz_value, + fill=0): depth = int(depth) stats_dict = {"mul_6_ops": 0, "spacc1_3_rmw_ops": [], "out_arr_size": 0, "repsiggen_i_17_total_rep": 0, "repsiggen_j_10_total_rep": 0, "repsiggen_i_17_max_rep": 0, "repsiggen_j_10_max_rep": 0, @@ -340,7 +341,7 @@ def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report in_fifo.append("D") fiberlookup_Bi_19 = CompressedCrdRdScan(name="Bi", crd_arr=B_crd0, seg_arr=B_seg0, debug=debug_sim2, statistics=report_stats, fifo=in_fifo, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) mem_model_bi.valid_tile_received() nxt_tile_present[0] = True if mem_blocks_decl_flag and fiberlookup_Bk_14.out_done() and mem_model_bk.valid_tile() and not nxt_tile_present[1]: @@ -361,7 +362,7 @@ def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report in_fifo = fiberlookup_Bk_14.get_fifo() fiberlookup_Bk_14 = CompressedCrdRdScan(name="Bk", crd_arr=B_crd1, seg_arr=B_seg1, debug=debug_sim2, statistics=report_stats, fifo=in_fifo, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) mem_model_bk.valid_tile_received() nxt_tile_present[1] = True if mem_blocks_decl_flag and fiberlookup_Ck_15.out_done() and mem_model_ck.valid_tile() and not nxt_tile_present[2]: @@ -382,7 +383,7 @@ def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report in_fifo = fiberlookup_Ck_15.get_fifo() fiberlookup_Ck_15 = CompressedCrdRdScan(name="Ck", crd_arr=C_crd0, seg_arr=C_seg0, debug=debug_sim2, statistics=report_stats, fifo=in_fifo, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) mem_model_ck.valid_tile_received() repeat_Ci_16.set_in_ref(0, "") repeat_Ci_16.set_in_ref("D", "") @@ -404,7 +405,7 @@ def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report in_fifo = fiberlookup_Cj_12.get_fifo() fiberlookup_Cj_12 = CompressedCrdRdScan(name="Cj", crd_arr=C_crd1, seg_arr=C_seg1, debug=debug_sim2, statistics=report_stats, fifo=in_fifo, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) mem_model_cj.valid_tile_received() nxt_tile_present[3] = True if mem_blocks_decl_flag and arrayvals_B_7.out_done() and mem_model_bvals.valid_tile() and not nxt_tile_present[4]: @@ -422,7 +423,7 @@ def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report B_vals = read_inputs(B_vals_filename, float) in_fifo = arrayvals_B_7.get_fifo() arrayvals_B_7 = Array(name="Bvals", init_arr=B_vals, debug=debug_sim2, statistics=report_stats, fifo=in_fifo, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) mem_model_bvals.valid_tile_received() nxt_tile_present[4] = True if mem_blocks_decl_flag and arrayvals_C_8.out_done() and mem_model_cvals.valid_tile() and not nxt_tile_present[5]: @@ -440,7 +441,7 @@ def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report C_vals = read_inputs(C_vals_filename, float) in_fifo = arrayvals_C_8.get_fifo() arrayvals_C_8 = Array(name="Cvals", init_arr=C_vals, debug=debug_sim2, statistics=report_stats, fifo=in_fifo, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) mem_model_cvals.valid_tile_received() nxt_tile_present[5] = True @@ -613,50 +614,50 @@ def test_matmul_ikj_tiled_sparse(samBench, ssname, check_gold, debug_sim, report debug_sim2 = False # True # False fiberlookup_Bi_19 = CompressedCrdRdScan(name="Bi", crd_arr=B_crd0, seg_arr=B_seg0, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) fiberlookup_Bk_14 = CompressedCrdRdScan(name="Bk", crd_arr=B_crd1, seg_arr=B_seg1, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) repsiggen_i_17 = RepeatSigGen(debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) repeat_Ci_16 = Repeat(debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) fiberlookup_Ck_15 = CompressedCrdRdScan(name="Ck", crd_arr=C_crd0, seg_arr=C_seg0, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) intersectk_13 = Intersect2(debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) crdhold_5 = CrdHold(debug=debug_sim2, statistics=report_stats, back_en=backpressure, - depth=depth) + depth=depth, memory_model_en=memory_model) fiberlookup_Cj_12 = CompressedCrdRdScan(name="Cj", crd_arr=C_crd1, seg_arr=C_seg1, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) arrayvals_C_8 = Array(name="C", init_arr=C_vals, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) crdhold_4 = CrdHold(debug=debug_sim2, statistics=report_stats, back_en=backpressure, depth=depth) repsiggen_j_10 = RepeatSigGen(debug=debug_sim2, statistics=report_stats, back_en=backpressure, - depth=depth) + depth=depth, memory_model_en=memory_model) repeat_Bj_9 = Repeat(debug=debug_sim2, statistics=report_stats, back_en=backpressure, depth=depth) arrayvals_B_7 = Array(name="B", init_arr=B_vals, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) mul_6 = Multiply2(debug=debug_sim2, statistics=report_stats, back_en=backpressure, depth=depth) spaccumulator1_3 = SparseAccumulator1(debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) spaccumulator1_3_drop_crd_inner = StknDrop(debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) spaccumulator1_3_drop_crd_outer = StknDrop(debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) spaccumulator1_3_drop_val = StknDrop(debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) fiberwrite_Xvals_0 = ValsWrScan(name="vals", size=1 * B_shape[0] * C_shape[1], fill=fill, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) fiberwrite_X1_1 = CompressWrScan(name="X1", seg_size=B_shape[0] + 1, size=B_shape[0] * C_shape[1], fill=fill, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) fiberwrite_X0_2 = CompressWrScan(name="X0", seg_size=2, size=B_shape[0], fill=fill, debug=debug_sim2, statistics=report_stats, - back_en=backpressure, depth=depth) + back_en=backpressure, depth=depth, memory_model_en=memory_model) # print("INITIALIZE compute loop at ", time_cnt) initialize_cntr = time_cnt mem_model_b.valid_tile_received() diff --git a/sam/sim/test/conftest.py b/sam/sim/test/conftest.py index 8339e3f5..d3609bf5 100644 --- a/sam/sim/test/conftest.py +++ b/sam/sim/test/conftest.py @@ -25,6 +25,8 @@ def pytest_addoption(parser): help="If nbuffering is enabled") parser.addoption("--back", action="store_true", default=False, help="Whether backpressure is enabled") + parser.addoption("--memory-model", action="store_true", default=False, + help="Whether memory model is wanted") parser.addoption("--depth", action="store", default=2, help="fifo depth value") parser.addoption("--nnz-value", action="store", default=5000, @@ -72,6 +74,11 @@ def backpressure(request): return request.config.getoption("--back") +@pytest.fixture +def memory_model(request): + return request.config.getoption("--memory-model") + + @pytest.fixture def skip_empty(request): return request.config.getoption("--skip-empty") @@ -87,11 +94,6 @@ def debug_sim(request): return request.config.getoption("--debug-sim") -@pytest.fixture -def backpressure(request): - return request.config.getoption("--back") - - @pytest.fixture def depth(request): return request.config.getoption("--depth") 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 e230d329..c286a41d 100644 --- a/sam/sim/test/final-apps/test_mat_elemadd_FINAL.py +++ b/sam/sim/test/final-apps/test_mat_elemadd_FINAL.py @@ -14,11 +14,14 @@ from sam.sim.test.gold import * import os 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 def test_mat_elemadd_FINAL(samBench, ssname, cast, check_gold, report_stats, backpressure, depth, debug_sim, fill=0): B_dirname = os.path.join(formatted_dir, ssname, "mat_elemadd") @@ -60,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)) @@ -69,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)) @@ -147,18 +153,34 @@ def bench(): extra_info["result/vals_size"] = len(out_vals) extra_info["result/nnz"] = len([x for x in out_vals if x != 0]) - sample_dict = unioni_9.return_statistics() + sample_dict = fiberlookup_Bi_10.return_statistics() for k in sample_dict.keys(): - extra_info["unioni_9" + "/" + k] = sample_dict[k] + extra_info["fiberlookup_Bi_10" + "/" + k] = sample_dict[k] - sample_dict = unionj_6.return_statistics() + sample_dict = fiberlookup_Ci_11.return_statistics() for k in sample_dict.keys(): - extra_info["unionj_6" + "/" + k] = sample_dict[k] + extra_info["fiberlookup_Ci_11" + "/" + k] = sample_dict[k] + + sample_dict = unioni_9.return_statistics() + for k in sample_dict.keys(): + extra_info["unioni_9" + "/" + k] = sample_dict[k] sample_dict = fiberwrite_X0_2.return_statistics() for k in sample_dict.keys(): extra_info["fiberwrite_X0_2" + "/" + k] = sample_dict[k] + sample_dict = fiberlookup_Bj_7.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberlookup_Bj_7" + "/" + k] = sample_dict[k] + + sample_dict = fiberlookup_Cj_8.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberlookup_Cj_8" + "/" + k] = sample_dict[k] + + sample_dict = unionj_6.return_statistics() + for k in sample_dict.keys(): + extra_info["unionj_6" + "/" + k] = sample_dict[k] + sample_dict = fiberwrite_X1_1.return_statistics() for k in sample_dict.keys(): extra_info["fiberwrite_X1_1" + "/" + k] = sample_dict[k] @@ -167,10 +189,6 @@ def bench(): for k in sample_dict.keys(): extra_info["arrayvals_B_4" + "/" + k] = sample_dict[k] - sample_dict = fiberwrite_Xvals_0.return_statistics() - for k in sample_dict.keys(): - extra_info["fiberwrite_Xvals_0" + "/" + k] = sample_dict[k] - sample_dict = arrayvals_C_5.return_statistics() for k in sample_dict.keys(): extra_info["arrayvals_C_5" + "/" + k] = sample_dict[k] @@ -179,21 +197,14 @@ def bench(): for k in sample_dict.keys(): extra_info["add_3" + "/" + k] = sample_dict[k] - sample_dict = fiberlookup_Bi_10.return_statistics() - for k in sample_dict.keys(): - extra_info["fiberlookup_Bi_10" + "/" + k] = sample_dict[k] - - sample_dict = fiberlookup_Ci_11.return_statistics() - for k in sample_dict.keys(): - extra_info["fiberlookup_Ci_11" + "/" + k] = sample_dict[k] - - sample_dict = fiberlookup_Bj_7.return_statistics() + sample_dict = fiberwrite_Xvals_0.return_statistics() for k in sample_dict.keys(): - extra_info["fiberlookup_Bj_7" + "/" + k] = sample_dict[k] + extra_info["fiberwrite_Xvals_0" + "/" + k] = sample_dict[k] - sample_dict = fiberlookup_Cj_8.return_statistics() - for k in sample_dict.keys(): - extra_info["fiberlookup_Cj_8" + "/" + k] = sample_dict[k] + # code for generating csv, gantt chart, txt file + extra_info["backpressure"] = backpressure + extra_info["depth"] = depth + gen_gantt(extra_info, "mat_elemadd") if check_gold: print("Checking gold...") diff --git a/sam/sim/test/final-apps/test_matmul_kij_FINAL.py b/sam/sim/test/final-apps/test_matmul_kij_FINAL.py index c1f0d212..3aa74641 100644 --- a/sam/sim/test/final-apps/test_matmul_kij_FINAL.py +++ b/sam/sim/test/final-apps/test_matmul_kij_FINAL.py @@ -14,6 +14,7 @@ from sam.sim.test.gold import * import os 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')) @@ -240,6 +241,8 @@ def bench(): for k in sample_dict.keys(): extra_info["fiberlookup_Cj_11" + "/" + k] = sample_dict[k] + gen_gantt(extra_info, "matmul_kij") + if check_gold: print("Checking gold...") check_gold_matmul(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 new file mode 100644 index 00000000..b421a49b --- /dev/null +++ b/sam/sim/test/gen_gantt.py @@ -0,0 +1,64 @@ +import matplotlib.pyplot as plt +import csv + + +def gen_gantt(extra_info, testname): + block_list = [] + start_list = [] + finish_list = [] + duration_list = [] + + start_c = '' + finish_c = '' + sam_name = '' + + for k in extra_info.keys(): + print(k, sam_name) + if "done_cycles" in k: + sam_name = k.split('/')[0] + finish_c = extra_info[k] + if not isinstance(finish_c, int): + finish_list.insert(0, int(finish_c)) + else: + finish_list.insert(0, finish_c) + elif ("start_cycle" in k) and (sam_name in k.split('/')[0]): + ''' + We assume that the info to extra_info is added + in the same order each block is updated. + If we assume the opposite order, use append function + instea of insert. + (e.g.) block_list.insert(0, sam_name) -> block_list.append(sam_name) + ''' + block_list.insert(0, sam_name) + start_c = extra_info[k] + if not isinstance(start_c, int): + start_list.insert(0, int(start_c)) + duration_list.insert(0, finish_c - int(start_c)) + else: + 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 + if "backpressure" in extra_info.keys() and extra_info["backpressure"]: + back_depth = extra_info["depth"] + + print(finish_list, block_list, start_list, duration_list) + + # Writing cycle info to csv 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"]) + for idx, block in reversed(list(enumerate(block_list))): + 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") + for k in extra_info.keys(): + if "/" in k: + 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" + 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 af03c87a..80347a06 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_ikj.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_ikj.py @@ -16,9 +16,11 @@ import os import csv import numpy +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')) -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')) @@ -29,11 +31,9 @@ reason='CI lacks datasets', ) @pytest.mark.synth -@pytest.mark.parametrize("sparsity", [0.95]) -def test_reorder_matmul_ikj(samBench, sparsity, check_gold, debug_sim, backpressure, depth, fill=0): - - # DCSR - B_dirname = os.path.join(synthetic_dir, f"matrix/DCSR/B_random_sp_{sparsity}/") +# @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) @@ -51,7 +51,7 @@ def test_reorder_matmul_ikj(samBench, sparsity, check_gold, debug_sim, backpress B_vals = read_inputs(B_vals_filename, float) # DCSR - C_dirname = os.path.join(synthetic_dir, f"matrix/DCSR/C_random_sp_{sparsity}/") + C_dirname = B_dirname C_shape_filename = os.path.join(C_dirname, "tensor_C_mode_shape") C_shape = read_inputs(C_shape_filename) @@ -68,6 +68,10 @@ def test_reorder_matmul_ikj(samBench, sparsity, check_gold, debug_sim, backpress C_vals_filename = os.path.join(C_dirname, "tensor_C_mode_vals") C_vals = read_inputs(C_vals_filename, float) + # THIS IS FOR SIZE INFO + Bs_dirname = B_dirname + Bs_seg = read_inputs(os.path.join(Bs_dirname, "tensor_B_mode_0_seg")) + # B_dirname = os.path.join(formatted_dir, ssname, "orig", "ss01") # B_shape_filename = os.path.join(B_dirname, "B_shape.txt") # B_shape = read_inputs(B_shape_filename) @@ -227,41 +231,43 @@ def bench(): extra_info["cycles"] = time_cnt extra_info["tensor_B_shape"] = B_shape extra_info["tensor_C_shape"] = C_shape - # sample_dict = spaccumulator1_3.return_statistics() - # for k in sample_dict.keys(): - # extra_info["spaccumulator1_3" + "_" + k] = sample_dict[k] + sample_dict = spaccumulator1_3.return_statistics() + for k in sample_dict.keys(): + extra_info["spaccumulator1_3" + "_" + k] = sample_dict[k] + + sample_dict = fiberwrite_Xvals_0.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_Xvals_0.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X1_1.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X1_1" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X1_1.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X1_1" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X0_2.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X0_2" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X0_2.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X0_2" + "_" + k] = sample_dict[k] + sample_dict = repeat_Ci_16.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Ci_16" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Ci_16.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Ci_16" + "_" + k] = sample_dict[k] + sample_dict = intersectk_13.return_statistics() + for k in sample_dict.keys(): + extra_info["intersectk_13" + "_" + k] = sample_dict[k] - # sample_dict = intersectk_13.return_statistics() - # for k in sample_dict.keys(): - # extra_info["intersectk_13" + "_" + k] = sample_dict[k] + sample_dict = repeat_Bj_9.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Bj_9" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Bj_9.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Bj_9" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_B_7.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_B_7" + "_" + k] = sample_dict[k] - # sample_dict = arrayvals_B_7.return_statistics() - # for k in sample_dict.keys(): - # extra_info["arrayvals_B_7" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_C_8.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_C_8" + "_" + k] = sample_dict[k] - # 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: print("Checking 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 0b7e4388..6afbe6df 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_jik.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_jik.py @@ -16,6 +16,8 @@ import csv from sam.onyx.generate_matrices import create_matrix_from_point_list, get_tensor_from_files import numpy +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')) formatted_dir = os.getenv('FROSTT_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) @@ -212,41 +214,43 @@ def bench(): extra_info["cycles"] = time_cnt extra_info["tensor_B_shape"] = B_shape extra_info["tensor_C_shape"] = C_shape - # sample_dict = fiberwrite_X1_2.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X1_2" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X1_2.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X1_2" + "_" + k] = sample_dict[k] + + sample_dict = repeat_Bj_14.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Bj_14" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Bj_14.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Bj_14" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X0_1.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X0_1" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X0_1.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X0_1" + "_" + k] = sample_dict[k] + sample_dict = repeat_Ci_10.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Ci_10" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Ci_10.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Ci_10" + "_" + k] = sample_dict[k] + sample_dict = intersectk_7.return_statistics() + for k in sample_dict.keys(): + extra_info["intersectk_7" + "_" + k] = sample_dict[k] - # sample_dict = intersectk_7.return_statistics() - # for k in sample_dict.keys(): - # extra_info["intersectk_7" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_B_5.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_B_5" + "_" + k] = sample_dict[k] - # sample_dict = arrayvals_B_5.return_statistics() - # for k in sample_dict.keys(): - # extra_info["arrayvals_B_5" + "_" + k] = sample_dict[k] + sample_dict = reduce_3.return_statistics() + for k in sample_dict.keys(): + extra_info["reduce_3" + "_" + k] = sample_dict[k] - # sample_dict = reduce_3.return_statistics() - # for k in sample_dict.keys(): - # extra_info["reduce_3" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_Xvals_0.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_Xvals_0.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_C_6.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_C_6" + "_" + k] = sample_dict[k] - # 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: print("Checking gold...") diff --git a/sam/sim/test/reorder-study/test_reorder_matmul_jki.py b/sam/sim/test/reorder-study/test_reorder_matmul_jki.py index 6511ddc6..8e12287d 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_jki.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_jki.py @@ -16,6 +16,8 @@ import csv from sam.onyx.generate_matrices import create_matrix_from_point_list, get_tensor_from_files import numpy +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')) formatted_dir = os.getenv('FROSTT_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) @@ -234,41 +236,43 @@ def bench(): extra_info["cycles"] = time_cnt extra_info["tensor_B_shape"] = B_shape extra_info["tensor_C_shape"] = C_shape - # sample_dict = spaccumulator1_3.return_statistics() - # for k in sample_dict.keys(): - # extra_info["spaccumulator1_3" + "_" + k] = sample_dict[k] + sample_dict = spaccumulator1_3.return_statistics() + for k in sample_dict.keys(): + extra_info["spaccumulator1_3" + "_" + k] = sample_dict[k] + + sample_dict = fiberwrite_Xvals_0.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_Xvals_0.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X0_1.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X0_1" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X0_1.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X0_1" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X1_2.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X1_2" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X1_2.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X1_2" + "_" + k] = sample_dict[k] + sample_dict = repeat_Bj_16.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Bj_16" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Bj_16.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Bj_16" + "_" + k] = sample_dict[k] + sample_dict = intersectk_13.return_statistics() + for k in sample_dict.keys(): + extra_info["intersectk_13" + "_" + k] = sample_dict[k] - # sample_dict = intersectk_13.return_statistics() - # for k in sample_dict.keys(): - # extra_info["intersectk_13" + "_" + k] = sample_dict[k] + sample_dict = repeat_Ci_9.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Ci_9" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Ci_9.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Ci_9" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_C_8.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_C_8" + "_" + k] = sample_dict[k] - # sample_dict = arrayvals_C_8.return_statistics() - # for k in sample_dict.keys(): - # extra_info["arrayvals_C_8" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_B_7.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_B_7" + "_" + k] = sample_dict[k] - # sample_dict = arrayvals_B_7.return_statistics() - # for k in sample_dict.keys(): - # extra_info["arrayvals_B_7" + "_" + k] = sample_dict[k] + gen_gantt(extra_info, "matmul_jki") if check_gold: print("Checking gold...") diff --git a/sam/sim/test/reorder-study/test_reorder_matmul_kij.py b/sam/sim/test/reorder-study/test_reorder_matmul_kij.py index c16f522a..8ea0851c 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_kij.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_kij.py @@ -16,6 +16,8 @@ import csv from sam.onyx.generate_matrices import create_matrix_from_point_list, get_tensor_from_files import numpy +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')) formatted_dir = os.getenv('FROSTT_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) @@ -230,41 +232,43 @@ def bench(): extra_info["cycles"] = time_cnt 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] + sample_dict = intersectk_16.return_statistics() + for k in sample_dict.keys(): + extra_info["intersectk_16" + "_" + k] = sample_dict[k] + + sample_dict = spaccumulator2_3.return_statistics() + for k in sample_dict.keys(): + extra_info["spaccumulator2_3" + "_" + k] = sample_dict[k] - # sample_dict = spaccumulator2_3.return_statistics() - # for k in sample_dict.keys(): - # extra_info["spaccumulator2_3" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_Xvals_0.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_Xvals_0.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X1_1.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X1_1" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X1_1.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X1_1" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X0_2.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X0_2" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X0_2.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X0_2" + "_" + k] = sample_dict[k] + sample_dict = repeat_Ci_12.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Ci_12" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Ci_12.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Ci_12" + "_" + k] = sample_dict[k] + sample_dict = repeat_Bj_8.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Bj_8" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Bj_8.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Bj_8" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_B_6.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_B_6" + "_" + k] = sample_dict[k] - # sample_dict = arrayvals_B_6.return_statistics() - # for k in sample_dict.keys(): - # extra_info["arrayvals_B_6" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_C_7.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_C_7" + "_" + k] = sample_dict[k] - # sample_dict = arrayvals_C_7.return_statistics() - # for k in sample_dict.keys(): - # extra_info["arrayvals_C_7" + "_" + k] = sample_dict[k] + gen_gantt(extra_info, "matmul_kij") if check_gold: print("Checking 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 184ca2c4..60284171 100644 --- a/sam/sim/test/reorder-study/test_reorder_matmul_kji.py +++ b/sam/sim/test/reorder-study/test_reorder_matmul_kji.py @@ -16,6 +16,8 @@ import csv from sam.onyx.generate_matrices import create_matrix_from_point_list, get_tensor_from_files import numpy +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')) formatted_dir = os.getenv('FROSTT_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats')) @@ -31,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") @@ -230,41 +231,44 @@ def bench(): extra_info["cycles"] = time_cnt 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] - # sample_dict = repeat_Bj_12.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Bj_12" + "_" + k] = sample_dict[k] + sample_dict = intersectk_16.return_statistics() + for k in sample_dict.keys(): + extra_info["intersectk_16" + "_" + k] = sample_dict[k] + + sample_dict = repeat_Bj_12.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Bj_12" + "_" + k] = sample_dict[k] + + sample_dict = spaccumulator2_3.return_statistics() + for k in sample_dict.keys(): + extra_info["spaccumulator2_3" + "_" + k] = sample_dict[k] - # sample_dict = spaccumulator2_3.return_statistics() - # for k in sample_dict.keys(): - # extra_info["spaccumulator2_3" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_Xvals_0.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_Xvals_0.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_Xvals_0" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X0_1.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X0_1" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X0_1.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X0_1" + "_" + k] = sample_dict[k] + sample_dict = fiberwrite_X1_2.return_statistics() + for k in sample_dict.keys(): + extra_info["fiberwrite_X1_2" + "_" + k] = sample_dict[k] - # sample_dict = fiberwrite_X1_2.return_statistics() - # for k in sample_dict.keys(): - # extra_info["fiberwrite_X1_2" + "_" + k] = sample_dict[k] + sample_dict = repeat_Ci_8.return_statistics() + for k in sample_dict.keys(): + extra_info["repeat_Ci_8" + "_" + k] = sample_dict[k] - # sample_dict = repeat_Ci_8.return_statistics() - # for k in sample_dict.keys(): - # extra_info["repeat_Ci_8" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_C_7.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_C_7" + "_" + k] = sample_dict[k] - # sample_dict = arrayvals_C_7.return_statistics() - # for k in sample_dict.keys(): - # extra_info["arrayvals_C_7" + "_" + k] = sample_dict[k] + sample_dict = arrayvals_B_6.return_statistics() + for k in sample_dict.keys(): + extra_info["arrayvals_B_6" + "_" + k] = sample_dict[k] - # 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: print("Checking gold...") diff --git a/sam/util.py b/sam/util.py index 0658de93..b023147d 100644 --- a/sam/util.py +++ b/sam/util.py @@ -602,54 +602,3 @@ def safeCastPydataTensorToInts(tensor): # data[i] = int(tensor.data[i]) data[i] = round_sparse(tensor.data[i]) return sparse.COO(tensor.coords, data, tensor.shape) - - -def parse_taco_format(infilename, outdir, tensorname, format_str): - with open(infilename, 'r') as inf: - level = -1 - count = 0 - seg = True - level_done = False - for line in inf: - if count == 0: - dim_start = line.find('(') + 1 - dim_end = line.find(')') - dims = line[dim_start: dim_end] - dims = dims.split('x') - - shapefile = os.path.join(outdir, tensorname + '_shape.txt') - with open(shapefile, 'w+') as shapef: - shapef.write(array_newline_str(dims)) - else: - if line.find(':') > -1: - level += 1 - seg = True - level_done = False - else: - start = line.find('[') + 1 - end = line.find(']') - line = line[start: end] - line = line.split(', ') - - if level_done: - # This is a values array - valfile = os.path.join(outdir, tensorname + '_vals.txt') - with open(valfile, 'w+') as valf: - valf.write(array_newline_str(line)) - else: - level_format = format_str[level] - if level_format == 's': - if seg: - segfile = os.path.join(outdir, tensorname + str(level) + - '_seg.txt') - with open(segfile, 'w+') as segf: - segf.write(array_newline_str(line)) - seg = False - else: - crdfile = os.path.join(outdir, tensorname + str(level) + - '_crd.txt') - with open(crdfile, 'w+') as crdf: - crdf.write(array_newline_str(line)) - level_done = True - - count += 1 diff --git a/scripts/formatting/datastructure_tns.py b/scripts/formatting/datastructure_tns.py index aede2dbc..7ff46056 100644 --- a/scripts/formatting/datastructure_tns.py +++ b/scripts/formatting/datastructure_tns.py @@ -1,7 +1,7 @@ import argparse import os from pathlib import Path -from sam.util import parse_taco_format +from scripts.util.util import parse_taco_format cwd = os.getcwd() diff --git a/scripts/formatting/generate_frostt_formats.sh b/scripts/formatting/generate_frostt_formats.sh index a83e76c7..26310bf8 100755 --- a/scripts/formatting/generate_frostt_formats.sh +++ b/scripts/formatting/generate_frostt_formats.sh @@ -22,12 +22,6 @@ FORMATS=( sss012 ) -#export SUITESPARSE_PATH=/nobackup/owhsu/sparse-datasets/suitesparse/ -#export FROSTT_PATH=/nobackup/owhsu/sparse-datasets/frostt/ -#export SUITESPARSE_FORMATTED_PATH=/nobackup/owhsu/sparse-datasets/suitesparse-formatted -#export FROSTT_FORMATTED_TACO_PATH=/nobackup/owhsu/sparse-datasets/frostt-formatted/taco-tensor -#export FROSTT_FORMATTED_PATH=/nobackup/owhsu/sparse-datasets/frostt-formatted - basedir=$(pwd) for i in ${!FORMATS[@]}; do diff --git a/scripts/formatting/generate_suitesparse_formats.sh b/scripts/formatting/generate_suitesparse_formats.sh index 8e74b9a1..3776800c 100755 --- a/scripts/formatting/generate_suitesparse_formats.sh +++ b/scripts/formatting/generate_suitesparse_formats.sh @@ -22,7 +22,7 @@ OTHERBENCHES='["mat_residual", "mat_mattransmul", "mat_vecmul"]' # THIS FILE MUST BE RUN FROM sam/ location outdir=${SUITESPARSE_FORMATTED_PATH} basedir=$(pwd) -textfile=$basedir/scripts/tensor_names/$1 +textfile=$basedir/$1 mkdir -p $outdir cd $outdir diff --git a/scripts/gen_sam_apps/test_generating_code.py b/scripts/gen_sam_apps/test_generating_code.py index d92b39b9..17bfa91b 100755 --- a/scripts/gen_sam_apps/test_generating_code.py +++ b/scripts/gen_sam_apps/test_generating_code.py @@ -151,8 +151,11 @@ def generate_header(f, out_name): f.write("from sam.sim.src.token import *\n") f.write("from sam.sim.test.test import *\n") f.write("from sam.sim.test.gold import *\n") + f.write("from sam.sim.test.gen_gantt import gen_gantt\n") + f.write("\n") f.write("import os\n") f.write("import csv\n") + f.write("\n") f.write("cwd = os.getcwd()\n") if out_name in suitesparse_list: f.write("formatted_dir = os.getenv('SUITESPARSE_FORMATTED_PATH', default=os.path.join(cwd, 'mode-formats'))\n") @@ -195,6 +198,19 @@ def get_common_test_name(test_name): return test_name +def get_out_crd_str(d, u_, index_value): + # By default, the input primitive connected to a crddrop will be a level scanner + out_crd_str = "out_crd" + # However, if the input primitive is another crddrop, we need to make sure it's reading from + # the correct input crddrop output. + if d[u_]["type"] == "crddrop": + if index_value == d[u_]["inner"]: + out_crd_str += "_inner" + elif index_value == d[u_]["outer"]: + out_crd_str += "_outer" + return out_crd_str + + def generate_datasets_code(f, tensor_formats, scope_lvl, tensor_info, tensor_format_parse, test_name): # Assuming the format is csr and csc: for ten in tensor_format_parse.return_all_tensors(): @@ -402,8 +418,12 @@ def finish_outputs(f, elements, nodes_completed): def generate_benchmarking_code(f, tensor_format_parse, test_name): - f.write("\n" + tab(1) + "def bench():\n") + f.write("\n") + f.write(tab(1) + "# Print out cycle count for pytest output\n") + f.write(tab(1) + "print(time_cnt)\n") + f.write(tab(1) + "def bench():\n") f.write(tab(2) + "time.sleep(0.01)\n\n") + f.write("\n") f.write(tab(1) + "extra_info = dict()\n") f.write(tab(1) + "extra_info[\"dataset\"] = " + get_dataset_name(test_name) + "\n") f.write(tab(1) + "extra_info[\"cycles\"] = time_cnt\n") @@ -422,7 +442,10 @@ def generate_benchmarking_code(f, tensor_format_parse, test_name): if d[u]["type"] in statistic_available: f.write(tab(1) + "sample_dict = " + d[u]["object"] + ".return_statistics()\n") f.write(tab(1) + "for k in sample_dict.keys():\n") - f.write(tab(2) + "extra_info[\"" + d[u]["object"] + "\" + \"_\" + k] = sample_dict[k]\n\n") + f.write(tab(2) + "extra_info[\"" + d[u]["object"] + "\" + \"/\" + k] = sample_dict[k]\n\n") + + f.write(tab(1) + "gen_gantt(extra_info, \"" + test_name + "\")\n") + f.write("\n") def generate_check_against_gold_code(f, tensor_format_parse, test_name): @@ -529,7 +552,7 @@ def get_all_files(directory_path): continue out_name.append(filename[0:-3]) # checking if it is a file - print(out_name[-1]) + print("Test Name:", out_name[-1]) if os.path.isfile(f): file_paths.append(f) return file_paths, out_name @@ -800,9 +823,13 @@ def get_all_files(directory_path): for u_ in data.get_parents()[v]: index_value = data.get_edge_data()[v][data.get_parents()[v].index(u_)][-1] if index_value == d[v]["inner"]: - f.write(tab(2) + d[v]["object"] + ".set_inner_crd" + "(" + d[u_]["object"] + ".out_crd())\n") + out_crd_str = get_out_crd_str(d, u_, index_value) + f.write(tab(2) + d[v]["object"] + ".set_inner_crd" + "(" + d[u_]["object"] + "." + + out_crd_str + "())\n") if index_value == d[v]["outer"]: - f.write(tab(2) + d[v]["object"] + ".set_outer_crd" + "(" + d[u_]["object"] + ".out_crd())\n") + out_crd_str = get_out_crd_str(d, u_, index_value) + f.write(tab(2) + d[v]["object"] + ".set_outer_crd" + "(" + d[u_]["object"] + "." + + out_crd_str + "())\n") nodes_updating_list.append(tab(2) + d[v]["object"] + ".update()\n") # f.write(tab(2) + d[v]["object"] + ".update()\n\n") data.add_done(v) @@ -923,7 +950,6 @@ def get_all_files(directory_path): if "val" not in data.get_edge_data()[v][i] and "spaccumulator" \ in d[u_]["object"]: local_index = data.get_edge_data()[v][i][-1] - print(d[u_], " ", local_index, " ", apath) if d[u_]["in0"] == local_index: local_cord = "_inner" else: diff --git a/scripts/run_cpu/frostt_runner.sh b/scripts/run_cpu/frostt_runner.sh index e8d6dfac..dbc53445 100755 --- a/scripts/run_cpu/frostt_runner.sh +++ b/scripts/run_cpu/frostt_runner.sh @@ -15,18 +15,16 @@ DATASET_NAMES=( nell-1 ) +sspath=$SUITESPARSE_PATH cwd=$(pwd) # LANKA if [ $1 -eq 1 ]; then - sspath=/data/scratch/changwan/florida_all/. lanka=ON neva=OFF elif [ $1 -eq 2 ]; then - sspath=/nobackup/owhsu/sparse-datasets/suitesparse lanka=OFF neva=ON else - sspath=cwd/. lanka=OFF neva=OFF fi diff --git a/scripts/run_onyx/sam_hw_suitesparse_runner.sh b/scripts/run_onyx/sam_hw_suitesparse_runner.sh index e9748bf1..adf680e3 100755 --- a/scripts/run_onyx/sam_hw_suitesparse_runner.sh +++ b/scripts/run_onyx/sam_hw_suitesparse_runner.sh @@ -29,25 +29,20 @@ errors=() RED='\033[0;31m' NC='\033[0m' # No Color +mkdir -p $TACO_TENSOR_PATH +mkdir -p $SUITESPARSE_FORMATTED_PATH +mkdir -p $FROSTT_FORMATTED_TACO_PATH +mkdir -p $FROSTT_FORMATTED_PATH + # LANKA if [ $2 -eq 1 ]; then - export SUITESPARSE_PATH=/data/scratch/changwan/florida_all - export FROSTT_PATH=/data/scratch/owhsu/datasets/frostt - export TACO_TENSOR_PATH=/data/scratch/owhsu/datasets - export SUITESPARSE_FORMATTED_PATH=/data/scratch/owhsu/datasets/suitesparse-formatted - export FROSTT_FORMATTED_TACO_PATH=/data/scratch/owhsu/datasets/frostt-formatted/taco-tensor - export FROSTT_FORMATTED_PATH=/data/scratch/owhsu/datasets/frostt-formatted - - mkdir -p $TACO_TENSOR_PATH - mkdir -p $SUITESPARSE_FORMATTED_PATH - mkdir -p $FROSTT_FORMATTED_TACO_PATH - mkdir -p $FROSTT_FORMATTED_PATH - lanka=ON neva=OFF +# KIWI/NEVA elif [ $2 -eq 2 ]; then lanka=OFF neva=ON +# Local Machine else lanka=OFF neva=OFF diff --git a/scripts/run_sam_sim/pytest_frostt.sh b/scripts/run_sam_sim/pytest_frostt.sh index ffc770a1..ba78463f 100755 --- a/scripts/run_sam_sim/pytest_frostt.sh +++ b/scripts/run_sam_sim/pytest_frostt.sh @@ -7,15 +7,12 @@ # Script that runs ALL test_tensor* pytest tests under sam/sim/test -outdir=/nobackup/owhsu/sparse-datasets/frostt-formatted +outdir=$FROSTT_FORMATTED_PATH errors=() RED='\033[0;31m' NC='\033[0m' # No Color -export FROSTT_PATH=/nobackup/owhsu/sparse-datasets/frostt -export FROSTT_FORMATTED_PATH=$outdir - mkdir -p $outdir cd ./sam/sim diff --git a/scripts/run_sam_sim/pytest_frostt_with_benchmarks.sh b/scripts/run_sam_sim/pytest_frostt_with_benchmarks.sh index da73cbb8..8056c3eb 100755 --- a/scripts/run_sam_sim/pytest_frostt_with_benchmarks.sh +++ b/scripts/run_sam_sim/pytest_frostt_with_benchmarks.sh @@ -14,11 +14,7 @@ BENCHMARKS=( tensor_mttkrp ) -outdir=/nobackup/owhsu/sparse-datasets/frostt-formatted - -export FROSTT_PATH=/nobackup/owhsu/sparse-datasets/frostt -export FROSTT_FORMATTED_PATH=$outdir - +outdir=$FROSTT_FORMATTED_PATH errors=() RED='\033[0;31m' diff --git a/scripts/run_sam_sim/run_suitesparse.sh b/scripts/run_sam_sim/run_suitesparse.sh index 2b3da4ce..a6b26601 100755 --- a/scripts/run_sam_sim/run_suitesparse.sh +++ b/scripts/run_sam_sim/run_suitesparse.sh @@ -8,15 +8,13 @@ # ./scripts/run_sam_sim/run_suitesparse.sh # THIS FILE MUST BE RUN FROM sam/ location -outdir=/nobackup/owhsu/sparse-datasets/suitesparse-formatted +outdir=$SUITESPARSE_FORMATTED_PATH basedir=$(pwd) errors=() RED='\033[0;31m' NC='\033[0m' # No Color -export SUITESPARSE_PATH=/nobackup/owhsu/sparse-datasets/suitesparse -export SUITESPARSE_FORMATTED_PATH=$outdir mkdir -p $outdir diff --git a/scripts/run_sam_sim/run_suitesparse_final.sh b/scripts/run_sam_sim/run_suitesparse_final.sh index d2480f74..eac4e371 100755 --- a/scripts/run_sam_sim/run_suitesparse_final.sh +++ b/scripts/run_sam_sim/run_suitesparse_final.sh @@ -4,7 +4,7 @@ #SBATCH -p lanka-v3 #SBATCH --exclusive -# ./scripts/run_sam_sim/run +# ./scripts/run_sam_sim/run_suitesparse_final.sh pushd . cd sam/sim diff --git a/scripts/run_sam_sim/sam_suitesparse_runner.sh b/scripts/run_sam_sim/sam_suitesparse_runner.sh index 5604f524..ff78826f 100755 --- a/scripts/run_sam_sim/sam_suitesparse_runner.sh +++ b/scripts/run_sam_sim/sam_suitesparse_runner.sh @@ -9,12 +9,12 @@ set -u BENCHMARKS=( -# mat_vecmul_FINAL + mat_vecmul_FINAL matmul_FINAL -# mat_elemadd_FINAL -# mat_elemadd3_FINAL -# mat_residual_FINAL -# mat_mattransmul_FINAL + mat_elemadd_FINAL + mat_elemadd3_FINAL + mat_residual_FINAL + mat_mattransmul_FINAL ) errors=() diff --git a/scripts/tiling/few_points_memory_model_runner.sh b/scripts/tiling/few_points_memory_model_runner.sh index 02ba18e3..5d36eae2 100755 --- a/scripts/tiling/few_points_memory_model_runner.sh +++ b/scripts/tiling/few_points_memory_model_runner.sh @@ -64,9 +64,9 @@ for b in ${!BENCHMARKS[@]}; do line=random_sparsity cd $basedir/sam/sim if [ $2 -eq 1 ]; then - pytest test/advanced-simulator/test_$bench.py --ssname $line -s --check-gold --skip-empty --nbuffer --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json + pytest test/advanced-simulator/test_$bench.py --ssname $line -s --check-gold --skip-empty --nbuffer --memory-model --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json else - pytest test/advanced-simulator/test_$bench.py --ssname $line -s --skip-empty --nbuffer --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json + pytest test/advanced-simulator/test_$bench.py --ssname $line -s --skip-empty --nbuffer --memory-model --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json fi python $basedir/scripts/util/converter.py --json_name $path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json diff --git a/scripts/tiling/full_memory_model_runner.sh b/scripts/tiling/full_memory_model_runner.sh index 190239df..d785a14c 100755 --- a/scripts/tiling/full_memory_model_runner.sh +++ b/scripts/tiling/full_memory_model_runner.sh @@ -65,9 +65,9 @@ for b in ${!BENCHMARKS[@]}; do line=random_sparsity cd $basedir/sam/sim if [ $2 -eq 1 ]; then - pytest test/advanced-simulator/test_$bench.py --ssname $line -s --check-gold --skip-empty --nbuffer --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json + pytest test/advanced-simulator/test_$bench.py --ssname $line -s --check-gold --skip-empty --nbuffer --memory-model --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json else - pytest test/advanced-simulator/test_$bench.py --ssname $line -s --skip-empty --nbuffer --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json + pytest test/advanced-simulator/test_$bench.py --ssname $line -s --skip-empty --nbuffer --memory-model --yaml_name=$1 --nnz-value=${NNZ[$nnz]} --benchmark-json=$path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json fi python $basedir/scripts/util/converter.py --json_name $path/${line}_${NNZ[$nnz]}_${DIMENSIONS[$dim]}.json diff --git a/scripts/tiling/generate_gold_matmul_tiled.py b/scripts/tiling/generate_gold_matmul_tiled.py index 55be3674..4fa3bfe3 100644 --- a/scripts/tiling/generate_gold_matmul_tiled.py +++ b/scripts/tiling/generate_gold_matmul_tiled.py @@ -67,17 +67,12 @@ def generate_gold_matmul_tiled(tile_crd_b, tile_crd_c, dirname, out_format="ss01 if __name__ == "__main__": parser = argparse.ArgumentParser(description="Generate tiled output gold") - parser.add_argument("--yaml_name", type=str, default="memory_config_real.yaml") + parser.add_argument("--yaml_name", type=str, default="memory_config_onyx.yaml") args = parser.parse_args() outdir = "./tiles/matmul_ikj/output/" outpath = Path(outdir) outpath.mkdir(parents=True, exist_ok=True) - # generate_gold_matmul_tiled([0, 1, 2, 9], [1, 0, 9, 0], outdir) - - # generate_gold_matmul_tiled([0, 1, 0, 7], [1, 0, 7, 0], outdir) - # quit() with open("/nobackup/rsharma3/Sparsity/simulator/old_sam/sam/tiles/matmul_ikj/tensor_sizes", "rb") as ff: - with open("./tiles/matmul_ikj/tensor_sizes", "rb") as ff: sizes_dict_level_full = pickle.load(ff) diff --git a/scripts/tiling/single_point_memory_model_runner.sh b/scripts/tiling/single_point_memory_model_runner.sh index a21b2d30..30b5ee4c 100755 --- a/scripts/tiling/single_point_memory_model_runner.sh +++ b/scripts/tiling/single_point_memory_model_runner.sh @@ -36,7 +36,7 @@ rm -rf $basedir/tiles/* ./scripts/tiling/prepare_files.sh $fname cd $basedir/sam/sim -pytest test/advanced-simulator/test_$bench.py --ssname $line -s --check-gold --skip-empty --nbuffer --yaml_name=$yaml_fname --nnz-value=$nnz --benchmark-json=$path/${line}_${nnz}_${dim}.json +pytest test/advanced-simulator/test_$bench.py --ssname $line -s --check-gold --skip-empty --nbuffer --yaml_name=$yaml_fname --memory-model --nnz-value=$nnz --benchmark-json=$path/${line}_${nnz}_${dim}.json python $basedir/scripts/util/converter.py --json_name $path/${line}_${nnz}_${dim}.json