Skip to content

Commit

Permalink
Merge pull request #94 from weiya711/gen_gantt_merged
Browse files Browse the repository at this point in the history
Gen gantt merged
  • Loading branch information
kalhankoul96 authored Oct 11, 2023
2 parents 2b1d0bf + 15833ac commit 08c2205
Show file tree
Hide file tree
Showing 35 changed files with 374 additions and 414 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ cmake-build-*/
# Generated SAM Graphs
*.gv

venv/

# Generated images
*.svg
*.png
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: aha
name: sam
channels:
- pytorch
- anaconda
Expand Down Expand Up @@ -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
59 changes: 4 additions & 55 deletions sam/sim/src/accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,13 @@ 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:
self.fifo_avail = False
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()
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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:
Expand All @@ -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]
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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())

Expand Down Expand Up @@ -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:
Expand All @@ -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,
Expand Down
13 changes: 1 addition & 12 deletions sam/sim/src/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion sam/sim/src/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 0 additions & 5 deletions sam/sim/src/joiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 6 additions & 19 deletions sam/sim/src/rd_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions sam/sim/src/repeater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions sam/sim/src/wr_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
Loading

0 comments on commit 08c2205

Please sign in to comment.