Skip to content

Commit

Permalink
update mapped input port storing logic, compute to compute connetion …
Browse files Browse the repository at this point in the history
…logic, and dedicated reduce primitive mapping logic
  • Loading branch information
bobcheng15 committed Jan 21, 2024
1 parent 8946ec5 commit 56744d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
9 changes: 5 additions & 4 deletions sam/onyx/hw_nodes/compute_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def connect(self, other, edge, kwargs=None):
other_conn = 1
else:
assert 0 & "edge connected to faddiexp has to have comment specified to either 'exp' or 'fp'"
else:
other_conn = other.mapped_input_ports[other_conn]
new_conns = {
f'pe_to_pe_{other_conn}': [
([(pe, "res"), (other_pe, f"data{other_conn}")], 17),
Expand Down Expand Up @@ -183,7 +185,7 @@ def parse_mapped_json(self, filename, node_id):
# if the connection is to the data port of alu
if "self.in" in src:
# get the port name of the alu
self.mapped_input_ports.append(dest.split(".")[1])
self.mapped_input_ports.append(dest.split(".")[1].strip("data"))
self.opcode = int(opcode, 0)

def configure(self, attributes):
Expand All @@ -201,9 +203,8 @@ def configure(self, attributes):
pe_in_external = 1
# according to the mapped input ports generate input port config
num_sparse_inputs = list("000")
for i in range(3):
if f"data{2 - i}" in self.mapped_input_ports:
num_sparse_inputs[i] = '1'
for port in self.mapped_input_ports:
num_sparse_inputs[2 - int(port)] = '1'
print("".join(num_sparse_inputs))
num_sparse_inputs = int("".join(num_sparse_inputs), 2)

Expand Down
2 changes: 1 addition & 1 deletion sam/onyx/hw_nodes/read_scanner_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def connect(self, other, edge, kwargs=None):
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, other.mapped_input_ports[compute_conn])], 17),
([(rd_scan, "coord_out"), (compute, f"data{other.mapped_input_ports[compute_conn]}")], 17),
]
}
# Now update the PE/compute to use the next connection next time
Expand Down
9 changes: 8 additions & 1 deletion sam/onyx/hw_nodes/reduce_node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from sam.onyx.hw_nodes.hw_node import *
from peak.assembler import Assembler
from hwtypes.modifiers import strip_modifiers
from lassen.sim import PE_fc as lassen_fc
import lassen.asm as asm


class ReduceNode(HWNode):
Expand Down Expand Up @@ -112,7 +116,10 @@ def configure(self, attributes):
# data I/O to and from the PE should be internal with the reduce
pe_in_external = 0
# op is set to integer add for the PE TODO: make this configurable in the sam graph
op = 0
# TODO: make this use the metamapper
instr_type = strip_modifiers(lassen_fc.Py.input_t.field_dict['inst'])
asm_ = Assembler(instr_type)
op = int(asm_.assemble(asm.add()))
cfg_kwargs = {
'stop_lvl': stop_lvl,
'pe_connected_to_reduce': pe_connected_to_reduce,
Expand Down

0 comments on commit 56744d9

Please sign in to comment.