Skip to content

Commit

Permalink
added mapping and routing support for fp_max, fp_add and faddiexp ins…
Browse files Browse the repository at this point in the history
…truction for the alu
  • Loading branch information
bobcheng15 committed Dec 14, 2023
1 parent 18e2b2d commit d132d85
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
16 changes: 13 additions & 3 deletions sam/onyx/hw_nodes/compute_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ def connect(self, other, edge, kwargs=None):
other_conn = other.get_num_inputs()
pe = self.get_name()
# TODO: remove hack eventually
if 'Max' in other.op:
if 'Max 0' in other.op:
other_conn = 1
else:
other_conn = other.get_num_inputs()
elif 'Faddiexp' in other.op:
comment = edge.get_attributes()["comment"].strip('"')
if 'fp' in comment:
other_conn = 0
elif 'exp' in comment:
other_conn = 1
else:
assert 0 & "edge connected to faddiexp has to have comment specified to either 'exp' or 'fp'"
new_conns = {
f'pe_to_pe_{other_conn}': [
([(pe, "res"), (other_pe, f"data{other_conn}")], 17),
Expand Down Expand Up @@ -186,6 +192,10 @@ def configure(self, attributes):
op_code = 8
elif c_op == 'faddiexp':
op_code = 9
elif c_op == 'fp_max':
op_code = 10
elif c_op == 'fp_add':
op_code = 11

rb_const = None
if "rb_const" in attributes:
Expand Down
10 changes: 9 additions & 1 deletion sam/onyx/hw_nodes/read_scanner_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ def connect(self, other, edge, kwargs=None):
# Can use dynamic information to assign inputs to compute nodes
# since add/mul are commutative
compute_conn = other.get_num_inputs()

# TODO: get rid of this hack
if 'Faddiexp' in other.op:
comment = edge.get_attributes()["comment"].strip('"')
if 'fp' in comment:
compute_conn = 0
elif 'exp' in comment:
compute_conn = 1
else:
assert 0 & "edge connected to faddiexp has to have comment specified to either 'exp' or 'fp'"
new_conns = {
f'rd_scan_to_compute_{compute_conn}': [
([(rd_scan, "coord_out"), (compute, f"data{compute_conn}")], 17),
Expand Down
2 changes: 1 addition & 1 deletion sam/onyx/hw_nodes/reduce_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def connect(self, other, edge, kwargs=None):
raise NotImplementedError(f'Cannot connect ReduceNode to {other_type}')
elif other_type == ComputeNode:
pe = other.get_name()
if 'Max' in other.op:
if 'Max 0' in other.op:
other_conn = 1
else:
other_conn = other.get_num_inputs()
Expand Down
4 changes: 2 additions & 2 deletions sam/onyx/parse_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def map_nodes(self):
hw_nt = f"HWNodeType.RepSigGen"
elif n_type == "repeat":
hw_nt = f"HWNodeType.Repeat"
elif n_type == "mul" or n_type == "add" or n_type == "max":
elif n_type == "mul" or n_type == "add" or n_type == "max" or n_type == "and":
hw_nt = f"HWNodeType.Compute"
elif n_type == "fgetfint" or n_type == "fgetffrac" or n_type == "faddiexp":
hw_nt = f"HWNodeType.Compute"
elif n_type == "fp_mul":
elif n_type == "fp_mul" or n_type == "fp_max" or n_type == "fp_add":
hw_nt = f"HWNodeType.Compute"
elif n_type == "reduce":
hw_nt = f"HWNodeType.Reduce"
Expand Down

0 comments on commit d132d85

Please sign in to comment.