diff --git a/compiler/sam-outputs/onyx-dot/matmul_ikj.gv b/compiler/sam-outputs/onyx-dot/matmul_ikj.gv new file mode 100644 index 00000000..6fbfbc85 --- /dev/null +++ b/compiler/sam-outputs/onyx-dot/matmul_ikj.gv @@ -0,0 +1,44 @@ +digraph SAM { + comment="X=ss01,B=ss01,C=ss01" + 20 [comment="type=vectorreducer,index=j" label="VectorReducer j" color=brown shape=box style=filled type="vectorreducer" accum_index="j"] + 0 [comment="type=fiberwrite,mode=vals,tensor=X,size=1*B0_dim*C1_dim,sink=true" label="FiberWrite Vals: X" color=green3 shape=box style=filled type="fiberwrite" tensor="X" mode="vals" size="1*B0_dim*C1_dim" sink="true"] + 1 [comment="type=fiberwrite,index=j,tensor=X,mode=1,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*C1_dim,sink=true" label="FiberWrite j: X1\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="X" mode="1" format="compressed" segsize="B0_dim+1" crdsize="B0_dim*C1_dim" sink="true"] + 19 [comment="type=fiberlookup,index=i,tensor=B,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: B0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="B" mode="0" format="compressed" src="true" root="true"] + 18 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 2 [comment="type=fiberwrite,index=i,tensor=X,mode=0,format=compressed,segsize=2,crdsize=B0_dim,sink=true" label="FiberWrite i: X0\ncompressed" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="X" mode="0" format="compressed" segsize="2" crdsize="B0_dim" sink="true"] + 17 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 16 [comment="type=repeat,index=i,tensor=C,root=true" label="Repeat i: C" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="C" root="true"] + 15 [comment="type=fiberlookup,index=k,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="0" format="compressed" src="true" root="false"] + 13 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 9 [comment="type=repeat,index=j,tensor=B,root=false" label="Repeat j: B" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="B" root="false"] + 7 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 6 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 12 [comment="type=fiberlookup,index=j,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="1" format="compressed" src="true" root="false"] + 11 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 10 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 8 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 14 [comment="type=fiberlookup,index=k,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="B" mode="1" format="compressed" src="true" root="false"] + 19 -> 18 [label="crd" style=dashed type="crd" comment=""] + 18 -> 17 [label="crd" style=dashed type="crd" comment=""] + 17 -> 16 [label="repsig" style=dotted type="repsig"] + 16 -> 15 [label="ref" style=bold type="ref"] + 15 -> 13 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 13 -> 9 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 9 -> 7 [label="ref" style=bold type="ref"] + 7 -> 6 [label="val" type="val"] + 13 -> 12 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 12 -> 11 [label="crd" style=dashed type="crd" comment=""] + 19 -> 2 [label="crd_i" style=dashed type="crd" comment="i"] + 11 -> 20 [label="crd_j" style=dashed type="crd" comment="j" special="true"] + 11 -> 10 [label="crd" style=dashed type="crd" comment=""] + 10 -> 9 [label="repsig" style=dotted type="repsig"] + 12 -> 8 [label="ref" style=bold type="ref" comment=""] + 8 -> 6 [label="val" type="val"] + 15 -> 13 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 19 -> 14 [label="ref" style=bold type="ref" comment=""] + 14 -> 13 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 14 -> 13 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 6 -> 20 [label="mul_val_out" type="val"] + 20 -> 0 [label="final_vals" type="val"] + 20 -> 1 [label="crd_out-j" style=dashed type="crd" comment="out-j"] +} diff --git a/sam/onyx/hw_nodes/buffet_node.py b/sam/onyx/hw_nodes/buffet_node.py index e2473e9d..828f1337 100644 --- a/sam/onyx/hw_nodes/buffet_node.py +++ b/sam/onyx/hw_nodes/buffet_node.py @@ -124,8 +124,16 @@ def configure(self, attributes): cap0 = kratos.clog2(capacity_0) - fetch_width_log cap1 = kratos.clog2(capacity_1) - fetch_width_log + if 'vector_reduce_mode' in attributes: + is_in_vr_mode = attributes['vector_reduce_mode'].strip('"') + if is_in_vr_mode == "true": + vr_mode = 1 + else: + vr_mode = 0 + cfg_kwargs = { 'capacity_0': cap0, - 'capacity_1': cap1 + 'capacity_1': cap1, + 'vr_mode': vr_mode } - return (capacity_0, capacity_1), cfg_kwargs + return (capacity_0, capacity_1, vr_mode), cfg_kwargs diff --git a/sam/onyx/hw_nodes/compute_node.py b/sam/onyx/hw_nodes/compute_node.py index 2482f399..283b771f 100644 --- a/sam/onyx/hw_nodes/compute_node.py +++ b/sam/onyx/hw_nodes/compute_node.py @@ -62,12 +62,16 @@ def connect(self, other, edge, kwargs=None): pe = self.get_name() # isect_conn = other.get_num_inputs() - if 'tensor' not in edge.get_attributes(): - # Taking some liberties here - but technically this is the combo val - # isect_conn = other.get_connection_from_tensor('B') - isect_conn = other.get_connection_from_tensor('C') + if 'vector_reduce_mode' in edge.get_attributes(): + if edge.get_attributes()['vector_reduce_mode']: + isect_conn = 0 else: - isect_conn = other.get_connection_from_tensor(edge.get_tensor()) + if 'tensor' not in edge.get_attributes(): + # Taking some liberties here - but technically this is the combo val + # isect_conn = other.get_connection_from_tensor('B') + isect_conn = other.get_connection_from_tensor('C') + else: + isect_conn = other.get_connection_from_tensor(edge.get_tensor()) new_conns = { f'pe_to_isect_{in_str}_{isect_conn}': [ diff --git a/sam/onyx/hw_nodes/fiberaccess_node.py b/sam/onyx/hw_nodes/fiberaccess_node.py index 89b12e6e..7e7a3722 100644 --- a/sam/onyx/hw_nodes/fiberaccess_node.py +++ b/sam/onyx/hw_nodes/fiberaccess_node.py @@ -228,9 +228,12 @@ def configure(self, attributes, flavor): cfg_tuple, cfg_kwargs = self.get_flavor(flavor=flavor).configure(attributes) cfg_kwargs['flavor'] = flavor + print("THESE ARE MY CONFIG KWARGS") + print(cfg_kwargs) + # breakpoint() - vr_mode = 0 - cfg_tuple += (vr_mode,) - cfg_kwargs["vr_mode"] = vr_mode + # vr_mode = 0 + # cfg_tuple += (vr_mode,) + # cfg_kwargs["vr_mode"] = vr_mode return cfg_tuple, cfg_kwargs diff --git a/sam/onyx/hw_nodes/hw_node.py b/sam/onyx/hw_nodes/hw_node.py index 5991a225..9b7d8847 100644 --- a/sam/onyx/hw_nodes/hw_node.py +++ b/sam/onyx/hw_nodes/hw_node.py @@ -16,7 +16,7 @@ class HWNodeType(Enum): Broadcast = 12 RepSigGen = 13 CrdHold = 14 - SpAccumulator = 15 + VectorReducer = 15 FiberAccess = 16 diff --git a/sam/onyx/hw_nodes/intersect_node.py b/sam/onyx/hw_nodes/intersect_node.py index 18e20d9e..f84feeef 100644 --- a/sam/onyx/hw_nodes/intersect_node.py +++ b/sam/onyx/hw_nodes/intersect_node.py @@ -180,6 +180,7 @@ def connect(self, other, edge, kwargs=None): print(edge.get_attributes()) edge_comment = edge.get_attributes()['comment'].strip('"') tensor = edge_comment.split('-')[1] + print(self.tensor_to_conn) out_conn = self.tensor_to_conn[tensor] compute_conn = compute.get_num_inputs() new_conns = { @@ -248,6 +249,14 @@ def configure(self, attributes): cmrg_enable = 0 cmrg_stop_lvl = 0 type_op = attributes['type'].strip('"') + + if 'vector_reduce_mode' in attributes: + is_in_vr_mode = attributes['vector_reduce_mode'].strip('"') + if is_in_vr_mode == "true": + vr_mode = 1 + else: + vr_mode = 0 + if type_op == "intersect": op = JoinerOp.INTERSECT.value elif type_op == "union": @@ -258,6 +267,6 @@ def configure(self, attributes): 'cmrg_enable': cmrg_enable, 'cmrg_stop_lvl': cmrg_stop_lvl, 'op': op, - 'vr_mode': 0 + 'vr_mode': vr_mode } - return (cmrg_enable, cmrg_stop_lvl, op, 0), cfg_kwargs + return (cmrg_enable, cmrg_stop_lvl, op, vr_mode), cfg_kwargs diff --git a/sam/onyx/hw_nodes/merge_node.py b/sam/onyx/hw_nodes/merge_node.py index c0b3d158..f074e3e4 100644 --- a/sam/onyx/hw_nodes/merge_node.py +++ b/sam/onyx/hw_nodes/merge_node.py @@ -62,7 +62,16 @@ def connect(self, other, edge, kwargs=None): return new_conns elif other_type == IntersectNode: - raise NotImplementedError(f'Cannot connect MergeNode to {other_type}') + isect = other.get_name() + print("MERGE TO UNION FOR VECTOR REDUCE") + new_conns = { + f'merge_to_union_inner': [ + ([(merge, f"cmrg_coord_out_{0}"), (isect, f"coord_in_{0}")], 17), + ] + } + + return new_conns + # raise NotImplementedError(f'Cannot connect MergeNode to {other_type}') elif other_type == ReduceNode: # raise NotImplementedError(f'Cannot connect MergeNode to {other_type}') other_red = other.get_name() diff --git a/sam/onyx/hw_nodes/read_scanner_node.py b/sam/onyx/hw_nodes/read_scanner_node.py index 63e8023f..74fd70ef 100644 --- a/sam/onyx/hw_nodes/read_scanner_node.py +++ b/sam/onyx/hw_nodes/read_scanner_node.py @@ -90,6 +90,9 @@ def connect(self, other, edge, kwargs=None): edge_attr = edge.get_attributes() if 'use_alt_out_port' in edge_attr: out_conn = 'block_rd_out' + elif ('vector_reduce_mode' in edge_attr): + if (edge_attr['vector_reduce_mode']): + out_conn = 'pos_out' else: out_conn = 'coord_out' @@ -102,7 +105,13 @@ def connect(self, other, edge, kwargs=None): elif other_type == IntersectNode: # Send both.... isect = other.get_name() - isect_conn = other.get_connection_from_tensor(self.get_tensor()) + if 'vector_reduce_mode' in edge.get_attributes(): + if edge.get_attributes()['vector_reduce_mode']: + isect_conn = 1 + elif 'special' in edge.get_attributes(): + isect_conn = 0 + else: + isect_conn = other.get_connection_from_tensor(self.get_tensor()) e_attr = edge.get_attributes() # isect_conn = 0 @@ -247,12 +256,12 @@ def configure(self, attributes): dim_size = 1 stop_lvl = 0 - if 'spacc' in attributes: - spacc_mode = 1 - assert 'stop_lvl' in attributes - stop_lvl = int(attributes['stop_lvl'].strip('"')) - else: - spacc_mode = 0 + # if 'spacc' in attributes: + # spacc_mode = 1 + # assert 'stop_lvl' in attributes + # stop_lvl = int(attributes['stop_lvl'].strip('"')) + # else: + # spacc_mode = 0 # This is a fiberwrite's opposing read scanner for comms with GLB if attributes['type'].strip('"') == 'fiberwrite': @@ -283,6 +292,13 @@ def configure(self, attributes): lookup = 0 block_mode = int(attributes['type'].strip('"') == 'fiberwrite') + if 'vector_reduce_mode' in attributes: + is_in_vr_mode = attributes['vector_reduce_mode'].strip('"') + if is_in_vr_mode == "true": + vr_mode = 1 + else: + vr_mode = 0 + cfg_kwargs = { 'dense': dense, 'dim_size': dim_size, @@ -294,11 +310,12 @@ def configure(self, attributes): 'do_repeat': do_repeat, 'repeat_outer': repeat_outer, 'repeat_factor': repeat_factor, - 'stop_lvl': stop_lvl, + # 'stop_lvl': stop_lvl, 'block_mode': block_mode, 'lookup': lookup, - 'spacc_mode': spacc_mode + # 'spacc_mode': spacc_mode + 'vr_mode': vr_mode } return (inner_offset, max_outer_dim, strides, ranges, is_root, do_repeat, - repeat_outer, repeat_factor, stop_lvl, block_mode, lookup, spacc_mode), cfg_kwargs + repeat_outer, repeat_factor, block_mode, lookup, vr_mode), cfg_kwargs diff --git a/sam/onyx/hw_nodes/write_scanner_node.py b/sam/onyx/hw_nodes/write_scanner_node.py index a61a2172..25df864a 100644 --- a/sam/onyx/hw_nodes/write_scanner_node.py +++ b/sam/onyx/hw_nodes/write_scanner_node.py @@ -79,6 +79,7 @@ def connect(self, other, edge, kwargs=None): def configure(self, attributes): stop_lvl = 0 + init_blank = 0 # compressed = int(attributes['format'] == 'compressed') if 'format' in attributes and 'vals' in attributes['format'].strip('"'): @@ -89,14 +90,14 @@ def configure(self, attributes): else: compressed = 1 - if 'spacc' in attributes: - spacc_mode = 1 - init_blank = 1 - assert 'stop_lvl' in attributes - stop_lvl = int(attributes['stop_lvl'].strip('"')) - else: - spacc_mode = 0 - init_blank = 0 + # if 'spacc' in attributes: + # spacc_mode = 1 + # init_blank = 1 + # assert 'stop_lvl' in attributes + # stop_lvl = int(attributes['stop_lvl'].strip('"')) + # else: + # spacc_mode = 0 + # init_blank = 0 # compressed = int(attributes['format'] == 'compressed') if attributes['type'].strip('"') == 'arrayvals': @@ -112,16 +113,24 @@ def configure(self, attributes): else: block_mode = 0 + if 'vector_reduce_mode' in attributes: + is_in_vr_mode = attributes['vector_reduce_mode'].strip('"') + if is_in_vr_mode == "true": + vr_mode = 1 + else: + vr_mode = 0 + # block_mode = int(attributes['type'].strip('"') == 'fiberlookup') # cfg_tuple = (inner_offset, compressed, lowest_level, stop_lvl, block_mode) - cfg_tuple = (compressed, lowest_level, stop_lvl, block_mode, init_blank, spacc_mode) + cfg_tuple = (compressed, lowest_level, stop_lvl, block_mode, vr_mode, init_blank) cfg_kwargs = { # 'inner_offset': inner_offset, 'compressed': compressed, 'lowest_level': lowest_level, 'stop_lvl': stop_lvl, 'block_mode': block_mode, - 'init_blank': init_blank, - 'spacc_mode': spacc_mode + 'vr_mode': vr_mode, + 'init_blank': init_blank + # 'spacc_mode': spacc_mode } return cfg_tuple, cfg_kwargs diff --git a/sam/onyx/parse_dot.py b/sam/onyx/parse_dot.py index 7fae6744..8533c9a8 100644 --- a/sam/onyx/parse_dot.py +++ b/sam/onyx/parse_dot.py @@ -37,7 +37,7 @@ def __init__(self, filename=None, local_mems=True, use_fork=False, # Rewrite each 3-input joiners to 3 2-input joiners self.rewrite_tri_to_binary() - self.rewrite_spacc_1() + self.rewrite_VectorReducer() # Passes to lower to CGRA self.rewrite_lookup() @@ -111,8 +111,8 @@ def map_nodes(self): hw_nt = f"HWNodeType.Merge" elif n_type == "crdhold": hw_nt = f"HWNodeType.CrdHold" - elif n_type == "spaccumulator": - hw_nt = f"HWNodeType.SpAccumulator" + elif n_type == "vectorreducer": + hw_nt = f"HWNodeType.VectorReducer " else: print(n_type) raise SAMDotGraphLoweringError(f"Node is of type {n_type}") @@ -130,32 +130,32 @@ def find_node_by_name(self, name): return node assert False - def rewrite_spacc_1(self): + def rewrite_VectorReducer(self): - # Get the spacc node and the resulting fiberwrites + # Get the vr node and the resulting fiberwrites nodes_to_proc = [] for node in self.graph.get_nodes(): node_type = node.get_attributes()['type'].strip('"') - if 'spaccumulator' in node_type and '1' in node.get_attributes()['order'].strip('"'): + if 'vectorreducer' in node_type: # nodes_to_proc.append(node.get_name()) nodes_to_proc.append(node) - for spacc_node in nodes_to_proc: + for vr_node in nodes_to_proc: - attrs = spacc_node.get_attributes() + attrs = vr_node.get_attributes() og_label = attrs['label'].strip('"') del attrs['label'] # TODO: Get redux crd - output_crd = attrs['in0'].strip('"') - input_crd = None + output_crd = attrs['accum_index'].strip('"') + # input_crd = None - incoming_edges = [edge for edge in self.graph.get_edges() if edge.get_destination() == spacc_node.get_name()] - outgoing_edges = [edge for edge in self.graph.get_edges() if edge.get_source() == spacc_node.get_name()] + incoming_edges = [edge for edge in self.graph.get_edges() if edge.get_destination() == vr_node.get_name()] + outgoing_edges = [edge for edge in self.graph.get_edges() if edge.get_source() == vr_node.get_name()] in_val_node = None - in_output_node = None - in_input_node = None + in_crd_node = None + # in_input_node = None # Keep these for the edges in_edge_attrs = {} @@ -167,14 +167,14 @@ def rewrite_spacc_1(self): in_val_node = incoming_edge_.get_source() in_edge_attrs[in_val_node] = edge_attr elif edge_attr['type'].strip('"') == 'crd': - edge_comment = edge_attr['comment'].strip('"') - if output_crd in edge_comment: - in_output_node = incoming_edge_.get_source() - in_edge_attrs[in_output_node] = edge_attr - else: - input_crd = edge_comment - in_input_node = incoming_edge_.get_source() - in_edge_attrs[in_input_node] = edge_attr + # edge_comment = edge_attr['comment'].strip('"') + # if output_crd in edge_comment: + in_crd_node = incoming_edge_.get_source() + in_edge_attrs[in_crd_node] = edge_attr + # else: + # input_crd = edge_comment + # in_input_node = incoming_edge_.get_source() + # in_edge_attrs[in_input_node] = edge_attr self.graph.del_edge(incoming_edge_.get_source(), incoming_edge_.get_destination()) # Delete the outgoing edges/attached nodes @@ -190,95 +190,142 @@ def rewrite_spacc_1(self): og_type = attrs['type'] del attrs['type'] - rsg = pydot.Node(f"spacc1_rsg_{self.get_next_seq()}", - **attrs, label=f"{og_label}_rsg", hwnode=f"{HWNodeType.RepSigGen}", - type=og_type) - - repeat = pydot.Node(f"spacc1_repeat_{self.get_next_seq()}", - **attrs, label=f"{og_label}_repeat", hwnode=f"{HWNodeType.Repeat}", - root="true", type=og_type, spacc="true") - - union = pydot.Node(f"spacc1_union_{self.get_next_seq()}", - **attrs, label=f"{og_label}_union", hwnode=f"{HWNodeType.Intersect}", - type="union") - - add = pydot.Node(f"spacc1_add_{self.get_next_seq()}", - **attrs, label=f"{og_label}_add", hwnode=f"{HWNodeType.Compute}", - type=og_type) - - crd_buffet = pydot.Node(f"spacc1_crd_buffet_{self.get_next_seq()}", - **attrs, label=f"{og_label}_crd_buffet", hwnode=f"{HWNodeType.Buffet}", - type=og_type, fa_color=self.fa_color) - - crd_rd_scanner = pydot.Node(f"spacc1_crd_rd_scanner_{self.get_next_seq()}", - **attrs, label=f"{og_label}_crd_rd_scanner", hwnode=f"{HWNodeType.ReadScanner}", - tensor="x", type=og_type, root="false", format="compressed", - mode="0", index=f"{output_crd}", spacc="true", stop_lvl="0", - fa_color=self.fa_color) - - crd_wr_scanner = pydot.Node(f"spacc1_crd_wr_scanner_{self.get_next_seq()}", - **attrs, label=f"{og_label}_crd_wr_scanner", hwnode=f"{HWNodeType.WriteScanner}", - type=og_type, mode="0", format="compressed", spacc="true", stop_lvl="0", - fa_color=self.fa_color) + # rsg = pydot.Node(f"vr_rsg_{self.get_next_seq()}", + # **attrs, label=f"{og_label}_rsg", hwnode=f"{HWNodeType.RepSigGen}", + # type=og_type) + + # repeat = pydot.Node(f"vr_repeat_{self.get_next_seq()}", + # **attrs, label=f"{og_label}_repeat", hwnode=f"{HWNodeType.Repeat}", + # root="true", type=og_type, spacc="true") + + union = pydot.Node( + f"vr_union_{self.get_next_seq()}", + label=f"{og_label}_union", + hwnode=f"{HWNodeType.Intersect}", + type="union", + vector_reduce_mode="true", + comment=f"type=union,index={output_crd}", + index=output_crd) + + add = pydot.Node(f"vr_add_{self.get_next_seq()}", label=f"{og_label}_Add", hwnode=f"{HWNodeType.Compute}", + type="add", sub="0", comment="type=add,sub=0") + + crd_buffet = pydot.Node(f"vr_crd_buffet_{self.get_next_seq()}", + label=f"{og_label}_crd_buffet", hwnode=f"{HWNodeType.Buffet}", + type="buffet", vector_reduce_mode="true", fa_color=self.fa_color, comment="crd_buffet") + + crd_rd_scanner = pydot.Node( + f"vr_crd_rd_scanner_{self.get_next_seq()}", + label=f"{og_label}_crd_rd_scanner", + hwnode=f"{HWNodeType.ReadScanner}", + tensor="X", + type="fiberlookup", + root="false", + format="compressed", + mode="0", + index=f"{output_crd}", + vector_reduce_mode="true", + fa_color=self.fa_color, + comment="crd_rd_scanner") + + crd_wr_scanner = pydot.Node( + f"vr_crd_wr_scanner_{self.get_next_seq()}", + label=f"{og_label}_crd_wr_scanner", + hwnode=f"{HWNodeType.WriteScanner}", + type="fiberwrite", + mode="0", + format="compressed", + vector_reduce_mode="true", + fa_color=self.fa_color, + comment="crd_wr_scanner") self.fa_color += 1 - # glb_crd = pydot.Node(f"spacc1_crd_glb_{self.get_next_seq()}", **attrs, + # glb_crd = pydot.Node(f"vr_crd_glb_{self.get_next_seq()}", **attrs, # label=f"{og_label}_glb_crd_read", hwnode=f"{HWNodeType.GLB}", # tensor="x", mode="0", format="compressed", type=og_type) - vals_buffet = pydot.Node(f"spacc1_vals_buffet_{self.get_next_seq()}", - **attrs, label=f"{og_label}_vals_buffet", hwnode=f"{HWNodeType.Buffet}", - type=og_type, fa_color=self.fa_color) - - vals_rd_scanner = pydot.Node(f"spacc1_vals_rd_scanner_{self.get_next_seq()}", - **attrs, label=f"{og_label}_vals_rd_scanner", hwnode=f"{HWNodeType.ReadScanner}", - tensor="x", type=og_type, root="false", format="vals", - mode="vals", spacc="true", stop_lvl="0", fa_color=self.fa_color) - - vals_wr_scanner = pydot.Node(f"spacc1_vals_wr_scanner_{self.get_next_seq()}", - **attrs, label=f"{og_label}_vals_wr_scanner", hwnode=f"{HWNodeType.WriteScanner}", - type=og_type, mode="vals", format="compressed", spacc="true", - stop_lvl="0", fa_color=self.fa_color) - - # glb_vals = pydot.Node(f"spacc1_crd_vals_{self.get_next_seq()}", **attrs, + vals_buffet = pydot.Node(f"vr_vals_buffet_{self.get_next_seq()}", + label=f"{og_label}_vals_buffet", hwnode=f"{HWNodeType.Buffet}", + type="buffet", vector_reduce_mode="true", fa_color=self.fa_color, comment="vals_buffet") + + # vals_rd_scanner = pydot.Node(f"vr_vals_rd_scanner_{self.get_next_seq()}", + # label=f"{og_label}_vals_rd_scanner", hwnode=f"{HWNodeType.ReadScanner}", + # tensor="X", type="arrayvals", root="false", format="vals", + # mode="vals", vector_reduce_mode="true", fa_color=self.fa_color, + # comment="vals_rd_scanner") + + vals_rd_scanner = pydot.Node( + f"vr_vals_rd_scanner_{self.get_next_seq()}", + label=f"{og_label}_vals_rd_scanner", + hwnode=f"{HWNodeType.ReadScanner}", + tensor="X", + type="fiberlookup", + root="false", + format="compressed", + mode="1", + vector_reduce_mode="true", + fa_color=self.fa_color, + comment="vals_rd_scanner") + + # vals_wr_scanner = pydot.Node(f"vr_vals_wr_scanner_{self.get_next_seq()}", + # label=f"{og_label}_vals_wr_scanner", hwnode=f"{HWNodeType.WriteScanner}", + # type="fiberwrite", mode="vals", vector_reduce_mode="true", + # fa_color=self.fa_color, comment="vals_wr_scanner") + + vals_wr_scanner = pydot.Node( + f"vr_vals_wr_scanner_{self.get_next_seq()}", + label=f"{og_label}_vals_wr_scanner", + hwnode=f"{HWNodeType.WriteScanner}", + type="fiberwrite", + mode="1", + format="compressed", + vector_reduce_mode="true", + fa_color=self.fa_color, + comment="vals_wr_scanner") + + # glb_vals = pydot.Node(f"vr_crd_vals_{self.get_next_seq()}", **attrs, # label=f"{og_label}_glb_vals_read", hwnode=f"{HWNodeType.GLB}", # tensor="x", mode="vals", format="vals", type=og_type) self.fa_color += 1 - self.graph.add_node(rsg) - self.graph.add_node(repeat) self.graph.add_node(union) self.graph.add_node(add) self.graph.add_node(crd_buffet) self.graph.add_node(crd_rd_scanner) self.graph.add_node(crd_wr_scanner) - # self.graph.add_node(glb_crd) self.graph.add_node(vals_buffet) self.graph.add_node(vals_rd_scanner) self.graph.add_node(vals_wr_scanner) - # self.graph.add_node(glb_vals) - print(in_edge_attrs[in_input_node]) - print(in_edge_attrs[in_output_node]) + # print(in_edge_attrs[in_input_node]) + print(in_edge_attrs[in_crd_node]) print(in_edge_attrs[in_val_node]) - del in_edge_attrs[in_output_node]['comment'] + del in_edge_attrs[in_crd_node]['comment'] del in_edge_attrs[in_val_node]['type'] + del in_edge_attrs[in_crd_node]['type'] # Edges - input_to_rsg_edge = pydot.Edge(src=in_input_node, dst=rsg, **in_edge_attrs[in_input_node]) - rsg_to_repeat = pydot.Edge(src=rsg, dst=repeat) - repeat_to_crd_rd_scan = pydot.Edge(src=repeat, dst=crd_rd_scanner) - crd_rd_scan_to_val_rd_scan = pydot.Edge(src=crd_rd_scanner, dst=vals_rd_scanner) - output_to_union_edge = pydot.Edge(src=in_output_node, dst=union, - **in_edge_attrs[in_output_node], comment=f"in-B") - val_to_union = pydot.Edge(src=in_val_node, dst=union, **in_edge_attrs[in_val_node], - type="ref", comment=f"in-B", val="true") + # input_to_rsg_edge = pydot.Edge(src=in_input_node, dst=rsg, **in_edge_attrs[in_input_node]) + # rsg_to_repeat = pydot.Edge(src=rsg, dst=repeat) + # repeat_to_crd_rd_scan = pydot.Edge(src=repeat, dst=crd_rd_scanner) + # crd_rd_scan_to_val_rd_scan = pydot.Edge(src=crd_rd_scanner, dst=vals_rd_scanner) + in_crd_to_union = pydot.Edge(src=in_crd_node, dst=union, + **in_edge_attrs[in_crd_node], type="crd", comment=f"in-B") + in_val_to_union = pydot.Edge(src=in_val_node, dst=union, **in_edge_attrs[in_val_node], + type="ref", comment=f"in-B", val="true", vector_reduce_mode=True) # type="ref", comment=f"in-C", val="true") - crd_rd_scan_to_union = pydot.Edge(src=crd_rd_scanner, dst=union, type="crd", comment="in-x") - val_rd_scan_to_union = pydot.Edge(src=vals_rd_scanner, dst=union, type="ref", comment="in-x", val="true") + crd_rd_scan_to_union = pydot.Edge(src=crd_rd_scanner, dst=union, type="crd", + comment="in-x", vector_reduce_mode=True) + val_rd_scan_to_union = pydot.Edge( + src=vals_rd_scanner, + dst=union, + type="ref", + comment="in-x", + val="true", + vector_reduce_mode=True) union_crd_to_crd_wr_scan = pydot.Edge(src=union, dst=crd_wr_scanner, type="crd") union_val0_to_alu = pydot.Edge(src=union, dst=add, comment='out-B') # union_val0_to_alu = pydot.Edge(src=union, dst=add, comment='out-C') @@ -307,15 +354,32 @@ def rewrite_spacc_1(self): self.graph.del_edge(crd_edge.get_source(), crd_edge.get_destination()) self.graph.del_edge(val_edge.get_source(), val_edge.get_destination()) - crd_rd_scan_to_glb = pydot.Edge(src=crd_rd_scanner, dst=dst_crd, **crd_edge_attr, use_alt_out_port="1") - val_rd_scan_to_glb = pydot.Edge(src=vals_rd_scanner, dst=dst_vals, **val_edge_attr, use_alt_out_port="1") - - self.graph.add_edge(input_to_rsg_edge) - self.graph.add_edge(rsg_to_repeat) - self.graph.add_edge(repeat_to_crd_rd_scan) - self.graph.add_edge(crd_rd_scan_to_val_rd_scan) - self.graph.add_edge(output_to_union_edge) - self.graph.add_edge(val_to_union) + print(crd_edge_attr) + print(val_edge_attr) + del crd_edge_attr['comment'] + + # crd_rd_scan_to_glb = pydot.Edge(src=crd_rd_scanner, dst=dst_crd, **crd_edge_attr, use_alt_out_port="1") + # val_rd_scan_to_glb = pydot.Edge(src=vals_rd_scanner, dst=dst_vals, **val_edge_attr, use_alt_out_port="1") + + crd_rd_scan_to_ds = pydot.Edge( + src=crd_rd_scanner, + dst=dst_crd, + **crd_edge_attr, + comment="final-crd", + vector_reduce_mode=True) + val_rd_scan_to_ds = pydot.Edge( + src=vals_rd_scanner, + dst=dst_vals, + **val_edge_attr, + comment="final-val", + vector_reduce_mode=True) + + # self.graph.add_edge(input_to_rsg_edge) + # self.graph.add_edge(rsg_to_repeat) + # self.graph.add_edge(repeat_to_crd_rd_scan) + # self.graph.add_edge(crd_rd_scan_to_val_rd_scan) + self.graph.add_edge(in_crd_to_union) + self.graph.add_edge(in_val_to_union) self.graph.add_edge(crd_rd_scan_to_union) self.graph.add_edge(val_rd_scan_to_union) self.graph.add_edge(union_crd_to_crd_wr_scan) @@ -326,10 +390,10 @@ def rewrite_spacc_1(self): self.graph.add_edge(val_wr_scan_to_buffet) self.graph.add_edge(crd_rd_scan_to_buffet) self.graph.add_edge(vals_rd_scan_to_buffet) - self.graph.add_edge(crd_rd_scan_to_glb) - self.graph.add_edge(val_rd_scan_to_glb) + self.graph.add_edge(crd_rd_scan_to_ds) + self.graph.add_edge(val_rd_scan_to_ds) - self.graph.del_node(spacc_node) + self.graph.del_node(vr_node) def rewrite_tri_to_binary(self): '''