From c8bfae3834096d6adf8665a348b66e84c3b6c052 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Fri, 4 Aug 2023 11:18:50 -0700 Subject: [PATCH 01/32] Add in correct mat_residual --- compiler/sam-outputs/onyx-dot/mat_residual.gv | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 compiler/sam-outputs/onyx-dot/mat_residual.gv diff --git a/compiler/sam-outputs/onyx-dot/mat_residual.gv b/compiler/sam-outputs/onyx-dot/mat_residual.gv new file mode 100644 index 00000000..a509d2c0 --- /dev/null +++ b/compiler/sam-outputs/onyx-dot/mat_residual.gv @@ -0,0 +1,47 @@ +digraph SAM { + comment="x=s0,b=s0,C=ss01,d=s0" + 17 [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"] + 16 [comment="type=union,index=i" label="union i" color=purple shape=box style=filled type="union" index="i"] + 15 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 9 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] + 1 [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"] + 14 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 13 [comment="type=repeat,index=i,tensor=d,root=true" label="Repeat i: d" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="d" root="true"] + 12 [comment="type=fiberlookup,index=j,tensor=d,mode=0,format=compressed,src=true,root=false" label="FiberLookup j: d0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="d" mode="0" format="compressed" src="true" root="false"] + 10 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 7 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 6 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 5 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 3 [comment="type=add,sub=1" label="Add +subtract" color=brown shape=box style=filled type="add" sub="1"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1*b0_dim,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1*b0_dim" sink="true"] + 8 [comment="type=arrayvals,tensor=d" label="Array Vals: d" color=green2 shape=box style=filled type="arrayvals" tensor="d"] + 4 [comment="type=arrayvals,tensor=b" label="Array Vals: b" color=green2 shape=box style=filled type="arrayvals" tensor="b"] + 11 [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"] + 18 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] + 17 -> 16 [label="crd_in-b" style=dashed type="crd" comment="in-b"] + 16 -> 15 [label="crd_i" style=dashed type="crd" comment="i"] + 15 -> 9 [label="crd_i" style=dashed type="crd" comment="i"] + 9 -> 1 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + 15 -> 14 [label="crd" style=dashed type="crd" comment=""] + 14 -> 13 [label="repsig" style=dotted type="repsig"] + 13 -> 12 [label="ref" style=bold type="ref"] + 12 -> 10 [label="crd_in-d" style=dashed type="crd" comment="in-d"] + 10 -> 9 [label="crd_in-j" style=dashed type="crd" comment="in-j"] + 10 -> 7 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 7 -> 6 [label="val" type="val"] + 6 -> 5 [label="val" type="val"] + 5 -> 3 [label="val" type="val"] + 3 -> 0 [label="val" type="val"] + 10 -> 8 [label="ref_out-d" style=bold type="ref" comment="out-d"] + 8 -> 6 [label="val" type="val"] + 12 -> 10 [label="ref_in-d" style=bold type="ref" comment="in-d"] + 16 -> 4 [label="ref_out-b" style=bold type="ref" comment="out-b"] + 4 -> 3 [label="val" type="val"] + 16 -> 11 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 11 -> 10 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 11 -> 10 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 17 -> 16 [label="ref_in-b" style=bold type="ref" comment="in-b"] + 18 -> 16 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 18 -> 16 [label="ref_in-C" style=bold type="ref" comment="in-C"] +} From 8f1817fb972f315db8b3a5e27f399c5c27dc092e Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Wed, 9 Aug 2023 10:06:52 -0700 Subject: [PATCH 02/32] Add in final onyx tensors used for ISSCC benchmarking --- scripts/tensor_names/onyx_final.txt | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 scripts/tensor_names/onyx_final.txt diff --git a/scripts/tensor_names/onyx_final.txt b/scripts/tensor_names/onyx_final.txt new file mode 100644 index 00000000..0226d887 --- /dev/null +++ b/scripts/tensor_names/onyx_final.txt @@ -0,0 +1,51 @@ +relat3 +lpi_itest6 +LFAT5 +ch4-4-b1 +ch7-4-b1 +ch7-6-b1 +bwm2000 +G32 +progas +lp_maros +G42 +stormg2-27 +lpl3 +nemsemm2 +rlfdual +rail507 +rand_small_tensor1 +rand_small_tensor2 +rand_small_tensor3 +rand_small_tensor4 +rand_small_tensor5 +rand_small_tensor6 +rand_small_tensor7 +rand_small_tensor8 +rand_small_tensor9 +rand_small_tensor10 +rand_mid_tensor1 +rand_mid_tensor2 +rand_mid_tensor3 +rand_mid_tensor4 +rand_mid_tensor5 +rand_mid_tensor6 +rand_mid_tensor7 +rand_mid_tensor8 +rand_mid_tensor9 +rand_mid_tensor10 +rand_large_tensor1 +rand_large_tensor2 +rand_large_tensor3 +rand_large_tensor4 +rand_large_tensor5 +rand_large_tensor6 +rand_large_tensor7 +rand_large_tensor8 +rand_large_tensor9 +rand_large_tensor10 +facebook +uber3 +nell-2-pruned25 +nell-2-pruned20 +lbnl-network3 From 74f6d5ed2e83f373761f7f6b3b9a780151ac0afe Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Wed, 9 Aug 2023 10:14:36 -0700 Subject: [PATCH 03/32] Rename file --- scripts/tensor_names/{onyx_final.txt => onyx_eval_final.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/tensor_names/{onyx_final.txt => onyx_eval_final.txt} (100%) diff --git a/scripts/tensor_names/onyx_final.txt b/scripts/tensor_names/onyx_eval_final.txt similarity index 100% rename from scripts/tensor_names/onyx_final.txt rename to scripts/tensor_names/onyx_eval_final.txt From 1f9d877ad0a1b13c6ca9caf0c4249d9bf06f7e0d Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Thu, 10 Aug 2023 19:40:54 -0700 Subject: [PATCH 04/32] Add in new suitesparse matrices for onyx_final_eval.txt --- scripts/tensor_names/onyx_eval_final.txt | 40 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/scripts/tensor_names/onyx_eval_final.txt b/scripts/tensor_names/onyx_eval_final.txt index 0226d887..69a82089 100644 --- a/scripts/tensor_names/onyx_eval_final.txt +++ b/scripts/tensor_names/onyx_eval_final.txt @@ -1,19 +1,33 @@ -relat3 +ch4-4-b1 +IG5-6 lpi_itest6 +relat3 LFAT5 -ch4-4-b1 -ch7-4-b1 -ch7-6-b1 -bwm2000 -G32 -progas -lp_maros +Ragusa16 +n3c4-b3 +farm +n3c4-b2 +Trefethen_20b +bcsstm26 +G30 +watt_2 G42 -stormg2-27 -lpl3 -nemsemm2 -rlfdual -rail507 +adder_trans_02 +qiulp +adder_trans_02 +S40PI_n1 +adder_dcop_30 +tols2000 +route +pltexpa +EternityII_E +nemsemm1 +sctap1-2b +ulevimin +scfxm1-2b +spal_004 +Goodwin_054 +EternityII_Etilde rand_small_tensor1 rand_small_tensor2 rand_small_tensor3 From d2bdbf81b4a570222599cd616ec9a062573c96e2 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 14 Aug 2023 15:39:27 -0700 Subject: [PATCH 05/32] Update final list of datasets again --- scripts/tensor_names/get_benchmark_data.py | 6 +++--- scripts/tensor_names/onyx_eval_final.txt | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/tensor_names/get_benchmark_data.py b/scripts/tensor_names/get_benchmark_data.py index 1edda1a5..c19a4fdb 100644 --- a/scripts/tensor_names/get_benchmark_data.py +++ b/scripts/tensor_names/get_benchmark_data.py @@ -6,19 +6,19 @@ def get_matrix_indices(seed, n=5): random.seed(seed) matrices = [] with open('suitesparse_valid_small50.txt', 'r') as small50: - randlist = [random.randint(0, 49) for x in range(n)] + randlist = random.sample(range(50), n) print(randlist) lines = small50.read().splitlines() chosen_matrices = [lines[i] for i in randlist] matrices += chosen_matrices with open('suitesparse_valid_mid50.txt', 'r') as mid50: - randlist = [random.randint(0, 49) for x in range(n)] + randlist = random.sample(range(50), n) print(randlist) lines = mid50.read().splitlines() chosen_matrices = [lines[i] for i in randlist] matrices += chosen_matrices with open('suitesparse_valid_large50.txt', 'r') as large50: - randlist = [random.randint(0, 49) for x in range(n)] + randlist = random.sample(range(50), n) print(randlist) lines = large50.read().splitlines() chosen_matrices = [lines[i] for i in randlist] diff --git a/scripts/tensor_names/onyx_eval_final.txt b/scripts/tensor_names/onyx_eval_final.txt index 69a82089..4ff42fd0 100644 --- a/scripts/tensor_names/onyx_eval_final.txt +++ b/scripts/tensor_names/onyx_eval_final.txt @@ -14,20 +14,20 @@ watt_2 G42 adder_trans_02 qiulp -adder_trans_02 -S40PI_n1 +west2021 adder_dcop_30 tols2000 -route +rajat12 pltexpa EternityII_E nemsemm1 sctap1-2b ulevimin scfxm1-2b -spal_004 Goodwin_054 -EternityII_Etilde +rail516 +stat96v4 +lp_nug20 rand_small_tensor1 rand_small_tensor2 rand_small_tensor3 From 13de22603be258b803066629d09ec380d3ba7345 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 28 Aug 2023 16:24:04 -0700 Subject: [PATCH 06/32] Add in matmul with crddrop --- .../onyx-dot/matmul_ijk_crddrop.gv | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv diff --git a/compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv b/compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv new file mode 100644 index 00000000..7df0e708 --- /dev/null +++ b/compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv @@ -0,0 +1,60 @@ +digraph SAM { + comment="X=ss01,B=ss01,C=ss10" + 17 [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"] + 16 [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"] + 15 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 14 [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"] + 13 [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"] + 12 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 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"] + 11 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 10 [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"] + 8 [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"] + 7 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 5 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 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"] + 6 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 9 [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"] + 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] + 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] + 20 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop Val i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] + 21 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop Val j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] + + 17 -> 16 [label="crd" style=dashed type="crd" comment=""] + # 16 -> 2 [label="crd" style=dashed type="crd"] + 16 -> 15 [label="crd" style=dashed type="crd"] + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 13 [label="ref" style=bold type="ref"] + 13 -> 12 [label="crd" style=dashed type="crd" comment=""] + # 12 -> 1 [label="crd" style=dashed type="crd"] + 12 -> 11 [label="crd" style=dashed type="crd"] + 11 -> 10 [label="repsig" style=dotted type="repsig"] + 10 -> 8 [label="ref" style=bold type="ref"] + 8 -> 7 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 7 -> 5 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 5 -> 4 [label="val" type="val"] + # 4 -> 3 [label="val" type="val"] + 3 -> 0 [label="val" type="val"] + 7 -> 6 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 6 -> 4 [label="val" type="val"] + 8 -> 7 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 13 -> 9 [label="ref" style=bold type="ref" comment=""] + 9 -> 7 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 9 -> 7 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 17 -> 10 [label="ref" style=bold type="ref" comment=""] + + 7 -> 19 [label="crd_inner-k" style=dashed type="crd" comment="inner-k"] + 12 -> 19 [label="crd_inner-k" style=dashed type="crd" comment="outer-j"] + 19 -> 1 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"] + + 19 -> 18 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] + 16 -> 18 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + 18 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + + 4 -> 21 [label="val_inner-k" type="val" comment="inner-k"] + 12 -> 21 [label="crd_inner-k" style=dashed type="crd" comment="outer-j"] + 21 -> 3 [label="val_inner-k" type="val" comment="inner-k"] +} From 7b0234ade659c8b3830642d4505b23d1e8682d75 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Tue, 29 Aug 2023 10:07:22 -0700 Subject: [PATCH 07/32] Update sam graph for matmul --- .../sam-outputs/onyx-dot/matmul_ijk_crddrop.gv | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv b/compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv index 7df0e708..af28d80d 100644 --- a/compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv +++ b/compiler/sam-outputs/onyx-dot/matmul_ijk_crddrop.gv @@ -20,8 +20,6 @@ digraph SAM { 9 [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"] 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] - 20 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop Val i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] - 21 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop Val j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] 17 -> 16 [label="crd" style=dashed type="crd" comment=""] # 16 -> 2 [label="crd" style=dashed type="crd"] @@ -46,15 +44,12 @@ digraph SAM { 9 -> 7 [label="ref_in-C" style=bold type="ref" comment="in-C"] 17 -> 10 [label="ref" style=bold type="ref" comment=""] - 7 -> 19 [label="crd_inner-k" style=dashed type="crd" comment="inner-k"] - 12 -> 19 [label="crd_inner-k" style=dashed type="crd" comment="outer-j"] - 19 -> 1 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"] - + 4 -> 19 [label="val_inner-k" type="val" comment="inner-k"] + 12 -> 19 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"] + 18 -> 1 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] + 19 -> 3 [label="val_inner-k" type="val" comment="inner-k"] + 19 -> 18 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] 16 -> 18 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] 18 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] - - 4 -> 21 [label="val_inner-k" type="val" comment="inner-k"] - 12 -> 21 [label="crd_inner-k" style=dashed type="crd" comment="outer-j"] - 21 -> 3 [label="val_inner-k" type="val" comment="inner-k"] } From 3050c6e53afd6dba2e547dd8e02af3d39378cbe2 Mon Sep 17 00:00:00 2001 From: mbstrange2 Date: Tue, 29 Aug 2023 10:29:12 -0700 Subject: [PATCH 08/32] update compue/merge node to handle crddrop, some pycodestyle fixes --- sam/onyx/hw_nodes/compute_node.py | 37 +-- sam/onyx/hw_nodes/merge_node.py | 17 +- sam/onyx/hw_nodes/read_scanner_node.py | 27 -- sam/sim/src/channel.py | 4 +- sam/sim/src/fiber.py | 1 + sam/sim/src/rd_scanner.py | 423 +++++++++++++++++++++++++ 6 files changed, 450 insertions(+), 59 deletions(-) diff --git a/sam/onyx/hw_nodes/compute_node.py b/sam/onyx/hw_nodes/compute_node.py index 6f5d3bd6..2fb7620f 100644 --- a/sam/onyx/hw_nodes/compute_node.py +++ b/sam/onyx/hw_nodes/compute_node.py @@ -39,11 +39,7 @@ def connect(self, other, edge, kwargs=None): pe = self.get_name() new_conns = { 'pe_to_rd_scan': [ - # send output to rd scanner ([(pe, "res"), (rd_scan, "us_pos_in")], 17), - # ([(pe, "eos_out"), (rd_scan, "us_eos_in")], 1), - # ([(rd_scan, "us_ready_out"), (pe, "ready_in")], 1), - # ([(pe, "valid_out"), (rd_scan, "us_valid_in")], 1), ] } return new_conns @@ -52,11 +48,7 @@ def connect(self, other, edge, kwargs=None): pe = self.get_name() new_conns = { 'pe_to_wr_scan': [ - # send output to rd scanner ([(pe, "res"), (wr_scan, "data_in")], 17), - # ([(pe, "eos_out"), (wr_scan, "eos_in_0")], 1), - # ([(wr_scan, "ready_out_0"), (pe, "ready_in")], 1), - # ([(pe, "valid_out"), (wr_scan, "valid_in_0")], 1), ] } return new_conns @@ -79,11 +71,7 @@ def connect(self, other, edge, kwargs=None): new_conns = { f'pe_to_isect_{in_str}_{isect_conn}': [ - # send output to rd scanner ([(pe, "res"), (isect, f"{in_str}_{isect_conn}")], 17), - # ([(pe, "eos_out"), (isect, f"eos_in_{isect_conn * 2 + offset}")], 1), - # ([(isect, f"ready_out_{isect_conn * 2 + offset}"), (pe, "ready_in")], 1), - # ([(pe, "valid_out"), (isect, f"valid_in_{isect_conn * 2 + offset}")], 1), ] } other.update_input_connections() @@ -93,11 +81,7 @@ def connect(self, other, edge, kwargs=None): pe = self.get_name() new_conns = { f'pe_to_reduce': [ - # send output to rd scanner ([(pe, "res"), (other_red, f"data_in")], 17), - # ([(pe, "eos_out"), (other_red, f"eos_in")], 1), - # ([(other_red, f"ready_out"), (pe, "ready_in")], 1), - # ([(pe, "valid_out"), (other_red, f"valid_in")], 1), ] } return new_conns @@ -106,7 +90,21 @@ def connect(self, other, edge, kwargs=None): raise NotImplementedError(f'Cannot connect ComputeNode to {other_type}') elif other_type == MergeNode: # TODO - raise NotImplementedError(f'Cannot connect ComputeNode to {other_type}') + # raise NotImplementedError(f'Cannot connect ComputeNode to {other_type}') + # Hack just use inner for now + crddrop = other.get_name() + pe = self.get_name() + conn = 0 + if 'outer' in edge.get_comment(): + conn = 1 + + new_conns = { + f'pe_to_crddrop_res_to_{conn}': [ + ([(pe, "res"), (crddrop, f"cmrg_coord_in_{conn}")], 17), + ] + } + return new_conns + elif other_type == RepeatNode: # TODO raise NotImplementedError(f'Cannot connect ComputeNode to {other_type}') @@ -116,12 +114,7 @@ def connect(self, other, edge, kwargs=None): pe = self.get_name() new_conns = { f'pe_to_pe_{other_conn}': [ - # send output to rd scanner - # ([(pe, "res"), (other_pe, f"data_in_{other_conn}")], 17), ([(pe, "res"), (other_pe, f"data{other_conn}")], 17), - # ([(pe, "eos_out"), (other_pe, f"eos_in_{other_conn}")], 1), - # ([(other_pe, f"ready_out_{other_conn}"), (pe, "ready_in")], 1), - # ([(pe, "valid_out"), (other_pe, f"valid_in_{other_conn}")], 1), ] } other.update_input_connections() diff --git a/sam/onyx/hw_nodes/merge_node.py b/sam/onyx/hw_nodes/merge_node.py index 0602f190..dd6339c6 100644 --- a/sam/onyx/hw_nodes/merge_node.py +++ b/sam/onyx/hw_nodes/merge_node.py @@ -56,9 +56,6 @@ def connect(self, other, edge, kwargs=None): new_conns = { f'merge_{conn}_to_wr_scan': [ ([(merge, f"cmrg_coord_out_{conn}"), (wr_scan, f"data_in")], 17), - # ([(merge, f"cmrg_eos_out_{conn}"), (wr_scan, f"eos_in_0")], 1), - # ([(wr_scan, f"ready_out_0"), (merge, f"cmrg_ready_in_{conn}")], 1), - # ([(merge, f"cmrg_valid_out_{conn}"), (wr_scan, f"valid_in_0")], 1), ] } @@ -66,7 +63,15 @@ def connect(self, other, edge, kwargs=None): elif other_type == IntersectNode: raise NotImplementedError(f'Cannot connect MergeNode to {other_type}') elif other_type == ReduceNode: - raise NotImplementedError(f'Cannot connect MergeNode to {other_type}') + # raise NotImplementedError(f'Cannot connect MergeNode to {other_type}') + other_red = other.get_name() + new_conns = { + f'merge_to_reduce_inner': [ + ([(merge, f"cmrg_coord_out_{0}"), (other_red, f"data_in")], 17), + ] + } + + return new_conns elif other_type == LookupNode: raise NotImplementedError(f'Cannot connect MergeNode to {other_type}') elif other_type == MergeNode: @@ -88,11 +93,7 @@ def connect(self, other, edge, kwargs=None): new_conns = { f'merger_to_merger_{out_conn}_to_{in_conn}': [ - # Send isect row and isect col to merger inside isect_col ([(merge, f"cmrg_coord_out_{out_conn}"), (other_merge, f"cmrg_coord_in_{in_conn}")], 17), - # ([(isect, "eos_out_0"), (merge, f"cmrg_eos_in_{conn}")], 1), - # ([(merge, f"cmrg_ready_out_{conn}"), (isect, "ready_in_0")], 1), - # ([(isect, "valid_out_0"), (merge, f"cmrg_valid_in_{conn}")], 1), ] } diff --git a/sam/onyx/hw_nodes/read_scanner_node.py b/sam/onyx/hw_nodes/read_scanner_node.py index 2b6beb19..63e8023f 100644 --- a/sam/onyx/hw_nodes/read_scanner_node.py +++ b/sam/onyx/hw_nodes/read_scanner_node.py @@ -54,8 +54,6 @@ def connect(self, other, edge, kwargs=None): other_valid = other.get_valid() new_conns = { 'rd_scan_to_glb': [ - # send output to rd scanner - # ([(rd_scan, "coord_out"), (other_data, "f2io_17")], 17), ([(rd_scan, "block_rd_out"), (other_data, "f2io_17")], 17), ] } @@ -82,11 +80,7 @@ def connect(self, other, edge, kwargs=None): other_rd_scan = other.get_name() new_conns = { 'rd_scan_to_rd_scan': [ - # send output to rd scanner ([(rd_scan, "pos_out"), (other_rd_scan, "us_pos_in")], 17), - # ([(rd_scan, "eos_out_1"), (other_rd_scan, "us_eos_in")], 1), - # ([(other_rd_scan, "us_ready_out"), (rd_scan, "pos_out_ready")], 1), - # ([(rd_scan, "pos_out_valid"), (other_rd_scan, "us_valid_in")], 1), ] } return new_conns @@ -101,11 +95,7 @@ def connect(self, other, edge, kwargs=None): new_conns = { 'rd_scan_to_wr_scan': [ - # send output to rd scanner ([(rd_scan, out_conn), (wr_scan, "data_in")], 17), - # ([(rd_scan, "eos_out_0"), (wr_scan, "eos_in_0")], 1), - # ([(wr_scan, "data_in_ready"), (rd_scan, "coord_out_ready")], 1), - # ([(rd_scan, "coord_out_valid"), (wr_scan, "data_in_valid")], 1), ] } return new_conns @@ -205,8 +195,6 @@ def connect(self, other, edge, kwargs=None): new_conns = { f'rd_scan_to_compute_{compute_conn}': [ - # send output to rd scanner - # ([(rd_scan, "coord_out"), (compute, f"data_in_{compute_conn}")], 17), ([(rd_scan, "coord_out"), (compute, f"data{compute_conn}")], 17), ] } @@ -292,21 +280,6 @@ def configure(self, attributes): # stop_lvl = 0 lookup = 0 else: - # stop_lvl = int(attributes['mode'].strip('"')) - - # Do some hex - # tensor = attributes['tensor'].strip('"') - # index = attributes['index'].strip('"') - - # if tensor == 'B' and index == 'i': - # stop_lvl = 0 - # elif tensor == 'B' and index == 'k': - # stop_lvl = 2 - # elif tensor == 'C' and index == 'j': - # stop_lvl = 1 - # elif tensor == 'C' and index == 'k': - # stop_lvl = 2 - lookup = 0 block_mode = int(attributes['type'].strip('"') == 'fiberwrite') diff --git a/sam/sim/src/channel.py b/sam/sim/src/channel.py index 87fd36fe..92690dcc 100644 --- a/sam/sim/src/channel.py +++ b/sam/sim/src/channel.py @@ -444,8 +444,8 @@ def update(self, cyclenum): assert len(self.tile_ptrs_fifo) == len(self.tile_ptrs_size) if self.done_received and len(self.tile_ptrs) > 0: # and not self.done_processed: assert self.curr_size == sum(self.tile_sizes) or \ - self.curr_size == (sum(self.tile_sizes) + self.load_size) or \ - self.curr_size == (sum(self.tile_sizes) + self.load_size + self.remove_size) + self.curr_size == (sum(self.tile_sizes) + self.load_size) or \ + self.curr_size == (sum(self.tile_sizes) + self.load_size + self.remove_size) self.outputed = False self.done_processed = True self.valid = False diff --git a/sam/sim/src/fiber.py b/sam/sim/src/fiber.py index d9cb6dbc..e81764bd 100644 --- a/sam/sim/src/fiber.py +++ b/sam/sim/src/fiber.py @@ -1,5 +1,6 @@ # NOT CURRENTLY USED FILE + class FiberCoordinateLookupError(Exception): def __init__(self, *args: object) -> None: super().__init__(*args) diff --git a/sam/sim/src/rd_scanner.py b/sam/sim/src/rd_scanner.py index fb17f949..feece99e 100644 --- a/sam/sim/src/rd_scanner.py +++ b/sam/sim/src/rd_scanner.py @@ -648,6 +648,429 @@ def set_crd_skip(self, in_crd, parent=None): parent.set_backpressure(self.fifo_avail) +class VirtualBuffer(): + + def __init__(self, + depth) -> None: + self._fifo = list() + self.depth = depth + + def full(self): + return len(self._fifo) == self.depth + + def empty(self): + return len(self._fifo) == 0 + + def valid(self): + if not self.empty(): + timestamp = self._fifo[0][1] + if timestamp is None: + return True + else: + return timestamp == 0 + else: + return False + + def data(self): + if self.empty(): + return 0 + else: + return self._fifo[0][0] + + def time(self): + if self.empty(): + return None + else: + return self._fifo[0][1] + + def push(self, data, time=None): + + use_time = 1 + + if time is not None: + assert time >= 1 + use_time = time + + self._fifo.append((data, use_time)) + + def pop(self): + self._fifo.pop(0) + + def tick(self): + + for idx, (data, time) in enumerate(self._fifo): + if time is not None: + if time != 0: + self._fifo[idx] = (data, time - 1) + + def __str__(self) -> str: + return str(self._fifo) + + +class CompressedCrdRdScanModel(CrdRdScan): + def __init__(self, crd_arr=[], seg_arr=[], skip=True, depth=1, tile_size=None, fifo=None, **kwargs): + super().__init__(**kwargs) + + if tile_size is not None: + assert len(crd_arr) < tile_size + + # Used for skip list + self.skip = skip + self.in_crd_skip = [] + self.curr_skip = None + self.skip_processed = True + self.prev_crd = 0 + # [Olivia]: I think this is needed to make sure we are looking at the correct fiber + + self.crd_arr = crd_arr + self.seg_arr = seg_arr + self.start_addr = 0 + self.stop_addr = 0 + + # self.curr_addr = None + self.curr_addr = 0 + + self.end_fiber = False + self.curr_ref = '' + self.curr_crd = '' + self.emit_fiber_stkn = False + self.meta_clen = len(crd_arr) + self.meta_slen = len(seg_arr) + + self.emit_fiber_stkn = False + self.fresh_fiber = True + + self._seg_vb0 = VirtualBuffer(8) + self._seg_vb1 = VirtualBuffer(8) + self._crd_vb = VirtualBuffer(8) + self._ref_vb = VirtualBuffer(8) + + self.pop_out_crd = False + self.pop_out_ref = False + + self.all_vbs = [self._seg_vb0, self._seg_vb1, self._crd_vb, self._ref_vb] + + # Statistics + if self.get_stats: + self.unique_refs = [] + # self.unique_crds = [] + self.total_outputs = 0 + self.elements_skipped = 0 + self.skip_cnt = 0 + self.intersection_behind_cnt = 0 + self.fiber_behind_cnt = 0 + self.stop_count = 0 + self.empty_tkn_cnt = 0 + self.skip_stkn_cnt = 0 # also used as a statistic + self.out_stkn_cnt = 0 + + self.begin = True + if self.backpressure_en: + self.depth = depth + self.data_valid = True + self.fifo_avail = True + self.ready_backpressure = True + if fifo is not None: + self.set_fifo(fifo) + + def reinitialize_arrs(self, seg_arr, crd_arr, fifo): + # assert False + self.start_addr = 0 + self.stop_addr = 0 + self.end_fiber = False + # self.curr_ref = '' + # self.curr_crd = '' + self.emit_fiber_stkn = False + self.meta_clen = len(crd_arr) + self.meta_slen = len(seg_arr) + self.skip_stkn_cnt = 0 + self.out_stkn_cnt = 0 + # self.begin = True + self.seg_arr = seg_arr + self.crd_arr = crd_arr + print(fifo) + for a_ in fifo: + print(self.in_ref) + self.in_ref.append(a_) + + # if fifo is not None: + # self.set_fifo(fifo) + # assert False + self.done = False + # print("+++++++++") + return + + def set_fifo(self, fifo): + for a in fifo: + self.in_ref.append(a) + return + + 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) + if self.backpressure_en and parent != "": + parent.set_backpressure(self.fifo_avail) + + def out_ref(self, child=None): + # if self.backpressure_en and self.data_valid: + if self.backpressure_en and self._ref_vb.valid() and self._crd_vb.valid(): + # return self.curr_ref + self.pop_out_ref = True + return self._ref_vb.data() + elif self.backpressure_en: + return + if not self.backpressure_en: + # return self.curr_ref + # if self._ref_vb.valid(): + if self._crd_vb.valid() and self._ref_vb.valid(): + dat_ret = self._ref_vb.data() + self.pop_out_ref = True + # self._ref_vb.pop() + return dat_ret + else: + return + + def out_crd(self, child=None): + # if self.backpressure_en and self.data_valid: + if self.backpressure_en and self._crd_vb.valid() and self._ref_vb.valid(): + # return self.curr_crd + self.pop_out_crd = True + return self._crd_vb.data() + elif self.backpressure_en: + return + if not self.backpressure_en: + # return self.curr_crd + # return self._crd_vb.data() + # if self._crd_vb.valid(): + if self._crd_vb.valid() and self._ref_vb.valid(): + dat_ret = self._crd_vb.data() + # self._crd_vb.pop() + self.pop_out_crd = True + return dat_ret + else: + return + + def _emit_stkn_code(self): + self.end_fiber = True + + if len(self.in_ref) > 0: + next_in = self.in_ref[0] + if is_stkn(next_in): + self.in_ref.pop(0) + stkn = increment_stkn(next_in) + else: + stkn = 'S0' + self.emit_fiber_stkn = False + else: + self.emit_fiber_stkn = True + stkn = '' + self.curr_crd = stkn + self.curr_ref = stkn + self.curr_addr = None + self.stop_addr = 0 + self.start_addr = 0 + + def _set_curr(self): + self.curr_ref = self.curr_addr + self.curr_crd = self.crd_arr[self.curr_addr] + if self.get_stats: + # if self.curr_ref not in self.unique_refs: + # self.unique_refs.append(self.curr_ref) + # if self.curr_crd not in self.unique_crds: + # self.unique_crds.append(self.curr_crd) + self.total_outputs += 1 + + def return_statistics(self): + if self.get_stats: + dic = {"total_size": len(self.crd_arr), "outputs_by_block": self.total_outputs, + "unique_refs": len(self.unique_refs), + "skip_list_fifo": len(self.in_crd_skip), "total_elements_skipped": self.elements_skipped, + "total_skips_encountered": self.skip_cnt, "intersection_behind_rd": self.intersection_behind_cnt, + "intersection_behind_fiber": self.fiber_behind_cnt, "stop_tokens": self.stop_count, + "skip_stp_tkn_cnt": self.skip_stkn_cnt} + dic.update(super().return_statistics()) + else: + dic = {} + return dic + + def check_backpressure(self): + if self.backpressure_en: + copy_backpressure = self.ready_backpressure + self.ready_backpressure = True + return copy_backpressure + return True + + def update(self): + self.update_done() + self.update_ready() + + # if len(self.in_ref) > 0: + + input_valid = len(self.in_ref) > 0 + # Basically if we have already emitted something, we know we should either emit S0 or increment stop token + if input_valid: + next_in = self.in_ref[0] + + # If stop token, we increment and push the stop token if there is room + if is_stkn(next_in): + # self.in_ref.pop(0) + stkn = increment_stkn(next_in) + if (not self._seg_vb0.full()) and (not self._seg_vb1.full()): + self._seg_vb0.push((stkn, 1)) + self._seg_vb1.push((stkn, 1)) + self.in_ref.pop(0) + self.emit_fiber_stkn = False + elif next_in == 'D' and not self.emit_fiber_stkn: + # Basically in the done phase if we are not emitting something from before + if (not self._seg_vb0.full()) and (not self._seg_vb1.full()): + self._seg_vb0.push(('D', 1)) + self._seg_vb1.push(('D', 1)) + self.in_ref.pop(0) + self.emit_fiber_stkn = False + else: + # If input is valid not stop token, we want to spend this cycle forwarding the S0 if we marked that + stkn = 'S0' + # Emit the stkn if we need to + if self.emit_fiber_stkn and (not self._seg_vb0.full()) and (not self._seg_vb1.full()): + self._seg_vb0.push((stkn, 1)) + self._seg_vb1.push((stkn, 1)) + self.emit_fiber_stkn = False + # Otherwise, make our two requests and put them in the seg vbs + elif (not self._seg_vb0.full()) and (not self._seg_vb1.full()): + self._seg_vb0.push((self.seg_arr[next_in], 0), 5) + self._seg_vb1.push((self.seg_arr[next_in + 1], 0), 6) + self.emit_fiber_stkn = True + self.in_ref.pop(0) + + # Now check if the seg vbs are valid + if self._seg_vb0.valid() and self._seg_vb1.valid(): + # If it is a stop token, we pass it through if room + if (self._seg_vb0.data()[1] == 1) and (not self._crd_vb.full()) and (not self._ref_vb.full()): + data_to_pass = self._seg_vb0.data()[0] + self._crd_vb.push(data_to_pass) + self._ref_vb.push(data_to_pass) + self._seg_vb0.pop() + self._seg_vb1.pop() + self.fresh_fiber = True + # Otherwise, go through the fiber + else: + if self.fresh_fiber: + self.curr_addr = self._seg_vb0.data()[0] + self.fresh_fiber = False + # Only make movement if there is reservation room + if (not self._crd_vb.full()) and (not self._ref_vb.full()): + self._crd_vb.push(self.crd_arr[self.curr_addr], 6) + self._ref_vb.push(self.curr_addr) + # Increase the addr, if it is equal to the bound, we can + # pop it, set fresh fiber to True + self.curr_addr += 1 + if self.curr_addr == self._seg_vb1.data()[0]: + self._seg_vb0.pop() + self._seg_vb1.pop() + self.fresh_fiber = True + + # Update the vbs + for vb in self.all_vbs: + vb.tick() + + print(f'seg_vb0: {self._seg_vb0}') + print(f'seg_vb1: {self._seg_vb1}') + print(f'crd_vb: {self._crd_vb}') + print(f'ref_vb: {self._ref_vb}') + print(f'seg_vb0 valid: {self._seg_vb0.valid()}') + print(f'seg_vb1 valid: {self._seg_vb1.valid()}') + print(f'crd_vb valid: {self._crd_vb.valid()}') + print(f'ref_vb valid: {self._ref_vb.valid()}') + print(self.curr_addr) + # print(self.data_valid) + print(self.backpressure_en) + + if self.pop_out_ref: + self._ref_vb.pop() + self.pop_out_ref = False + + if self.pop_out_crd: + self._crd_vb.pop() + self.pop_out_crd = False + + # Debugging print statements + if self.debug and self.backpressure_en: + print("DEBUG: C RD SCAN:" + "\n \t" + "name: ", self.name, "\t ref", len(self.in_ref), " :: ", self.in_ref, + "\t Curr crd:", self.curr_crd, "\t curr ref:", self.curr_ref, + "\n curr addr:", self.curr_addr, "\t start addr:", self.start_addr, "\t stop addr:", self.stop_addr, + "\n end fiber:", self.end_fiber, "\t curr input:", curr_in_ref, + "\n skip in:", self.curr_skip, "\t skip processed", self.skip_processed, "\t prev crd:", + self.prev_crd, + "\n Out stkn cnt:", self.out_stkn_cnt, "\t Skip stkn cnt:", self.skip_stkn_cnt, "\t Bakcpressure: ", + self.check_backpressure(), "\t backpressure_len: ", + self.data_valid, self.done) + elif self.debug: + print("DEBUG: C RD SCAN:" + "\n \t" + "name: ", self.name, "\t ref", len(self.in_ref), " :: ", self.in_ref, + "\t Curr crd:", self.curr_crd, "\t curr ref:", self.curr_ref, + "\n curr addr:", self.curr_addr, "\t start addr:", self.start_addr, "\t stop addr:", self.stop_addr, + "\n end fiber:", self.end_fiber, "\t curr input:", curr_in_ref, + "\n skip in:", self.curr_skip, "\t skip processed", self.skip_processed, "\t prev crd:", + self.prev_crd, + "\n Out stkn cnt:", self.out_stkn_cnt, "\t Skip stkn cnt:", self.skip_stkn_cnt, self.done) + # else: + # Debugging print statements + if self.debug and self.backpressure_en: + print("DEBUG: C RD SCAN:" + "\n \t" + "name: ", self.name, "\t ref", len(self.in_ref), " :: ", self.in_ref, + "\t Curr crd:", self.curr_crd, "\t curr ref:", self.curr_ref, + "\n curr addr:", self.curr_addr, "\t start addr:", self.start_addr, "\t stop addr:", self.stop_addr, + "\n skip in:", self.curr_skip, "\t skip processed", self.skip_processed, "\t prev crd:", + self.prev_crd, + "\n Out stkn cnt:", self.out_stkn_cnt, "\t Skip stkn cnt:", self.skip_stkn_cnt, "\t Bakcpressure: ", + self.data_valid) + elif self.debug: + print("DEBUG: C RD SCAN:" + "\n \t" + "name: ", self.name, "\t ref", len(self.in_ref), " :: ", self.in_ref, + "\t Curr crd:", self.curr_crd, "\t curr ref:", self.curr_ref, + "\n curr addr:", self.curr_addr, "\t start addr:", self.start_addr, "\t stop addr:", self.stop_addr, + "\n skip in:", self.curr_skip, "\t skip processed", self.skip_processed, "\t prev crd:", + self.prev_crd, + "\n Out stkn cnt:", self.out_stkn_cnt, "\t Skip stkn cnt:", self.skip_stkn_cnt, self.done) + # # Debugging print statements + # if self.debug: + # print("DEBUG: C RD SCAN:" + # "\n \t" + # "name: ", self.name, "\t ref", len(self.in_ref), " :: ", self.in_ref, + # "\t Curr crd:", self.curr_crd, "\t curr ref:", self.curr_ref, + # "\n curr addr:", self.curr_addr, "\t start addr:", self.start_addr, "\t stop addr:", self.stop_addr, + # "\n end fiber:", self.end_fiber, "\t curr input:", curr_in_ref, + # "\n skip in:", self.curr_skip, "\t skip processed", self.skip_processed, "\t prev crd:", + # self.prev_crd, + # "\n emit_fiber_stkn:", self.emit_fiber_stkn, + # "\n Out stkn cnt:", self.out_stkn_cnt, "\t Skip stkn cnt:", self.skip_stkn_cnt) + + def set_crd_skip(self, in_crd, parent=None): + assert in_crd is None or is_valid_crd(in_crd) + if in_crd != '' and in_crd is not None: + if is_stkn(in_crd): + idx = last_stkn(self.in_crd_skip) + if idx is not None: + # Flush coordinates + self.in_crd_skip = self.in_crd_skip[:idx + 1] + self.in_crd_skip.append(in_crd) + if self.backpressure_en and parent != "": + parent.set_backpressure(self.fifo_avail) + + # ---------------- BV --------------# class BVRdScanSuper(Primitive, ABC): def __init__(self, **kwargs): From 7fde12e7ab6d5763ebef343d161ba2e35a4089ab Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Fri, 1 Sep 2023 11:42:27 -0700 Subject: [PATCH 09/32] Add in triangle counting --- compiler/sam-outputs/dot/mat_mask_tri.gv | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 compiler/sam-outputs/dot/mat_mask_tri.gv diff --git a/compiler/sam-outputs/dot/mat_mask_tri.gv b/compiler/sam-outputs/dot/mat_mask_tri.gv new file mode 100644 index 00000000..2af91546 --- /dev/null +++ b/compiler/sam-outputs/dot/mat_mask_tri.gv @@ -0,0 +1,62 @@ +digraph SAM { + comment="x=none,B=ss01,C=ss01,D=ss10" + 22 [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"] + 21 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] + 20 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 19 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 18 [comment="type=fiberlookup,index=j,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="D" mode="1" format="compressed" src="true" root="false"] + 16 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 15 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 14 [comment="type=repeat,index=j,tensor=C,root=false" label="Repeat j: C" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="C" root="false"] + 12 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 11 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 10 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 9 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 6 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 5 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 1 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1" sink="true"] + 7 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 8 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 13 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 17 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 23 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] + 22 -> 21 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 21 -> 20 [label="crd" style=dashed type="crd"] + 20 -> 19 [label="repsig" style=dotted type="repsig"] + 19 -> 18 [label="ref" style=bold type="ref"] + 18 -> 16 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 16 -> 15 [label="crd" style=dashed type="crd"] + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 12 [label="ref" style=bold type="ref"] + 12 -> 11 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 11 -> 10 [label="crd" style=dashed type="crd"] + 10 -> 9 [label="repsig" style=dotted type="repsig"] + 9 -> 6 [label="ref" style=bold type="ref"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 1 [label="val" type="val"] + 1 -> 0 [label="val" type="val"] + 11 -> 7 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 7 -> 5 [label="val" type="val"] + 11 -> 8 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 8 -> 4 [label="val" type="val"] + 12 -> 11 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 16 -> 9 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 16 -> 13 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 13 -> 11 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 13 -> 11 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 18 -> 16 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 21 -> 17 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 17 -> 16 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 17 -> 16 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 21 -> 14 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 22 -> 21 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 23 -> 21 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 23 -> 21 [label="ref_in-C" style=bold type="ref" comment="in-C"] +} From 65679b3cb80258452c9ec13d6c7964d2b69eb27a Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Fri, 1 Sep 2023 11:42:52 -0700 Subject: [PATCH 10/32] Add in triangle counting to sam-kernels.sh --- compiler/sam-kernels.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/sam-kernels.sh b/compiler/sam-kernels.sh index 44db88c2..e17f73b3 100755 --- a/compiler/sam-kernels.sh +++ b/compiler/sam-kernels.sh @@ -41,6 +41,7 @@ GEN_KERNEL_NAMES=( mat_spacc_simple vec_sd_compression_WRONG vec_ds_compression_WRONG + mat_mask_tri ) HAND_KERNEL_NAMES=( @@ -83,6 +84,7 @@ TACO_ARGS=( "X(j,k)=B(i,j,k) -f=X:ss -f=B:sss" "x(i)=b(i) -f=b:s -f=x:d" "x(i)=b(i) -f=b:d -f=x:s" + "x=B(i,j)*C(i,k)*D(k,j) -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" ) mkdir -p $dir From 7ffc7032314a2f9e7496b63944c55ae710df30fb Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Fri, 1 Sep 2023 11:56:48 -0700 Subject: [PATCH 11/32] Add in pagerank/iter solve --- compiler/sam-kernels.sh | 2 + compiler/sam-outputs/dot/mat_vecmul_iter.gv | 140 ++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 compiler/sam-outputs/dot/mat_vecmul_iter.gv diff --git a/compiler/sam-kernels.sh b/compiler/sam-kernels.sh index e17f73b3..40adb748 100755 --- a/compiler/sam-kernels.sh +++ b/compiler/sam-kernels.sh @@ -42,6 +42,7 @@ GEN_KERNEL_NAMES=( vec_sd_compression_WRONG vec_ds_compression_WRONG mat_mask_tri + mat_vecmul_iter ) HAND_KERNEL_NAMES=( @@ -85,6 +86,7 @@ TACO_ARGS=( "x(i)=b(i) -f=b:s -f=x:d" "x(i)=b(i) -f=b:d -f=x:s" "x=B(i,j)*C(i,k)*D(k,j) -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" + "x(i)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=x:s -f=B:ss -f=C:ss -f=D:ss -f=E:ss -s=reorder(i,j,k,l,m)" ) mkdir -p $dir diff --git a/compiler/sam-outputs/dot/mat_vecmul_iter.gv b/compiler/sam-outputs/dot/mat_vecmul_iter.gv new file mode 100644 index 00000000..704c888d --- /dev/null +++ b/compiler/sam-outputs/dot/mat_vecmul_iter.gv @@ -0,0 +1,140 @@ +digraph SAM { + comment="x=s0,B=ss01,C=ss01,D=ss01,E=ss01,f=d0" + 54 [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"] + 53 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 1 [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"] + 52 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 51 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 47 [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"] + 46 [comment="type=fiberlookup,index=j,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup j: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="0" format="compressed" src="true" root="false"] + 44 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 43 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 42 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 39 [comment="type=repeat,index=j,tensor=D,root=false" label="Repeat j: D" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="D" root="false"] + 38 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 36 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 35 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 34 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 31 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 23 [comment="type=repeat,index=l,tensor=B,root=false" label="Repeat l: B" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="B" root="false"] + 15 [comment="type=repeat,index=m,tensor=B,root=false" label="Repeat m: B" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="B" root="false"] + 10 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 9 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 8 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 7 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 6 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 5 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 4 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1*B0_dim,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1*B0_dim" sink="true"] + 32 [comment="type=repeat,index=k,tensor=E,root=false" label="Repeat k: E" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="E" root="false"] + 30 [comment="type=fiberlookup,index=l,tensor=E,mode=0,format=compressed,src=true,root=false" label="FiberLookup l: E0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="E" mode="0" format="compressed" src="true" root="false"] + 28 [comment="type=intersect,index=l" label="intersect l" color=purple shape=box style=filled type="intersect" index="l"] + 27 [comment="type=repsiggen,index=l" label="RepeatSignalGenerator l" color=cyan3 shape=box style=filled type="repsiggen" index="l"] + 26 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 24 [comment="type=repeat,index=l,tensor=C,root=false" label="Repeat l: C" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="C" root="false"] + 16 [comment="type=repeat,index=m,tensor=C,root=false" label="Repeat m: C" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="C" root="false"] + 11 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 25 [comment="type=repeat,index=l,tensor=f,root=false" label="Repeat l: f" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="f" root="false"] + 22 [comment="type=fiberlookup,index=m,tensor=f,mode=0,format=dense,src=true,root=false" label="FiberLookup m: f0\ndense" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="f" mode="0" format="dense" src="true" root="false"] + 20 [comment="type=intersect,index=m" label="intersect m" color=purple shape=box style=filled type="intersect" index="m"] + 19 [comment="type=repsiggen,index=m" label="RepeatSignalGenerator m" color=cyan3 shape=box style=filled type="repsiggen" index="m"] + 18 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 17 [comment="type=repeat,index=m,tensor=D,root=false" label="Repeat m: D" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="D" root="false"] + 12 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 13 [comment="type=arrayvals,tensor=E" label="Array Vals: E" color=green2 shape=box style=filled type="arrayvals" tensor="E"] + 14 [comment="type=arrayvals,tensor=f" label="Array Vals: f" color=green2 shape=box style=filled type="arrayvals" tensor="f"] + 21 [comment="type=fiberlookup,index=m,tensor=E,mode=1,format=compressed,src=true,root=false" label="FiberLookup m: E1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="E" mode="1" format="compressed" src="true" root="false"] + 33 [comment="type=repeat,index=k,tensor=f,root=false" label="Repeat k: f" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="f" root="false"] + 29 [comment="type=fiberlookup,index=l,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup l: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="D" mode="1" format="compressed" src="true" root="false"] + 40 [comment="type=repeat,index=j,tensor=E,root=false" label="Repeat j: E" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="E" root="false"] + 41 [comment="type=repeat,index=j,tensor=f,root=false" label="Repeat j: f" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="f" root="false"] + 37 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 48 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 49 [comment="type=repeat,index=i,tensor=E,root=true" label="Repeat i: E" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="E" root="true"] + 50 [comment="type=repeat,index=i,tensor=f,root=true" label="Repeat i: f" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="f" root="true"] + 45 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 54 -> 53 [label="crd" style=dashed type="crd" comment=""] + 53 -> 1 [label="crd" style=dashed type="crd"] + 53 -> 52 [label="crd" style=dashed type="crd"] + 52 -> 51 [label="repsig" style=dotted type="repsig"] + 51 -> 47 [label="repsig" style=dotted type="repsig"] + 47 -> 46 [label="ref" style=bold type="ref"] + 46 -> 44 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 44 -> 43 [label="crd" style=dashed type="crd"] + 43 -> 42 [label="repsig" style=dotted type="repsig"] + 42 -> 39 [label="repsig" style=dotted type="repsig"] + 39 -> 38 [label="ref" style=bold type="ref"] + 38 -> 36 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 36 -> 35 [label="crd" style=dashed type="crd"] + 35 -> 34 [label="repsig" style=dotted type="repsig"] + 34 -> 31 [label="repsig" style=dotted type="repsig"] + 31 -> 23 [label="ref" style=bold type="ref"] + 23 -> 15 [label="ref" style=bold type="ref"] + 15 -> 10 [label="ref" style=bold type="ref"] + 10 -> 9 [label="val" type="val"] + 9 -> 8 [label="val" type="val"] + 8 -> 7 [label="val" type="val"] + 7 -> 6 [label="val" type="val"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 0 [label="val" type="val"] + 34 -> 32 [label="repsig" style=dotted type="repsig"] + 32 -> 30 [label="ref" style=bold type="ref"] + 30 -> 28 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 28 -> 27 [label="crd" style=dashed type="crd"] + 27 -> 26 [label="repsig" style=dotted type="repsig"] + 26 -> 23 [label="repsig" style=dotted type="repsig"] + 26 -> 24 [label="repsig" style=dotted type="repsig"] + 24 -> 16 [label="ref" style=bold type="ref"] + 16 -> 11 [label="ref" style=bold type="ref"] + 11 -> 9 [label="val" type="val"] + 26 -> 25 [label="repsig" style=dotted type="repsig"] + 25 -> 22 [label="ref" style=bold type="ref"] + 22 -> 20 [label="crd_in-f" style=dashed type="crd" comment="in-f"] + 20 -> 19 [label="crd" style=dashed type="crd"] + 19 -> 18 [label="repsig" style=dotted type="repsig"] + 18 -> 15 [label="repsig" style=dotted type="repsig"] + 18 -> 16 [label="repsig" style=dotted type="repsig"] + 18 -> 17 [label="repsig" style=dotted type="repsig"] + 17 -> 12 [label="ref" style=bold type="ref"] + 12 -> 8 [label="val" type="val"] + 20 -> 13 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 13 -> 7 [label="val" type="val"] + 20 -> 14 [label="ref_out-f" style=bold type="ref" comment="out-f"] + 14 -> 6 [label="val" type="val"] + 22 -> 20 [label="ref_in-f" style=bold type="ref" comment="in-f"] + 28 -> 17 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 28 -> 21 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 21 -> 20 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 21 -> 20 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 30 -> 28 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 34 -> 33 [label="repsig" style=dotted type="repsig"] + 33 -> 25 [label="ref" style=bold type="ref"] + 36 -> 24 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 36 -> 29 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 29 -> 28 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 29 -> 28 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 38 -> 36 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 42 -> 40 [label="repsig" style=dotted type="repsig"] + 40 -> 32 [label="ref" style=bold type="ref"] + 42 -> 41 [label="repsig" style=dotted type="repsig"] + 41 -> 33 [label="ref" style=bold type="ref"] + 44 -> 31 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 44 -> 37 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 37 -> 36 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 37 -> 36 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 46 -> 44 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 51 -> 48 [label="repsig" style=dotted type="repsig"] + 48 -> 39 [label="ref" style=bold type="ref"] + 51 -> 49 [label="repsig" style=dotted type="repsig"] + 49 -> 40 [label="ref" style=bold type="ref"] + 51 -> 50 [label="repsig" style=dotted type="repsig"] + 50 -> 41 [label="ref" style=bold type="ref"] + 54 -> 45 [label="ref" style=bold type="ref" comment=""] + 45 -> 44 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 45 -> 44 [label="ref_in-B" style=bold type="ref" comment="in-B"] +} From 7bdb2d727942fd1d36b95e12fc0c1e01f23973fb Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Fri, 1 Sep 2023 13:00:22 -0700 Subject: [PATCH 12/32] Add in graphs needed for more complex expressions: --- compiler/sam-kernels.sh | 4 + .../sam-outputs/dot/tensor3_website_expr.gv | 155 ++++++++++++++++++ compiler/sam-outputs/dot/vec_sub.gv | 22 +++ 3 files changed, 181 insertions(+) create mode 100644 compiler/sam-outputs/dot/tensor3_website_expr.gv create mode 100644 compiler/sam-outputs/dot/vec_sub.gv diff --git a/compiler/sam-kernels.sh b/compiler/sam-kernels.sh index 40adb748..2baed0c7 100755 --- a/compiler/sam-kernels.sh +++ b/compiler/sam-kernels.sh @@ -41,8 +41,10 @@ GEN_KERNEL_NAMES=( mat_spacc_simple vec_sd_compression_WRONG vec_ds_compression_WRONG + vec_sub mat_mask_tri mat_vecmul_iter + tensor3_website_expr ) HAND_KERNEL_NAMES=( @@ -85,8 +87,10 @@ TACO_ARGS=( "X(j,k)=B(i,j,k) -f=X:ss -f=B:sss" "x(i)=b(i) -f=b:s -f=x:d" "x(i)=b(i) -f=b:d -f=x:s" + "x(i)=b(i)-c(i) -f=b:s -f=c:s" "x=B(i,j)*C(i,k)*D(k,j) -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" "x(i)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=x:s -f=B:ss -f=C:ss -f=D:ss -f=E:ss -s=reorder(i,j,k,l,m)" + "x=B(i)*C(j)*D(i,j,k)*E(j,l)*F(l,m,n) -f=B:s -f=C:s -f=D:sss -f=E:ss -f=F:sss -s=reorder(i,j,k,l,m,n)" ) mkdir -p $dir diff --git a/compiler/sam-outputs/dot/tensor3_website_expr.gv b/compiler/sam-outputs/dot/tensor3_website_expr.gv new file mode 100644 index 00000000..b8f11a17 --- /dev/null +++ b/compiler/sam-outputs/dot/tensor3_website_expr.gv @@ -0,0 +1,155 @@ +digraph SAM { + comment="x=none,B=s0,C=s0,D=sss012,E=ss01,F=sss012" + 59 [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"] + 58 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] + 57 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 56 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 53 [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"] + 50 [comment="type=fiberlookup,index=j,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup j: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="0" format="compressed" src="true" root="false"] + 49 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 48 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 47 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 45 [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"] + 38 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 30 [comment="type=repeat,index=l,tensor=B,root=false" label="Repeat l: B" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="B" root="false"] + 23 [comment="type=repeat,index=m,tensor=B,root=false" label="Repeat m: B" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="B" root="false"] + 16 [comment="type=repeat,index=n,tensor=B,root=false" label="Repeat n: B" color=cyan2 shape=box style=filled type="repeat" index="n" tensor="B" root="false"] + 11 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 10 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 9 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 8 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 7 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 6 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 5 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 4 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 1 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1" sink="true"] + 46 [comment="type=repeat,index=j,tensor=F,root=false" label="Repeat j: F" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="F" root="false"] + 41 [comment="type=repeat,index=k,tensor=F,root=false" label="Repeat k: F" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="F" root="false"] + 37 [comment="type=fiberlookup,index=l,tensor=F,mode=0,format=compressed,src=true,root=false" label="FiberLookup l: F0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="F" mode="0" format="compressed" src="true" root="false"] + 35 [comment="type=intersect,index=l" label="intersect l" color=purple shape=box style=filled type="intersect" index="l"] + 34 [comment="type=repsiggen,index=l" label="RepeatSignalGenerator l" color=cyan3 shape=box style=filled type="repsiggen" index="l"] + 33 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 31 [comment="type=repeat,index=l,tensor=C,root=false" label="Repeat l: C" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="C" root="false"] + 24 [comment="type=repeat,index=m,tensor=C,root=false" label="Repeat m: C" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="C" root="false"] + 17 [comment="type=repeat,index=n,tensor=C,root=false" label="Repeat n: C" color=cyan2 shape=box style=filled type="repeat" index="n" tensor="C" root="false"] + 12 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 32 [comment="type=repeat,index=l,tensor=D,root=false" label="Repeat l: D" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="D" root="false"] + 25 [comment="type=repeat,index=m,tensor=D,root=false" label="Repeat m: D" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="D" root="false"] + 18 [comment="type=repeat,index=n,tensor=D,root=false" label="Repeat n: D" color=cyan2 shape=box style=filled type="repeat" index="n" tensor="D" root="false"] + 13 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 26 [comment="type=repeat,index=m,tensor=E,root=false" label="Repeat m: E" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="E" root="false"] + 19 [comment="type=repeat,index=n,tensor=E,root=false" label="Repeat n: E" color=cyan2 shape=box style=filled type="repeat" index="n" tensor="E" root="false"] + 14 [comment="type=arrayvals,tensor=E" label="Array Vals: E" color=green2 shape=box style=filled type="arrayvals" tensor="E"] + 29 [comment="type=fiberlookup,index=m,tensor=F,mode=1,format=compressed,src=true,root=false" label="FiberLookup m: F1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="F" mode="1" format="compressed" src="true" root="false"] + 28 [comment="type=repsiggen,index=m" label="RepeatSignalGenerator m" color=cyan3 shape=box style=filled type="repsiggen" index="m"] + 27 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 22 [comment="type=fiberlookup,index=n,tensor=F,mode=2,format=compressed,src=true,root=false" label="FiberLookup n: F2\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="n" tensor="F" mode="2" format="compressed" src="true" root="false"] + 21 [comment="type=repsiggen,index=n" label="RepeatSignalGenerator n" color=cyan3 shape=box style=filled type="repsiggen" index="n"] + 20 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 15 [comment="type=arrayvals,tensor=F" label="Array Vals: F" color=green2 shape=box style=filled type="arrayvals" tensor="F"] + 39 [comment="type=repeat,index=k,tensor=C,root=false" label="Repeat k: C" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="C" root="false"] + 44 [comment="type=fiberlookup,index=k,tensor=D,mode=2,format=compressed,src=true,root=false" label="FiberLookup k: D2\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="2" format="compressed" src="true" root="false"] + 43 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 42 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 40 [comment="type=repeat,index=k,tensor=E,root=false" label="Repeat k: E" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="E" root="false"] + 36 [comment="type=fiberlookup,index=l,tensor=E,mode=1,format=compressed,src=true,root=false" label="FiberLookup l: E1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="E" mode="1" format="compressed" src="true" root="false"] + 54 [comment="type=repeat,index=i,tensor=E,root=true" label="Repeat i: E" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="E" root="true"] + 52 [comment="type=fiberlookup,index=j,tensor=E,mode=0,format=compressed,src=true,root=false" label="FiberLookup j: E0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="E" mode="0" format="compressed" src="true" root="false"] + 55 [comment="type=repeat,index=i,tensor=F,root=true" label="Repeat i: F" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="F" root="true"] + 51 [comment="type=fiberlookup,index=j,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="D" mode="1" format="compressed" src="true" root="false"] + 60 [comment="type=fiberlookup,index=i,tensor=D,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="D" mode="0" format="compressed" src="true" root="true"] + 59 -> 58 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 58 -> 57 [label="crd" style=dashed type="crd"] + 57 -> 56 [label="repsig" style=dotted type="repsig"] + 56 -> 53 [label="repsig" style=dotted type="repsig"] + 53 -> 50 [label="ref" style=bold type="ref"] + 50 -> 49 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 49 -> 48 [label="crd" style=dashed type="crd"] + 48 -> 47 [label="repsig" style=dotted type="repsig"] + 47 -> 45 [label="repsig" style=dotted type="repsig"] + 45 -> 38 [label="ref" style=bold type="ref"] + 38 -> 30 [label="ref" style=bold type="ref"] + 30 -> 23 [label="ref" style=bold type="ref"] + 23 -> 16 [label="ref" style=bold type="ref"] + 16 -> 11 [label="ref" style=bold type="ref"] + 11 -> 10 [label="val" type="val"] + 10 -> 9 [label="val" type="val"] + 9 -> 8 [label="val" type="val"] + 8 -> 7 [label="val" type="val"] + 7 -> 6 [label="val" type="val"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 1 [label="val" type="val"] + 1 -> 0 [label="val" type="val"] + 47 -> 46 [label="repsig" style=dotted type="repsig"] + 46 -> 41 [label="ref" style=bold type="ref"] + 41 -> 37 [label="ref" style=bold type="ref"] + 37 -> 35 [label="crd_in-F" style=dashed type="crd" comment="in-F"] + 35 -> 34 [label="crd" style=dashed type="crd"] + 34 -> 33 [label="repsig" style=dotted type="repsig"] + 33 -> 30 [label="repsig" style=dotted type="repsig"] + 33 -> 31 [label="repsig" style=dotted type="repsig"] + 31 -> 24 [label="ref" style=bold type="ref"] + 24 -> 17 [label="ref" style=bold type="ref"] + 17 -> 12 [label="ref" style=bold type="ref"] + 12 -> 10 [label="val" type="val"] + 33 -> 32 [label="repsig" style=dotted type="repsig"] + 32 -> 25 [label="ref" style=bold type="ref"] + 25 -> 18 [label="ref" style=bold type="ref"] + 18 -> 13 [label="ref" style=bold type="ref"] + 13 -> 9 [label="val" type="val"] + 35 -> 26 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 26 -> 19 [label="ref" style=bold type="ref"] + 19 -> 14 [label="ref" style=bold type="ref"] + 14 -> 8 [label="val" type="val"] + 35 -> 29 [label="ref_out-F" style=bold type="ref" comment="out-F"] + 29 -> 28 [label="crd" style=dashed type="crd" comment=""] + 28 -> 27 [label="repsig" style=dotted type="repsig"] + 27 -> 23 [label="repsig" style=dotted type="repsig"] + 27 -> 24 [label="repsig" style=dotted type="repsig"] + 27 -> 25 [label="repsig" style=dotted type="repsig"] + 27 -> 26 [label="repsig" style=dotted type="repsig"] + 29 -> 22 [label="ref" style=bold type="ref" comment=""] + 22 -> 21 [label="crd" style=dashed type="crd" comment=""] + 21 -> 20 [label="repsig" style=dotted type="repsig"] + 20 -> 16 [label="repsig" style=dotted type="repsig"] + 20 -> 17 [label="repsig" style=dotted type="repsig"] + 20 -> 18 [label="repsig" style=dotted type="repsig"] + 20 -> 19 [label="repsig" style=dotted type="repsig"] + 22 -> 15 [label="ref" style=bold type="ref" comment=""] + 15 -> 7 [label="val" type="val"] + 37 -> 35 [label="ref_in-F" style=bold type="ref" comment="in-F"] + 49 -> 39 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 39 -> 31 [label="ref" style=bold type="ref"] + 49 -> 44 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 44 -> 43 [label="crd" style=dashed type="crd" comment=""] + 43 -> 42 [label="repsig" style=dotted type="repsig"] + 42 -> 38 [label="repsig" style=dotted type="repsig"] + 42 -> 39 [label="repsig" style=dotted type="repsig"] + 42 -> 40 [label="repsig" style=dotted type="repsig"] + 40 -> 36 [label="ref" style=bold type="ref"] + 36 -> 35 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 36 -> 35 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 42 -> 41 [label="repsig" style=dotted type="repsig"] + 44 -> 32 [label="ref" style=bold type="ref" comment=""] + 49 -> 40 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 50 -> 49 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 56 -> 54 [label="repsig" style=dotted type="repsig"] + 54 -> 52 [label="ref" style=bold type="ref"] + 52 -> 49 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 52 -> 49 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 56 -> 55 [label="repsig" style=dotted type="repsig"] + 55 -> 46 [label="ref" style=bold type="ref"] + 58 -> 45 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 58 -> 51 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 51 -> 49 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 51 -> 49 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 59 -> 58 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 60 -> 58 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 60 -> 58 [label="ref_in-D" style=bold type="ref" comment="in-D"] +} diff --git a/compiler/sam-outputs/dot/vec_sub.gv b/compiler/sam-outputs/dot/vec_sub.gv new file mode 100644 index 00000000..1f0588a9 --- /dev/null +++ b/compiler/sam-outputs/dot/vec_sub.gv @@ -0,0 +1,22 @@ +digraph SAM { + comment="x=d0,b=s0,c=s0" + 6 [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"] + 5 [comment="type=union,index=i" label="union i" color=purple shape=box style=filled type="union" index="i"] + 1 [comment="type=fiberwrite,index=i,tensor=x,mode=0,format=dense,sink=true" label="FiberWrite i: x0\ndense" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="x" mode="0" format="dense" sink="true"] + 3 [comment="type=arrayvals,tensor=b" label="Array Vals: b" color=green2 shape=box style=filled type="arrayvals" tensor="b"] + 2 [comment="type=add,sub=1" label="Add +subtract" color=brown shape=box style=filled type="add" sub="1"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1*b0_dim,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1*b0_dim" sink="true"] + 4 [comment="type=arrayvals,tensor=c" label="Array Vals: c" color=green2 shape=box style=filled type="arrayvals" tensor="c"] + 7 [comment="type=fiberlookup,index=i,tensor=c,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: c0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="c" mode="0" format="compressed" src="true" root="true"] + 6 -> 5 [label="crd_in-b" style=dashed type="crd" comment="in-b"] + 5 -> 1 [label="crd" style=dashed type="crd"] + 5 -> 3 [label="ref_out-b" style=bold type="ref" comment="out-b"] + 3 -> 2 [label="val" type="val"] + 2 -> 0 [label="val" type="val"] + 5 -> 4 [label="ref_out-c" style=bold type="ref" comment="out-c"] + 4 -> 2 [label="val" type="val"] + 6 -> 5 [label="ref_in-b" style=bold type="ref" comment="in-b"] + 7 -> 5 [label="crd_in-c" style=dashed type="crd" comment="in-c"] + 7 -> 5 [label="ref_in-c" style=bold type="ref" comment="in-c"] +} From f17e3cfcd61fd439644539ec76ff33fb1e5477f7 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Fri, 1 Sep 2023 20:45:35 -0700 Subject: [PATCH 13/32] Add in masked triangle counting partial --- compiler/sam-kernels.sh | 2 + .../sam-outputs/dot/mat_mask_tri_partial.gv | 69 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 compiler/sam-outputs/dot/mat_mask_tri_partial.gv diff --git a/compiler/sam-kernels.sh b/compiler/sam-kernels.sh index 2baed0c7..3233cbd1 100755 --- a/compiler/sam-kernels.sh +++ b/compiler/sam-kernels.sh @@ -43,6 +43,7 @@ GEN_KERNEL_NAMES=( vec_ds_compression_WRONG vec_sub mat_mask_tri + mat_mask_tri_partial mat_vecmul_iter tensor3_website_expr ) @@ -89,6 +90,7 @@ TACO_ARGS=( "x(i)=b(i) -f=b:d -f=x:s" "x(i)=b(i)-c(i) -f=b:s -f=c:s" "x=B(i,j)*C(i,k)*D(k,j) -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" + "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" "x(i)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=x:s -f=B:ss -f=C:ss -f=D:ss -f=E:ss -s=reorder(i,j,k,l,m)" "x=B(i)*C(j)*D(i,j,k)*E(j,l)*F(l,m,n) -f=B:s -f=C:s -f=D:sss -f=E:ss -f=F:sss -s=reorder(i,j,k,l,m,n)" ) diff --git a/compiler/sam-outputs/dot/mat_mask_tri_partial.gv b/compiler/sam-outputs/dot/mat_mask_tri_partial.gv new file mode 100644 index 00000000..d109897f --- /dev/null +++ b/compiler/sam-outputs/dot/mat_mask_tri_partial.gv @@ -0,0 +1,69 @@ +digraph SAM { + comment="X=ss01,B=ss01,C=ss01,D=ss10" + 25 [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"] + 24 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] + 23 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 9 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] + 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"] + 1 [comment="type=fiberwrite,index=j,tensor=X,mode=1,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*B1_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*B1_dim" sink="true"] + 22 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 21 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 20 [comment="type=fiberlookup,index=j,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="D" mode="1" format="compressed" src="true" root="false"] + 18 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 17 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 16 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 15 [comment="type=repeat,index=j,tensor=C,root=false" label="Repeat j: C" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="C" root="false"] + 13 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 12 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 11 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 10 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 6 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 5 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=X,size=1*B0_dim*B1_dim,sink=true" label="FiberWrite Vals: X" color=green3 shape=box style=filled type="fiberwrite" tensor="X" mode="vals" size="1*B0_dim*B1_dim" sink="true"] + 7 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 8 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 14 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 19 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 26 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] + 25 -> 24 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 24 -> 23 [label="crd_i" style=dashed type="crd" comment="i"] + 23 -> 9 [label="crd_i" style=dashed type="crd" comment="i"] + 9 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + 9 -> 1 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] + 23 -> 22 [label="crd" style=dashed type="crd" comment=""] + 22 -> 21 [label="repsig" style=dotted type="repsig"] + 21 -> 20 [label="ref" style=bold type="ref"] + 20 -> 18 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 18 -> 17 [label="crd_j" style=dashed type="crd" comment="j"] + 17 -> 9 [label="crd_j" style=dashed type="crd" comment="j"] + 17 -> 16 [label="crd" style=dashed type="crd" comment=""] + 16 -> 15 [label="repsig" style=dotted type="repsig"] + 15 -> 13 [label="ref" style=bold type="ref"] + 13 -> 12 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 12 -> 11 [label="crd" style=dashed type="crd"] + 11 -> 10 [label="repsig" style=dotted type="repsig"] + 10 -> 6 [label="ref" style=bold type="ref"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 0 [label="val" type="val"] + 12 -> 7 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 7 -> 5 [label="val" type="val"] + 12 -> 8 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 8 -> 4 [label="val" type="val"] + 13 -> 12 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 18 -> 10 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 18 -> 14 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 14 -> 12 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 14 -> 12 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 20 -> 18 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 24 -> 19 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 19 -> 18 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 19 -> 18 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 24 -> 15 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 25 -> 24 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 26 -> 24 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 26 -> 24 [label="ref_in-C" style=bold type="ref" comment="in-C"] +} From 00d70e4e9c064000f3c89725cc0ec807d890e187 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Sat, 2 Sep 2023 16:58:40 -0700 Subject: [PATCH 14/32] Add in a fix for mat_vecmul_iter.gv --- compiler/sam-kernels.sh | 2 +- compiler/sam-outputs/dot/mat_vecmul_iter.gv | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/sam-kernels.sh b/compiler/sam-kernels.sh index 3233cbd1..9166a22f 100755 --- a/compiler/sam-kernels.sh +++ b/compiler/sam-kernels.sh @@ -91,7 +91,7 @@ TACO_ARGS=( "x(i)=b(i)-c(i) -f=b:s -f=c:s" "x=B(i,j)*C(i,k)*D(k,j) -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" - "x(i)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=x:s -f=B:ss -f=C:ss -f=D:ss -f=E:ss -s=reorder(i,j,k,l,m)" + "x(i)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=x:s -f=B:ss -f=C:ss -f=D:ss -f=E:ss -f=f:s -s=reorder(i,j,k,l,m)" "x=B(i)*C(j)*D(i,j,k)*E(j,l)*F(l,m,n) -f=B:s -f=C:s -f=D:sss -f=E:ss -f=F:sss -s=reorder(i,j,k,l,m,n)" ) diff --git a/compiler/sam-outputs/dot/mat_vecmul_iter.gv b/compiler/sam-outputs/dot/mat_vecmul_iter.gv index 704c888d..532312f6 100644 --- a/compiler/sam-outputs/dot/mat_vecmul_iter.gv +++ b/compiler/sam-outputs/dot/mat_vecmul_iter.gv @@ -1,5 +1,5 @@ digraph SAM { - comment="x=s0,B=ss01,C=ss01,D=ss01,E=ss01,f=d0" + comment="x=s0,B=ss01,C=ss01,D=ss01,E=ss01,f=s0" 54 [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"] 53 [comment="type=broadcast" shape=point style=invis type="broadcast"] 1 [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"] @@ -37,7 +37,7 @@ digraph SAM { 16 [comment="type=repeat,index=m,tensor=C,root=false" label="Repeat m: C" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="C" root="false"] 11 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] 25 [comment="type=repeat,index=l,tensor=f,root=false" label="Repeat l: f" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="f" root="false"] - 22 [comment="type=fiberlookup,index=m,tensor=f,mode=0,format=dense,src=true,root=false" label="FiberLookup m: f0\ndense" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="f" mode="0" format="dense" src="true" root="false"] + 22 [comment="type=fiberlookup,index=m,tensor=f,mode=0,format=compressed,src=true,root=false" label="FiberLookup m: f0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="f" mode="0" format="compressed" src="true" root="false"] 20 [comment="type=intersect,index=m" label="intersect m" color=purple shape=box style=filled type="intersect" index="m"] 19 [comment="type=repsiggen,index=m" label="RepeatSignalGenerator m" color=cyan3 shape=box style=filled type="repsiggen" index="m"] 18 [comment="type=broadcast" shape=point style=invis type="broadcast"] From eeccda916bbf88ab6970066afd522921b5ef9cd1 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Sun, 3 Sep 2023 16:38:41 -0700 Subject: [PATCH 15/32] Add in short spmv iter --- compiler/sam-kernels.sh | 2 + .../sam-outputs/dot/mat_vecmul_iter_short.gv | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 compiler/sam-outputs/dot/mat_vecmul_iter_short.gv diff --git a/compiler/sam-kernels.sh b/compiler/sam-kernels.sh index 9166a22f..5cc75fe0 100755 --- a/compiler/sam-kernels.sh +++ b/compiler/sam-kernels.sh @@ -45,6 +45,7 @@ GEN_KERNEL_NAMES=( mat_mask_tri mat_mask_tri_partial mat_vecmul_iter + mat_vecmul_iter_short tensor3_website_expr ) @@ -92,6 +93,7 @@ TACO_ARGS=( "x=B(i,j)*C(i,k)*D(k,j) -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss:1,0 -s=reorder(i,j,k)" "x(i)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=x:s -f=B:ss -f=C:ss -f=D:ss -f=E:ss -f=f:s -s=reorder(i,j,k,l,m)" + "x(i)=B(i,j)*C(j,k)*d(k) -f=x:s -f=B:ss -f=C:ss -f=d:s -s=reorder(i,j,k)" "x=B(i)*C(j)*D(i,j,k)*E(j,l)*F(l,m,n) -f=B:s -f=C:s -f=D:sss -f=E:ss -f=F:sss -s=reorder(i,j,k,l,m,n)" ) diff --git a/compiler/sam-outputs/dot/mat_vecmul_iter_short.gv b/compiler/sam-outputs/dot/mat_vecmul_iter_short.gv new file mode 100644 index 00000000..dfe5819e --- /dev/null +++ b/compiler/sam-outputs/dot/mat_vecmul_iter_short.gv @@ -0,0 +1,62 @@ +digraph SAM { + comment="x=s0,B=ss01,C=ss01,d=s0" + 24 [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"] + 23 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 1 [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"] + 22 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 21 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 19 [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"] + 18 [comment="type=fiberlookup,index=j,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup j: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="0" format="compressed" src="true" root="false"] + 16 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 15 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 14 [comment="type=repeat,index=j,tensor=d,root=false" label="Repeat j: d" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="d" root="false"] + 13 [comment="type=fiberlookup,index=k,tensor=d,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: d0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="d" mode="0" format="compressed" src="true" root="false"] + 11 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 10 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 9 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 6 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 5 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1*B0_dim,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1*B0_dim" sink="true"] + 7 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 8 [comment="type=arrayvals,tensor=d" label="Array Vals: d" color=green2 shape=box style=filled type="arrayvals" tensor="d"] + 12 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 20 [comment="type=repeat,index=i,tensor=d,root=true" label="Repeat i: d" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="d" root="true"] + 17 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 24 -> 23 [label="crd" style=dashed type="crd" comment=""] + 23 -> 1 [label="crd" style=dashed type="crd"] + 23 -> 22 [label="crd" style=dashed type="crd"] + 22 -> 21 [label="repsig" style=dotted type="repsig"] + 21 -> 19 [label="repsig" style=dotted type="repsig"] + 19 -> 18 [label="ref" style=bold type="ref"] + 18 -> 16 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 16 -> 15 [label="crd" style=dashed type="crd"] + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 13 [label="ref" style=bold type="ref"] + 13 -> 11 [label="crd_in-d" style=dashed type="crd" comment="in-d"] + 11 -> 10 [label="crd" style=dashed type="crd"] + 10 -> 9 [label="repsig" style=dotted type="repsig"] + 9 -> 6 [label="ref" style=bold type="ref"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 0 [label="val" type="val"] + 11 -> 7 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 7 -> 5 [label="val" type="val"] + 11 -> 8 [label="ref_out-d" style=bold type="ref" comment="out-d"] + 8 -> 4 [label="val" type="val"] + 13 -> 11 [label="ref_in-d" style=bold type="ref" comment="in-d"] + 16 -> 9 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 16 -> 12 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 12 -> 11 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 12 -> 11 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 18 -> 16 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 21 -> 20 [label="repsig" style=dotted type="repsig"] + 20 -> 14 [label="ref" style=bold type="ref"] + 24 -> 17 [label="ref" style=bold type="ref" comment=""] + 17 -> 16 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 17 -> 16 [label="ref_in-B" style=bold type="ref" comment="in-B"] +} From 4bccd11b74e5ad8e93ca26fe9f6456a25c299892 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 4 Sep 2023 11:16:21 -0700 Subject: [PATCH 16/32] Add in graph for mask_tri with fiberwrite to act as bypass --- .../dot/mat_mask_tri_fiberwrite.gv | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv diff --git a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv new file mode 100644 index 00000000..675290fd --- /dev/null +++ b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv @@ -0,0 +1,81 @@ +digraph SAM { + comment="x=none,B=ss01,C=ss01,D=ss10" + 22 [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"] + 21 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] + 20 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 19 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 18 [comment="type=fiberlookup,index=j,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="D" mode="1" format="compressed" src="true" root="false"] + 16 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 15 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 14 [comment="type=repeat,index=j,tensor=C,root=false" label="Repeat j: C" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="C" root="false"] + 12 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 11 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 10 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 9 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 6 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 5 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 1 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1" sink="true"] + 7 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 8 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 13 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 17 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 23 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] + + 24 [comment="type=fiberwrite,mode=0,tensor=T,size=B0_dim,sink=true" label="FiberWrite i: T0" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="0" size="1" sink="true"] + 25 [comment="type=fiberwrite,mode=1,tensor=T,size=B0_dim*B1_dim,sink=true" label="FiberWrite j: T1" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="1" size="B0_dim*B1_dim" sink="true"] + 26 [comment="type=fiberwrite,mode=2,tensor=T,size=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite k: T2" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="2" size="B0_dim*B1_dim*C1_dim" sink="true"] + + 27 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 28 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 29 [comment="type=broadcast" shape=point style=invis type="broadcast"] + + 22 -> 21 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 21 -> 27 [label="crd" style=dashed type="crd"] + 27 -> 20 [label="crd" style=dashed type="crd"] + 27 -> 24 [label="crd" style=dashed type="crd"] + + 20 -> 19 [label="repsig" style=dotted type="repsig"] + 19 -> 18 [label="ref" style=bold type="ref"] + 18 -> 16 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 16 -> 28 [label="crd" style=dashed type="crd"] + 28 -> 15 [label="crd" style=dashed type="crd"] + 28 -> 25 [label="crd" style=dashed type="crd"] + + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 12 [label="ref" style=bold type="ref"] + 12 -> 11 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 11 -> 29 [label="crd" style=dashed type="crd"] + 29 -> 10 [label="crd" style=dashed type="crd"] + 29 -> 26 [label="crd" style=dashed type="crd"] + + 10 -> 9 [label="repsig" style=dotted type="repsig"] + 9 -> 6 [label="ref" style=bold type="ref"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 1 [label="val" type="val"] + 1 -> 0 [label="val" type="val"] + 11 -> 7 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 7 -> 5 [label="val" type="val"] + 11 -> 8 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 8 -> 4 [label="val" type="val"] + 12 -> 11 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 16 -> 9 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 16 -> 13 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 13 -> 11 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 13 -> 11 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 18 -> 16 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 21 -> 17 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 17 -> 16 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 17 -> 16 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 21 -> 14 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 22 -> 21 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 23 -> 21 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 23 -> 21 [label="ref_in-C" style=bold type="ref" comment="in-C"] +} + From b7afe45ecdecc8b366a6da693e38774254b9f0d0 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 4 Sep 2023 13:41:27 -0700 Subject: [PATCH 17/32] Add in fix to mat_mask_tri_fiberwrite --- .../dot/mat_mask_tri_fiberwrite.gv | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv index 675290fd..e4dbbde8 100644 --- a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv +++ b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv @@ -28,35 +28,40 @@ digraph SAM { 24 [comment="type=fiberwrite,mode=0,tensor=T,size=B0_dim,sink=true" label="FiberWrite i: T0" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="0" size="1" sink="true"] 25 [comment="type=fiberwrite,mode=1,tensor=T,size=B0_dim*B1_dim,sink=true" label="FiberWrite j: T1" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="1" size="B0_dim*B1_dim" sink="true"] 26 [comment="type=fiberwrite,mode=2,tensor=T,size=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite k: T2" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="2" size="B0_dim*B1_dim*C1_dim" sink="true"] - + 30 [comment="type=fiberwrite,mode=vals,tensor=T,size=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite Vals: T" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="vals" size="B0_dim*B1_dim*C1_dim" sink="true"] + 27 [comment="type=broadcast" shape=point style=invis type="broadcast"] 28 [comment="type=broadcast" shape=point style=invis type="broadcast"] 29 [comment="type=broadcast" shape=point style=invis type="broadcast"] - + 31 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 22 -> 21 [label="crd_in-B" style=dashed type="crd" comment="in-B"] 21 -> 27 [label="crd" style=dashed type="crd"] 27 -> 20 [label="crd" style=dashed type="crd"] 27 -> 24 [label="crd" style=dashed type="crd"] - + 20 -> 19 [label="repsig" style=dotted type="repsig"] 19 -> 18 [label="ref" style=bold type="ref"] 18 -> 16 [label="crd_in-D" style=dashed type="crd" comment="in-D"] 16 -> 28 [label="crd" style=dashed type="crd"] 28 -> 15 [label="crd" style=dashed type="crd"] 28 -> 25 [label="crd" style=dashed type="crd"] - + 15 -> 14 [label="repsig" style=dotted type="repsig"] 14 -> 12 [label="ref" style=bold type="ref"] 12 -> 11 [label="crd_in-C" style=dashed type="crd" comment="in-C"] 11 -> 29 [label="crd" style=dashed type="crd"] 29 -> 10 [label="crd" style=dashed type="crd"] 29 -> 26 [label="crd" style=dashed type="crd"] - + 10 -> 9 [label="repsig" style=dotted type="repsig"] 9 -> 6 [label="ref" style=bold type="ref"] 6 -> 5 [label="val" type="val"] 5 -> 4 [label="val" type="val"] - 4 -> 3 [label="val" type="val"] + 4 -> 31 [label="val" type="val"] + 31 -> 3 + 31 -> 30 + 3 -> 2 [label="val" type="val"] 2 -> 1 [label="val" type="val"] 1 -> 0 [label="val" type="val"] @@ -77,5 +82,5 @@ digraph SAM { 22 -> 21 [label="ref_in-B" style=bold type="ref" comment="in-B"] 23 -> 21 [label="crd_in-C" style=dashed type="crd" comment="in-C"] 23 -> 21 [label="ref_in-C" style=bold type="ref" comment="in-C"] + } - From e74efa6329d7e10b72dba0081f3ce9849acf1743 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 4 Sep 2023 13:51:08 -0700 Subject: [PATCH 18/32] Fix an oopsies --- compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv index e4dbbde8..aa991d57 100644 --- a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv +++ b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv @@ -59,8 +59,8 @@ digraph SAM { 6 -> 5 [label="val" type="val"] 5 -> 4 [label="val" type="val"] 4 -> 31 [label="val" type="val"] - 31 -> 3 - 31 -> 30 + 31 -> 3 [label="val" type="val"] + 31 -> 30 [label="val" type="val"] 3 -> 2 [label="val" type="val"] 2 -> 1 [label="val" type="val"] From 75f91c56101b78fdf5c033fc8f1dc4ced78a2761 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 4 Sep 2023 14:07:00 -0700 Subject: [PATCH 19/32] Add in more fixes to mat_mask_tri_fiberwrite.gv --- compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv index aa991d57..911212cd 100644 --- a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv +++ b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv @@ -25,9 +25,9 @@ digraph SAM { 17 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] 23 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] - 24 [comment="type=fiberwrite,mode=0,tensor=T,size=B0_dim,sink=true" label="FiberWrite i: T0" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="0" size="1" sink="true"] - 25 [comment="type=fiberwrite,mode=1,tensor=T,size=B0_dim*B1_dim,sink=true" label="FiberWrite j: T1" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="1" size="B0_dim*B1_dim" sink="true"] - 26 [comment="type=fiberwrite,mode=2,tensor=T,size=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite k: T2" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="2" size="B0_dim*B1_dim*C1_dim" sink="true"] + 24 [comment="type=fiberwrite,mode=0,index=i,tensor=T,format=compressed,segsize=2,crdsize=B0_dim,sink=true" label="FiberWrite i: T0" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="T" mode="0" format="compressed" segsize="2" crdsize="B0_dim" sink="true"] + 25 [comment="type=fiberwrite,mode=1,index=j,tensor=T,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*B1_dim,sink=true" label="FiberWrite j: T1" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="T" mode="1" segsize="B0_dim+1" crdsize="B0_dim*B1_dim" sink="true"] + 26 [comment="type=fiberwrite,mode=2,index=k,tensor=T,format=compressed,segsize=B0_dim*B1_dim+1,crdsize=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite k: T2" color=green3 shape=box style=filled type="fiberwrite" index="k" tensor="T" mode="2" segsize="B0_dim*B1_dim+1" crdsize="B0_dim*B1_dim*C1_dim" sink="true"] 30 [comment="type=fiberwrite,mode=vals,tensor=T,size=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite Vals: T" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="vals" size="B0_dim*B1_dim*C1_dim" sink="true"] 27 [comment="type=broadcast" shape=point style=invis type="broadcast"] From adcb4f92c10cba9b5f0599c8ffc32fbef21a83bd Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 4 Sep 2023 14:13:07 -0700 Subject: [PATCH 20/32] Add in T to top tensor --- compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv index 911212cd..5364b62d 100644 --- a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv +++ b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv @@ -1,5 +1,5 @@ digraph SAM { - comment="x=none,B=ss01,C=ss01,D=ss10" + comment="x=none,B=ss01,C=ss01,D=ss10,T=ss01" 22 [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"] 21 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] 20 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] From 623788517c8338a7ab3985b01f3ccd01d25decc6 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 4 Sep 2023 14:13:57 -0700 Subject: [PATCH 21/32] Fix the 'T' mistake --- compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv index 5364b62d..81834eb2 100644 --- a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv +++ b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv @@ -1,5 +1,5 @@ digraph SAM { - comment="x=none,B=ss01,C=ss01,D=ss10,T=ss01" + comment="x=none,B=ss01,C=ss01,D=ss10,T=sss012" 22 [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"] 21 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] 20 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] From ab2a10d2dc6d40d8eb206f97f92450ae7278efc7 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Mon, 4 Sep 2023 15:09:56 -0700 Subject: [PATCH 22/32] Add in format --- compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv index 81834eb2..6886a760 100644 --- a/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv +++ b/compiler/sam-outputs/dot/mat_mask_tri_fiberwrite.gv @@ -26,8 +26,8 @@ digraph SAM { 23 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] 24 [comment="type=fiberwrite,mode=0,index=i,tensor=T,format=compressed,segsize=2,crdsize=B0_dim,sink=true" label="FiberWrite i: T0" color=green3 shape=box style=filled type="fiberwrite" index="i" tensor="T" mode="0" format="compressed" segsize="2" crdsize="B0_dim" sink="true"] - 25 [comment="type=fiberwrite,mode=1,index=j,tensor=T,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*B1_dim,sink=true" label="FiberWrite j: T1" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="T" mode="1" segsize="B0_dim+1" crdsize="B0_dim*B1_dim" sink="true"] - 26 [comment="type=fiberwrite,mode=2,index=k,tensor=T,format=compressed,segsize=B0_dim*B1_dim+1,crdsize=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite k: T2" color=green3 shape=box style=filled type="fiberwrite" index="k" tensor="T" mode="2" segsize="B0_dim*B1_dim+1" crdsize="B0_dim*B1_dim*C1_dim" sink="true"] + 25 [comment="type=fiberwrite,mode=1,index=j,tensor=T,format=compressed,segsize=B0_dim+1,crdsize=B0_dim*B1_dim,sink=true" label="FiberWrite j: T1" color=green3 shape=box style=filled type="fiberwrite" index="j" tensor="T" mode="1" format="compressed" segsize="B0_dim+1" crdsize="B0_dim*B1_dim" sink="true"] + 26 [comment="type=fiberwrite,mode=2,index=k,tensor=T,format=compressed,segsize=B0_dim*B1_dim+1,crdsize=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite k: T2" color=green3 shape=box style=filled type="fiberwrite" index="k" tensor="T" mode="2" format="compressed" segsize="B0_dim*B1_dim+1" crdsize="B0_dim*B1_dim*C1_dim" sink="true"] 30 [comment="type=fiberwrite,mode=vals,tensor=T,size=B0_dim*B1_dim*C1_dim,sink=true" label="FiberWrite Vals: T" color=green3 shape=box style=filled type="fiberwrite" tensor="T" mode="vals" size="B0_dim*B1_dim*C1_dim" sink="true"] 27 [comment="type=broadcast" shape=point style=invis type="broadcast"] From a50f69d3aafd5083df81371af6dff05f97f1e253 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 Oct 2023 13:34:42 -0700 Subject: [PATCH 23/32] added new apps --- compiler/sam-outputs/onyx-dot/mat_mask_tri.gv | 62 ++++++++ .../sam-outputs/onyx-dot/mat_vecmul_iter.gv | 140 ++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 compiler/sam-outputs/onyx-dot/mat_mask_tri.gv create mode 100644 compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv diff --git a/compiler/sam-outputs/onyx-dot/mat_mask_tri.gv b/compiler/sam-outputs/onyx-dot/mat_mask_tri.gv new file mode 100644 index 00000000..2af91546 --- /dev/null +++ b/compiler/sam-outputs/onyx-dot/mat_mask_tri.gv @@ -0,0 +1,62 @@ +digraph SAM { + comment="x=none,B=ss01,C=ss01,D=ss10" + 22 [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"] + 21 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] + 20 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 19 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 18 [comment="type=fiberlookup,index=j,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="D" mode="1" format="compressed" src="true" root="false"] + 16 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 15 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 14 [comment="type=repeat,index=j,tensor=C,root=false" label="Repeat j: C" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="C" root="false"] + 12 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 11 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 10 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 9 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 6 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 5 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 1 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1" sink="true"] + 7 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 8 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 13 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 17 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 23 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] + 22 -> 21 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 21 -> 20 [label="crd" style=dashed type="crd"] + 20 -> 19 [label="repsig" style=dotted type="repsig"] + 19 -> 18 [label="ref" style=bold type="ref"] + 18 -> 16 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 16 -> 15 [label="crd" style=dashed type="crd"] + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 12 [label="ref" style=bold type="ref"] + 12 -> 11 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 11 -> 10 [label="crd" style=dashed type="crd"] + 10 -> 9 [label="repsig" style=dotted type="repsig"] + 9 -> 6 [label="ref" style=bold type="ref"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 1 [label="val" type="val"] + 1 -> 0 [label="val" type="val"] + 11 -> 7 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 7 -> 5 [label="val" type="val"] + 11 -> 8 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 8 -> 4 [label="val" type="val"] + 12 -> 11 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 16 -> 9 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 16 -> 13 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 13 -> 11 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 13 -> 11 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 18 -> 16 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 21 -> 17 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 17 -> 16 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 17 -> 16 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 21 -> 14 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 22 -> 21 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 23 -> 21 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 23 -> 21 [label="ref_in-C" style=bold type="ref" comment="in-C"] +} diff --git a/compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv b/compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv new file mode 100644 index 00000000..532312f6 --- /dev/null +++ b/compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv @@ -0,0 +1,140 @@ +digraph SAM { + comment="x=s0,B=ss01,C=ss01,D=ss01,E=ss01,f=s0" + 54 [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"] + 53 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 1 [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"] + 52 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 51 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 47 [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"] + 46 [comment="type=fiberlookup,index=j,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup j: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="0" format="compressed" src="true" root="false"] + 44 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 43 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 42 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 39 [comment="type=repeat,index=j,tensor=D,root=false" label="Repeat j: D" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="D" root="false"] + 38 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 36 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 35 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 34 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 31 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 23 [comment="type=repeat,index=l,tensor=B,root=false" label="Repeat l: B" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="B" root="false"] + 15 [comment="type=repeat,index=m,tensor=B,root=false" label="Repeat m: B" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="B" root="false"] + 10 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 9 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 8 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 7 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 6 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 5 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 4 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1*B0_dim,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1*B0_dim" sink="true"] + 32 [comment="type=repeat,index=k,tensor=E,root=false" label="Repeat k: E" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="E" root="false"] + 30 [comment="type=fiberlookup,index=l,tensor=E,mode=0,format=compressed,src=true,root=false" label="FiberLookup l: E0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="E" mode="0" format="compressed" src="true" root="false"] + 28 [comment="type=intersect,index=l" label="intersect l" color=purple shape=box style=filled type="intersect" index="l"] + 27 [comment="type=repsiggen,index=l" label="RepeatSignalGenerator l" color=cyan3 shape=box style=filled type="repsiggen" index="l"] + 26 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 24 [comment="type=repeat,index=l,tensor=C,root=false" label="Repeat l: C" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="C" root="false"] + 16 [comment="type=repeat,index=m,tensor=C,root=false" label="Repeat m: C" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="C" root="false"] + 11 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 25 [comment="type=repeat,index=l,tensor=f,root=false" label="Repeat l: f" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="f" root="false"] + 22 [comment="type=fiberlookup,index=m,tensor=f,mode=0,format=compressed,src=true,root=false" label="FiberLookup m: f0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="f" mode="0" format="compressed" src="true" root="false"] + 20 [comment="type=intersect,index=m" label="intersect m" color=purple shape=box style=filled type="intersect" index="m"] + 19 [comment="type=repsiggen,index=m" label="RepeatSignalGenerator m" color=cyan3 shape=box style=filled type="repsiggen" index="m"] + 18 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 17 [comment="type=repeat,index=m,tensor=D,root=false" label="Repeat m: D" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="D" root="false"] + 12 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 13 [comment="type=arrayvals,tensor=E" label="Array Vals: E" color=green2 shape=box style=filled type="arrayvals" tensor="E"] + 14 [comment="type=arrayvals,tensor=f" label="Array Vals: f" color=green2 shape=box style=filled type="arrayvals" tensor="f"] + 21 [comment="type=fiberlookup,index=m,tensor=E,mode=1,format=compressed,src=true,root=false" label="FiberLookup m: E1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="E" mode="1" format="compressed" src="true" root="false"] + 33 [comment="type=repeat,index=k,tensor=f,root=false" label="Repeat k: f" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="f" root="false"] + 29 [comment="type=fiberlookup,index=l,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup l: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="D" mode="1" format="compressed" src="true" root="false"] + 40 [comment="type=repeat,index=j,tensor=E,root=false" label="Repeat j: E" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="E" root="false"] + 41 [comment="type=repeat,index=j,tensor=f,root=false" label="Repeat j: f" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="f" root="false"] + 37 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 48 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 49 [comment="type=repeat,index=i,tensor=E,root=true" label="Repeat i: E" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="E" root="true"] + 50 [comment="type=repeat,index=i,tensor=f,root=true" label="Repeat i: f" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="f" root="true"] + 45 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 54 -> 53 [label="crd" style=dashed type="crd" comment=""] + 53 -> 1 [label="crd" style=dashed type="crd"] + 53 -> 52 [label="crd" style=dashed type="crd"] + 52 -> 51 [label="repsig" style=dotted type="repsig"] + 51 -> 47 [label="repsig" style=dotted type="repsig"] + 47 -> 46 [label="ref" style=bold type="ref"] + 46 -> 44 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 44 -> 43 [label="crd" style=dashed type="crd"] + 43 -> 42 [label="repsig" style=dotted type="repsig"] + 42 -> 39 [label="repsig" style=dotted type="repsig"] + 39 -> 38 [label="ref" style=bold type="ref"] + 38 -> 36 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 36 -> 35 [label="crd" style=dashed type="crd"] + 35 -> 34 [label="repsig" style=dotted type="repsig"] + 34 -> 31 [label="repsig" style=dotted type="repsig"] + 31 -> 23 [label="ref" style=bold type="ref"] + 23 -> 15 [label="ref" style=bold type="ref"] + 15 -> 10 [label="ref" style=bold type="ref"] + 10 -> 9 [label="val" type="val"] + 9 -> 8 [label="val" type="val"] + 8 -> 7 [label="val" type="val"] + 7 -> 6 [label="val" type="val"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 0 [label="val" type="val"] + 34 -> 32 [label="repsig" style=dotted type="repsig"] + 32 -> 30 [label="ref" style=bold type="ref"] + 30 -> 28 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 28 -> 27 [label="crd" style=dashed type="crd"] + 27 -> 26 [label="repsig" style=dotted type="repsig"] + 26 -> 23 [label="repsig" style=dotted type="repsig"] + 26 -> 24 [label="repsig" style=dotted type="repsig"] + 24 -> 16 [label="ref" style=bold type="ref"] + 16 -> 11 [label="ref" style=bold type="ref"] + 11 -> 9 [label="val" type="val"] + 26 -> 25 [label="repsig" style=dotted type="repsig"] + 25 -> 22 [label="ref" style=bold type="ref"] + 22 -> 20 [label="crd_in-f" style=dashed type="crd" comment="in-f"] + 20 -> 19 [label="crd" style=dashed type="crd"] + 19 -> 18 [label="repsig" style=dotted type="repsig"] + 18 -> 15 [label="repsig" style=dotted type="repsig"] + 18 -> 16 [label="repsig" style=dotted type="repsig"] + 18 -> 17 [label="repsig" style=dotted type="repsig"] + 17 -> 12 [label="ref" style=bold type="ref"] + 12 -> 8 [label="val" type="val"] + 20 -> 13 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 13 -> 7 [label="val" type="val"] + 20 -> 14 [label="ref_out-f" style=bold type="ref" comment="out-f"] + 14 -> 6 [label="val" type="val"] + 22 -> 20 [label="ref_in-f" style=bold type="ref" comment="in-f"] + 28 -> 17 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 28 -> 21 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 21 -> 20 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 21 -> 20 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 30 -> 28 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 34 -> 33 [label="repsig" style=dotted type="repsig"] + 33 -> 25 [label="ref" style=bold type="ref"] + 36 -> 24 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 36 -> 29 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 29 -> 28 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 29 -> 28 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 38 -> 36 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 42 -> 40 [label="repsig" style=dotted type="repsig"] + 40 -> 32 [label="ref" style=bold type="ref"] + 42 -> 41 [label="repsig" style=dotted type="repsig"] + 41 -> 33 [label="ref" style=bold type="ref"] + 44 -> 31 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 44 -> 37 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 37 -> 36 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 37 -> 36 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 46 -> 44 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 51 -> 48 [label="repsig" style=dotted type="repsig"] + 48 -> 39 [label="ref" style=bold type="ref"] + 51 -> 49 [label="repsig" style=dotted type="repsig"] + 49 -> 40 [label="ref" style=bold type="ref"] + 51 -> 50 [label="repsig" style=dotted type="repsig"] + 50 -> 41 [label="ref" style=bold type="ref"] + 54 -> 45 [label="ref" style=bold type="ref" comment=""] + 45 -> 44 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 45 -> 44 [label="ref_in-B" style=bold type="ref" comment="in-B"] +} From ac0261ab7a7c63f7df18462d3a359e8a78d7fd65 Mon Sep 17 00:00:00 2001 From: Bo-Wun Cheng Date: Fri, 13 Oct 2023 11:06:39 -0700 Subject: [PATCH 24/32] updated new graphs for opal and mapping code to cope with the addtion of compression mode in crddrop --- .../opal-dot/matmul_ijk_crddrop_relu.gv | 60 +++++++++++++++++++ .../matmul_ijk_crddrop_relu_no_valdrop.gv | 54 +++++++++++++++++ sam/onyx/hw_nodes/merge_node.py | 6 +- 3 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv create mode 100644 compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv diff --git a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv new file mode 100644 index 00000000..73d523cc --- /dev/null +++ b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv @@ -0,0 +1,60 @@ +digraph SAM { + comment="X=ss01,B=ss01,C=ss10" + 17 [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"] + 16 [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"] + 15 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 14 [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"] + 13 [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"] + 12 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 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"] + 11 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 10 [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"] + 8 [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"] + 7 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 5 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 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"] + 6 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 9 [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"] + 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] + 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] + 20 [comment="type=max" label="Max 0" color=orange shape=box style=filled type="max"] + 21 [comment="type=valdrop,outer=j,inner=val" label="ValDropper j,val" color=purple shape=box style=filled type="valdrop" outer="j" inner="val"] + 22 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] + 17 -> 16 [label="crd" style=dashed type="crd" comment=""] + 16 -> 15 [label="crd" style=dashed type="crd"] + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 13 [label="ref" style=bold type="ref"] + 13 -> 12 [label="crd" style=dashed type="crd" comment=""] + 12 -> 11 [label="crd" style=dashed type="crd"] + 11 -> 10 [label="repsig" style=dotted type="repsig"] + 10 -> 8 [label="ref" style=bold type="ref"] + 8 -> 7 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 7 -> 5 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 5 -> 4 [label="val" type="val"] + 7 -> 6 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 6 -> 4 [label="val" type="val"] + 8 -> 7 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 13 -> 9 [label="ref" style=bold type="ref" comment=""] + 9 -> 7 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 9 -> 7 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 17 -> 10 [label="ref" style=bold type="ref" comment=""] + + 4 -> 19 [label="val_inner-k" type="val" comment="inner-k"] + 12 -> 19 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"] + 19 -> 3 [label="val_inner-k" type="val" comment="inner-k"] + 3 -> 20 [label="val" type="val" comment="val"] + 20 -> 21 [label="val" type="val" comment="relu-val"] + 18 -> 21 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] + 21 -> 22 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] + 18 -> 22 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + + 19 -> 18 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] + 16 -> 18 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + 21 -> 0 [label="val" type="val"] + + 22 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + 22 -> 1 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] +} diff --git a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv new file mode 100644 index 00000000..79740d0a --- /dev/null +++ b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv @@ -0,0 +1,54 @@ +digraph SAM { + comment="X=ss01,B=ss01,C=ss10" + 17 [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"] + 16 [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"] + 15 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 14 [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"] + 13 [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"] + 12 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 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"] + 11 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 10 [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"] + 8 [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"] + 7 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 5 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 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"] + 6 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 9 [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"] + 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] + 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] + 20 [comment="type=max" label="Max 0" color=orange shape=box style=filled type="max"] + 17 -> 16 [label="crd" style=dashed type="crd" comment=""] + 16 -> 15 [label="crd" style=dashed type="crd"] + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 13 [label="ref" style=bold type="ref"] + 13 -> 12 [label="crd" style=dashed type="crd" comment=""] + 12 -> 11 [label="crd" style=dashed type="crd"] + 11 -> 10 [label="repsig" style=dotted type="repsig"] + 10 -> 8 [label="ref" style=bold type="ref"] + 8 -> 7 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 7 -> 5 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 5 -> 4 [label="val" type="val"] + 7 -> 6 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 6 -> 4 [label="val" type="val"] + 8 -> 7 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 13 -> 9 [label="ref" style=bold type="ref" comment=""] + 9 -> 7 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 9 -> 7 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 17 -> 10 [label="ref" style=bold type="ref" comment=""] + + 4 -> 19 [label="val_inner-k" type="val" comment="inner-k"] + 12 -> 19 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"] + 19 -> 3 [label="val_inner-k" type="val" comment="inner-k"] + 3 -> 20 [label="val" type="val" comment="val"] + + 19 -> 18 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] + 16 -> 18 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + 20 -> 0 [label="val" type="val"] + + 18 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] + 18 -> 1 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] +} diff --git a/sam/onyx/hw_nodes/merge_node.py b/sam/onyx/hw_nodes/merge_node.py index dd6339c6..a1ca8d36 100644 --- a/sam/onyx/hw_nodes/merge_node.py +++ b/sam/onyx/hw_nodes/merge_node.py @@ -127,9 +127,11 @@ def configure(self, attributes): # TODO what is this supposed to be? cmrg_stop_lvl = 1 op = 0 + cmrg_mode = 1 # forced to 1 to peform crddrop instead of compression cfg_kwargs = { 'cmrg_enable': cmrg_enable, 'cmrg_stop_lvl': cmrg_stop_lvl, - 'op': op + 'op': op, + 'cmrg_mode': cmrg_mode } - return (cmrg_enable, cmrg_stop_lvl, op), cfg_kwargs + return (cmrg_enable, cmrg_stop_lvl, op, cmrg_mode), cfg_kwargs From 065785496e25b241c83baa03a04775c3db95099a Mon Sep 17 00:00:00 2001 From: Bo-Wun Cheng Date: Fri, 13 Oct 2023 11:15:18 -0700 Subject: [PATCH 25/32] updated the color of max in the graph --- compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv | 2 +- .../sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv index 73d523cc..4d6ba559 100644 --- a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv +++ b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv @@ -20,7 +20,7 @@ digraph SAM { 9 [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"] 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] - 20 [comment="type=max" label="Max 0" color=orange shape=box style=filled type="max"] + 20 [comment="type=max" label="Max 0" color=brown shape=box style=filled type="max"] 21 [comment="type=valdrop,outer=j,inner=val" label="ValDropper j,val" color=purple shape=box style=filled type="valdrop" outer="j" inner="val"] 22 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] 17 -> 16 [label="crd" style=dashed type="crd" comment=""] diff --git a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv index 79740d0a..d4a2c34a 100644 --- a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv +++ b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv @@ -20,7 +20,7 @@ digraph SAM { 9 [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"] 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] - 20 [comment="type=max" label="Max 0" color=orange shape=box style=filled type="max"] + 20 [comment="type=max" label="Max 0" color=brown shape=box style=filled type="max"] 17 -> 16 [label="crd" style=dashed type="crd" comment=""] 16 -> 15 [label="crd" style=dashed type="crd"] 15 -> 14 [label="repsig" style=dotted type="repsig"] From e4e64a060f4513d507a920112eae1cc72ac95a93 Mon Sep 17 00:00:00 2001 From: Bo-Wun Cheng Date: Fri, 13 Oct 2023 13:28:24 -0700 Subject: [PATCH 26/32] updated sam graph mapping code to take the new cmrg_mode signal into account --- sam/onyx/hw_nodes/merge_node.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sam/onyx/hw_nodes/merge_node.py b/sam/onyx/hw_nodes/merge_node.py index a1ca8d36..f759b235 100644 --- a/sam/onyx/hw_nodes/merge_node.py +++ b/sam/onyx/hw_nodes/merge_node.py @@ -3,10 +3,11 @@ class MergeNode(HWNode): - def __init__(self, name=None, outer=None, inner=None) -> None: + def __init__(self, name=None, outer=None, inner=None, mode=False) -> None: super().__init__(name=name) self.outer = outer self.inner = inner + self.mode = mode def get_outer(self): return self.outer @@ -127,7 +128,8 @@ def configure(self, attributes): # TODO what is this supposed to be? cmrg_stop_lvl = 1 op = 0 - cmrg_mode = 1 # forced to 1 to peform crddrop instead of compression + # 0 for compression, 1 for crddrop + cmrg_mode = self.mode cfg_kwargs = { 'cmrg_enable': cmrg_enable, 'cmrg_stop_lvl': cmrg_stop_lvl, From 3e78adcaa7b965f74509e9a6772132d3af3edb2f Mon Sep 17 00:00:00 2001 From: Bo Wun Cheng Date: Sun, 15 Oct 2023 23:02:03 -0700 Subject: [PATCH 27/32] update data type of the default mode value --- sam/onyx/hw_nodes/merge_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sam/onyx/hw_nodes/merge_node.py b/sam/onyx/hw_nodes/merge_node.py index f759b235..bf0ee8b4 100644 --- a/sam/onyx/hw_nodes/merge_node.py +++ b/sam/onyx/hw_nodes/merge_node.py @@ -3,7 +3,7 @@ class MergeNode(HWNode): - def __init__(self, name=None, outer=None, inner=None, mode=False) -> None: + def __init__(self, name=None, outer=None, inner=None, mode=None) -> None: super().__init__(name=name) self.outer = outer self.inner = inner From 85401559698102ff79cda1faa364af2edfc9cc55 Mon Sep 17 00:00:00 2001 From: Bo Wun Cheng Date: Mon, 16 Oct 2023 23:47:24 -0700 Subject: [PATCH 28/32] include sam simulation code that models compression using crddrop --- sam/sim/src/base.py | 21 +++++++ sam/sim/src/compression.py | 109 +++++++++++++++++++++++++++++++++++-- 2 files changed, 125 insertions(+), 5 deletions(-) diff --git a/sam/sim/src/base.py b/sam/sim/src/base.py index 38eaa778..c635c881 100644 --- a/sam/sim/src/base.py +++ b/sam/sim/src/base.py @@ -1,5 +1,8 @@ from abc import ABC, abstractmethod +import numpy as np +import warnings +# warnings.simplefilter(action='ignore', category=FutureWarning) def gen_stkns(dim=10): return ['S' + str(i) for i in range(dim)] @@ -24,6 +27,10 @@ def is_valid_crdpt(elem): return isinstance(elem, int) or elem in valid_tkns +def is_valid_num(elem, dim=10): + return isinstance(elem, int) or isinstance(elem, float) + + def is_valid_val(elem, dim=10): valid_tkns = ['', 'D'] + gen_stkns(dim) return isinstance(elem, int) or isinstance(elem, float) or elem in valid_tkns @@ -32,6 +39,9 @@ def is_valid_val(elem, dim=10): def is_0tkn(elem): return elem == 'N' +# Checks if a token is a non-control (numerical) token +def is_nc_tkn(elem, datatype=int): + return isinstance(elem, datatype) def is_stkn(elem): if isinstance(elem, str): @@ -39,6 +49,12 @@ def is_stkn(elem): return False +def is_dtkn(elem): + if isinstance(elem, str): + return elem == 'D' + return False + + def stkn_order(elem): assert is_stkn(elem) return int(elem[1]) @@ -89,6 +105,11 @@ def is_debug(self): def update(self): pass + # Check the input token of something + def valid_token(self, element, datatype=int): + return element != "" and element is not None and \ + (is_dtkn(element) or is_stkn(element) or is_nc_tkn(element, datatype) or is_0tkn(element)) + def reset(self): self.done = False diff --git a/sam/sim/src/compression.py b/sam/sim/src/compression.py index 939768c0..a87c6386 100644 --- a/sam/sim/src/compression.py +++ b/sam/sim/src/compression.py @@ -1,14 +1,26 @@ from .base import * +from .token import EmptyFiberStknDrop, StknDrop -class Compression(Primitive): - def __init__(self, **kwargs): +class ValDropper(Primitive): + def __init__(self, drop_refs=False, **kwargs): super().__init__(**kwargs) self.in_val = [] self.in_crd = [] + self.in_ref = [] self.curr_crd = '' + self.curr_ref = '' + self.curr_val = '' + self.out_crds = '' + self.out_refs = '' + self.out_vals = '' + self.val_stkn_dropper = EmptyFiberStknDrop() + self.crd_stkn_dropper = EmptyFiberStknDrop() + self.ref_stkn_dropper = EmptyFiberStknDrop() + self.drop_refs = drop_refs + if self.backpressure_en: self.ready_backpressure = True self.data_valid = True @@ -49,13 +61,86 @@ def update(self): if len(self.in_val) > 0 or len(self.in_crd) > 0: self.block_start = False - icrd = "" + icrd = '' + ival = '' if self.done: self.curr_crd = '' + self.curr_val = '' + self.out_crds = '' + self.out_vals = '' + if self.drop_refs: + self.curr_ref = '' + self.out_refs = '' return + elif (len(self.in_val) > 0 and len(self.in_crd) == 0) or (len(self.in_crd) > 0 and len(self.in_val) == 0) or (len(self.in_val) == 0 and len(self.in_crd) == 0): + self.out_crds = '' + self.out_vals = '' + if self.drop_refs: + self.out_refs = '' elif len(self.in_val) > 0 and len(self.in_crd) > 0: - icrd = self + ival = self.in_val.pop(0) + icrd = self.in_crd.pop(0) + iref = '' + if self.drop_refs: + iref = self.in_ref.pop(0) + + # print("ival:", ival) + # print("icrd:", icrd) + + assert ival != '', "ival is an empty str" + + if is_valid_num(ival): + # assert isinstance(icrd, int), "both val and crd need ot match" + if not isinstance(icrd, int) and icrd != 'N': + print("Both val and icrd need to match") + print(icrd, ival) + exit(1) + if ival == 0.0: + self.curr_crd = '' + self.curr_ref = '' + self.curr_val = '' + else: + self.curr_crd = icrd + self.curr_val = ival + if self.drop_refs: + self.curr_ref = iref + elif isinstance(ival, str) and ival != 'D': + assert isinstance(icrd, str), "both val and coord need to match" + self.curr_crd = icrd + self.curr_val = ival + if self.drop_refs: + self.curr_ref = iref + elif ival == 'D': + assert icrd == 'D' + self.curr_val = ival + self.curr_crd = icrd + if self.drop_refs: + self.curr_ref = iref + self.done = True + else: + self.curr_crd = icrd + self.curr_val = ival + if self.drop_refs: + self.curr_ref = iref + + # if self.curr_crd == self.out_crds or icrd == self.out_crds: + # self.out_crds = '' + # self.out_vals = '' + # self.out_refs = '' + # else: + self.val_stkn_dropper.set_in_stream(self.curr_val) + self.crd_stkn_dropper.set_in_stream(self.curr_crd) + self.val_stkn_dropper.update() + self.crd_stkn_dropper.update() + # self.out_crds = self.crd_stkn_dropper.out_val() + # self.out_vals = self.val_stkn_dropper.out_val() + self.out_crds = self.curr_crd + self.out_vals = self.curr_val + if self.drop_refs: + self.ref_stkn_dropper.set_in_stream(self.curr_ref) + self.ref_stkn_dropper.update() + self.out_refs = self.curr_ref if self.debug: print("Curr OuterCrd:", self.curr_ocrd, "\tCurr InnerCrd:", icrd, "\t Curr OutputCrd:", self.curr_crd, @@ -74,6 +159,20 @@ def set_crd(self, crd, parent=None): if self.backpressure_en: parent.set_backpressure(self.fifo_avail_crd) + def set_ref(self, ref, parent=None): + if ref != '' and ref is not None: + self.in_ref.append(ref) + if self.backpressure_en: + parent.set_backpressure(self.fifo_avail_crd) + def out_crd(self): if (self.backpressure_en and self.data_valid) or not self.backpressure_en: - return self.curr_crd + return self.out_crds + + def out_ref(self): + if (self.backpressure_en and self.data_valid) or not self.backpressure_en: + return self.out_refs + + def out_val(self): + if (self.backpressure_en and self.data_valid) or not self.backpressure_en: + return self.out_vals From 05323c77d540bbc4be80387bfa20330ad3d38e86 Mon Sep 17 00:00:00 2001 From: Bo Wun Cheng Date: Tue, 17 Oct 2023 09:52:04 -0700 Subject: [PATCH 29/32] fixed style issues that are failing the CI --- compiler/sam-outputs/onyx-dot/mat_mask_tri.gv | 62 ++++++++ .../sam-outputs/onyx-dot/mat_vecmul_iter.gv | 140 ++++++++++++++++++ sam/sim/src/base.py | 3 + sam/sim/src/compression.py | 6 +- 4 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 compiler/sam-outputs/onyx-dot/mat_mask_tri.gv create mode 100644 compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv diff --git a/compiler/sam-outputs/onyx-dot/mat_mask_tri.gv b/compiler/sam-outputs/onyx-dot/mat_mask_tri.gv new file mode 100644 index 00000000..2af91546 --- /dev/null +++ b/compiler/sam-outputs/onyx-dot/mat_mask_tri.gv @@ -0,0 +1,62 @@ +digraph SAM { + comment="x=none,B=ss01,C=ss01,D=ss10" + 22 [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"] + 21 [comment="type=intersect,index=i" label="intersect i" color=purple shape=box style=filled type="intersect" index="i"] + 20 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 19 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 18 [comment="type=fiberlookup,index=j,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="D" mode="1" format="compressed" src="true" root="false"] + 16 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 15 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 14 [comment="type=repeat,index=j,tensor=C,root=false" label="Repeat j: C" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="C" root="false"] + 12 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 11 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 10 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 9 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 6 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 5 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 1 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1" sink="true"] + 7 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 8 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 13 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 17 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 23 [comment="type=fiberlookup,index=i,tensor=C,mode=0,format=compressed,src=true,root=true" label="FiberLookup i: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="i" tensor="C" mode="0" format="compressed" src="true" root="true"] + 22 -> 21 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 21 -> 20 [label="crd" style=dashed type="crd"] + 20 -> 19 [label="repsig" style=dotted type="repsig"] + 19 -> 18 [label="ref" style=bold type="ref"] + 18 -> 16 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 16 -> 15 [label="crd" style=dashed type="crd"] + 15 -> 14 [label="repsig" style=dotted type="repsig"] + 14 -> 12 [label="ref" style=bold type="ref"] + 12 -> 11 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 11 -> 10 [label="crd" style=dashed type="crd"] + 10 -> 9 [label="repsig" style=dotted type="repsig"] + 9 -> 6 [label="ref" style=bold type="ref"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 1 [label="val" type="val"] + 1 -> 0 [label="val" type="val"] + 11 -> 7 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 7 -> 5 [label="val" type="val"] + 11 -> 8 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 8 -> 4 [label="val" type="val"] + 12 -> 11 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 16 -> 9 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 16 -> 13 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 13 -> 11 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 13 -> 11 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 18 -> 16 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 21 -> 17 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 17 -> 16 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 17 -> 16 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 21 -> 14 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 22 -> 21 [label="ref_in-B" style=bold type="ref" comment="in-B"] + 23 -> 21 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 23 -> 21 [label="ref_in-C" style=bold type="ref" comment="in-C"] +} diff --git a/compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv b/compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv new file mode 100644 index 00000000..532312f6 --- /dev/null +++ b/compiler/sam-outputs/onyx-dot/mat_vecmul_iter.gv @@ -0,0 +1,140 @@ +digraph SAM { + comment="x=s0,B=ss01,C=ss01,D=ss01,E=ss01,f=s0" + 54 [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"] + 53 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 1 [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"] + 52 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] + 51 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 47 [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"] + 46 [comment="type=fiberlookup,index=j,tensor=C,mode=0,format=compressed,src=true,root=false" label="FiberLookup j: C0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="C" mode="0" format="compressed" src="true" root="false"] + 44 [comment="type=intersect,index=j" label="intersect j" color=purple shape=box style=filled type="intersect" index="j"] + 43 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] + 42 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 39 [comment="type=repeat,index=j,tensor=D,root=false" label="Repeat j: D" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="D" root="false"] + 38 [comment="type=fiberlookup,index=k,tensor=D,mode=0,format=compressed,src=true,root=false" label="FiberLookup k: D0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="D" mode="0" format="compressed" src="true" root="false"] + 36 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] + 35 [comment="type=repsiggen,index=k" label="RepeatSignalGenerator k" color=cyan3 shape=box style=filled type="repsiggen" index="k"] + 34 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 31 [comment="type=repeat,index=k,tensor=B,root=false" label="Repeat k: B" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="B" root="false"] + 23 [comment="type=repeat,index=l,tensor=B,root=false" label="Repeat l: B" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="B" root="false"] + 15 [comment="type=repeat,index=m,tensor=B,root=false" label="Repeat m: B" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="B" root="false"] + 10 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] + 9 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 8 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 7 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 6 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] + 5 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 4 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 2 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] + 0 [comment="type=fiberwrite,mode=vals,tensor=x,size=1*B0_dim,sink=true" label="FiberWrite Vals: x" color=green3 shape=box style=filled type="fiberwrite" tensor="x" mode="vals" size="1*B0_dim" sink="true"] + 32 [comment="type=repeat,index=k,tensor=E,root=false" label="Repeat k: E" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="E" root="false"] + 30 [comment="type=fiberlookup,index=l,tensor=E,mode=0,format=compressed,src=true,root=false" label="FiberLookup l: E0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="E" mode="0" format="compressed" src="true" root="false"] + 28 [comment="type=intersect,index=l" label="intersect l" color=purple shape=box style=filled type="intersect" index="l"] + 27 [comment="type=repsiggen,index=l" label="RepeatSignalGenerator l" color=cyan3 shape=box style=filled type="repsiggen" index="l"] + 26 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 24 [comment="type=repeat,index=l,tensor=C,root=false" label="Repeat l: C" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="C" root="false"] + 16 [comment="type=repeat,index=m,tensor=C,root=false" label="Repeat m: C" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="C" root="false"] + 11 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] + 25 [comment="type=repeat,index=l,tensor=f,root=false" label="Repeat l: f" color=cyan2 shape=box style=filled type="repeat" index="l" tensor="f" root="false"] + 22 [comment="type=fiberlookup,index=m,tensor=f,mode=0,format=compressed,src=true,root=false" label="FiberLookup m: f0\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="f" mode="0" format="compressed" src="true" root="false"] + 20 [comment="type=intersect,index=m" label="intersect m" color=purple shape=box style=filled type="intersect" index="m"] + 19 [comment="type=repsiggen,index=m" label="RepeatSignalGenerator m" color=cyan3 shape=box style=filled type="repsiggen" index="m"] + 18 [comment="type=broadcast" shape=point style=invis type="broadcast"] + 17 [comment="type=repeat,index=m,tensor=D,root=false" label="Repeat m: D" color=cyan2 shape=box style=filled type="repeat" index="m" tensor="D" root="false"] + 12 [comment="type=arrayvals,tensor=D" label="Array Vals: D" color=green2 shape=box style=filled type="arrayvals" tensor="D"] + 13 [comment="type=arrayvals,tensor=E" label="Array Vals: E" color=green2 shape=box style=filled type="arrayvals" tensor="E"] + 14 [comment="type=arrayvals,tensor=f" label="Array Vals: f" color=green2 shape=box style=filled type="arrayvals" tensor="f"] + 21 [comment="type=fiberlookup,index=m,tensor=E,mode=1,format=compressed,src=true,root=false" label="FiberLookup m: E1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="m" tensor="E" mode="1" format="compressed" src="true" root="false"] + 33 [comment="type=repeat,index=k,tensor=f,root=false" label="Repeat k: f" color=cyan2 shape=box style=filled type="repeat" index="k" tensor="f" root="false"] + 29 [comment="type=fiberlookup,index=l,tensor=D,mode=1,format=compressed,src=true,root=false" label="FiberLookup l: D1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="l" tensor="D" mode="1" format="compressed" src="true" root="false"] + 40 [comment="type=repeat,index=j,tensor=E,root=false" label="Repeat j: E" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="E" root="false"] + 41 [comment="type=repeat,index=j,tensor=f,root=false" label="Repeat j: f" color=cyan2 shape=box style=filled type="repeat" index="j" tensor="f" root="false"] + 37 [comment="type=fiberlookup,index=k,tensor=C,mode=1,format=compressed,src=true,root=false" label="FiberLookup k: C1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="k" tensor="C" mode="1" format="compressed" src="true" root="false"] + 48 [comment="type=repeat,index=i,tensor=D,root=true" label="Repeat i: D" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="D" root="true"] + 49 [comment="type=repeat,index=i,tensor=E,root=true" label="Repeat i: E" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="E" root="true"] + 50 [comment="type=repeat,index=i,tensor=f,root=true" label="Repeat i: f" color=cyan2 shape=box style=filled type="repeat" index="i" tensor="f" root="true"] + 45 [comment="type=fiberlookup,index=j,tensor=B,mode=1,format=compressed,src=true,root=false" label="FiberLookup j: B1\ncompressed" color=green4 shape=box style=filled type="fiberlookup" index="j" tensor="B" mode="1" format="compressed" src="true" root="false"] + 54 -> 53 [label="crd" style=dashed type="crd" comment=""] + 53 -> 1 [label="crd" style=dashed type="crd"] + 53 -> 52 [label="crd" style=dashed type="crd"] + 52 -> 51 [label="repsig" style=dotted type="repsig"] + 51 -> 47 [label="repsig" style=dotted type="repsig"] + 47 -> 46 [label="ref" style=bold type="ref"] + 46 -> 44 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 44 -> 43 [label="crd" style=dashed type="crd"] + 43 -> 42 [label="repsig" style=dotted type="repsig"] + 42 -> 39 [label="repsig" style=dotted type="repsig"] + 39 -> 38 [label="ref" style=bold type="ref"] + 38 -> 36 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 36 -> 35 [label="crd" style=dashed type="crd"] + 35 -> 34 [label="repsig" style=dotted type="repsig"] + 34 -> 31 [label="repsig" style=dotted type="repsig"] + 31 -> 23 [label="ref" style=bold type="ref"] + 23 -> 15 [label="ref" style=bold type="ref"] + 15 -> 10 [label="ref" style=bold type="ref"] + 10 -> 9 [label="val" type="val"] + 9 -> 8 [label="val" type="val"] + 8 -> 7 [label="val" type="val"] + 7 -> 6 [label="val" type="val"] + 6 -> 5 [label="val" type="val"] + 5 -> 4 [label="val" type="val"] + 4 -> 3 [label="val" type="val"] + 3 -> 2 [label="val" type="val"] + 2 -> 0 [label="val" type="val"] + 34 -> 32 [label="repsig" style=dotted type="repsig"] + 32 -> 30 [label="ref" style=bold type="ref"] + 30 -> 28 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 28 -> 27 [label="crd" style=dashed type="crd"] + 27 -> 26 [label="repsig" style=dotted type="repsig"] + 26 -> 23 [label="repsig" style=dotted type="repsig"] + 26 -> 24 [label="repsig" style=dotted type="repsig"] + 24 -> 16 [label="ref" style=bold type="ref"] + 16 -> 11 [label="ref" style=bold type="ref"] + 11 -> 9 [label="val" type="val"] + 26 -> 25 [label="repsig" style=dotted type="repsig"] + 25 -> 22 [label="ref" style=bold type="ref"] + 22 -> 20 [label="crd_in-f" style=dashed type="crd" comment="in-f"] + 20 -> 19 [label="crd" style=dashed type="crd"] + 19 -> 18 [label="repsig" style=dotted type="repsig"] + 18 -> 15 [label="repsig" style=dotted type="repsig"] + 18 -> 16 [label="repsig" style=dotted type="repsig"] + 18 -> 17 [label="repsig" style=dotted type="repsig"] + 17 -> 12 [label="ref" style=bold type="ref"] + 12 -> 8 [label="val" type="val"] + 20 -> 13 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 13 -> 7 [label="val" type="val"] + 20 -> 14 [label="ref_out-f" style=bold type="ref" comment="out-f"] + 14 -> 6 [label="val" type="val"] + 22 -> 20 [label="ref_in-f" style=bold type="ref" comment="in-f"] + 28 -> 17 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 28 -> 21 [label="ref_out-E" style=bold type="ref" comment="out-E"] + 21 -> 20 [label="crd_in-E" style=dashed type="crd" comment="in-E"] + 21 -> 20 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 30 -> 28 [label="ref_in-E" style=bold type="ref" comment="in-E"] + 34 -> 33 [label="repsig" style=dotted type="repsig"] + 33 -> 25 [label="ref" style=bold type="ref"] + 36 -> 24 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 36 -> 29 [label="ref_out-D" style=bold type="ref" comment="out-D"] + 29 -> 28 [label="crd_in-D" style=dashed type="crd" comment="in-D"] + 29 -> 28 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 38 -> 36 [label="ref_in-D" style=bold type="ref" comment="in-D"] + 42 -> 40 [label="repsig" style=dotted type="repsig"] + 40 -> 32 [label="ref" style=bold type="ref"] + 42 -> 41 [label="repsig" style=dotted type="repsig"] + 41 -> 33 [label="ref" style=bold type="ref"] + 44 -> 31 [label="ref_out-B" style=bold type="ref" comment="out-B"] + 44 -> 37 [label="ref_out-C" style=bold type="ref" comment="out-C"] + 37 -> 36 [label="crd_in-C" style=dashed type="crd" comment="in-C"] + 37 -> 36 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 46 -> 44 [label="ref_in-C" style=bold type="ref" comment="in-C"] + 51 -> 48 [label="repsig" style=dotted type="repsig"] + 48 -> 39 [label="ref" style=bold type="ref"] + 51 -> 49 [label="repsig" style=dotted type="repsig"] + 49 -> 40 [label="ref" style=bold type="ref"] + 51 -> 50 [label="repsig" style=dotted type="repsig"] + 50 -> 41 [label="ref" style=bold type="ref"] + 54 -> 45 [label="ref" style=bold type="ref" comment=""] + 45 -> 44 [label="crd_in-B" style=dashed type="crd" comment="in-B"] + 45 -> 44 [label="ref_in-B" style=bold type="ref" comment="in-B"] +} diff --git a/sam/sim/src/base.py b/sam/sim/src/base.py index c635c881..2ba86530 100644 --- a/sam/sim/src/base.py +++ b/sam/sim/src/base.py @@ -4,6 +4,7 @@ # warnings.simplefilter(action='ignore', category=FutureWarning) + def gen_stkns(dim=10): return ['S' + str(i) for i in range(dim)] @@ -39,10 +40,12 @@ def is_valid_val(elem, dim=10): def is_0tkn(elem): return elem == 'N' + # Checks if a token is a non-control (numerical) token def is_nc_tkn(elem, datatype=int): return isinstance(elem, datatype) + def is_stkn(elem): if isinstance(elem, str): return elem.startswith('S') and (len(elem) == 2) diff --git a/sam/sim/src/compression.py b/sam/sim/src/compression.py index a87c6386..ad96eb2e 100644 --- a/sam/sim/src/compression.py +++ b/sam/sim/src/compression.py @@ -73,7 +73,9 @@ def update(self): self.curr_ref = '' self.out_refs = '' return - elif (len(self.in_val) > 0 and len(self.in_crd) == 0) or (len(self.in_crd) > 0 and len(self.in_val) == 0) or (len(self.in_val) == 0 and len(self.in_crd) == 0): + elif (len(self.in_val) > 0 and len(self.in_crd) == 0) \ + or (len(self.in_crd) > 0 and len(self.in_val) == 0) \ + or (len(self.in_val) == 0 and len(self.in_crd) == 0): self.out_crds = '' self.out_vals = '' if self.drop_refs: @@ -168,7 +170,7 @@ def set_ref(self, ref, parent=None): def out_crd(self): if (self.backpressure_en and self.data_valid) or not self.backpressure_en: return self.out_crds - + def out_ref(self): if (self.backpressure_en and self.data_valid) or not self.backpressure_en: return self.out_refs From cdbea75071c58ff64c05340535b2d7452bfb40c0 Mon Sep 17 00:00:00 2001 From: Bo Wun Cheng Date: Tue, 17 Oct 2023 09:56:08 -0700 Subject: [PATCH 30/32] fixed style issues that are failing the CI --- sam/onyx/hw_nodes/merge_node.py | 2 +- sam/sim/src/compression.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sam/onyx/hw_nodes/merge_node.py b/sam/onyx/hw_nodes/merge_node.py index bf0ee8b4..9b1f1ae7 100644 --- a/sam/onyx/hw_nodes/merge_node.py +++ b/sam/onyx/hw_nodes/merge_node.py @@ -129,7 +129,7 @@ def configure(self, attributes): cmrg_stop_lvl = 1 op = 0 # 0 for compression, 1 for crddrop - cmrg_mode = self.mode + cmrg_mode = self.mode cfg_kwargs = { 'cmrg_enable': cmrg_enable, 'cmrg_stop_lvl': cmrg_stop_lvl, diff --git a/sam/sim/src/compression.py b/sam/sim/src/compression.py index ad96eb2e..f344a12a 100644 --- a/sam/sim/src/compression.py +++ b/sam/sim/src/compression.py @@ -75,7 +75,7 @@ def update(self): return elif (len(self.in_val) > 0 and len(self.in_crd) == 0) \ or (len(self.in_crd) > 0 and len(self.in_val) == 0) \ - or (len(self.in_val) == 0 and len(self.in_crd) == 0): + or (len(self.in_val) == 0 and len(self.in_crd) == 0): self.out_crds = '' self.out_vals = '' if self.drop_refs: From 0fb04fda60d61adc2287dbe340f5ce27e7190407 Mon Sep 17 00:00:00 2001 From: Bo Wun Cheng Date: Tue, 17 Oct 2023 10:09:44 -0700 Subject: [PATCH 31/32] removed opal graphs that are not ready yet --- .../opal-dot/matmul_ijk_crddrop_relu.gv | 60 ------------------- .../matmul_ijk_crddrop_relu_no_valdrop.gv | 54 ----------------- 2 files changed, 114 deletions(-) delete mode 100644 compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv delete mode 100644 compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv diff --git a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv deleted file mode 100644 index 4d6ba559..00000000 --- a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu.gv +++ /dev/null @@ -1,60 +0,0 @@ -digraph SAM { - comment="X=ss01,B=ss01,C=ss10" - 17 [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"] - 16 [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"] - 15 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] - 14 [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"] - 13 [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"] - 12 [comment="type=broadcast" shape=point style=invis type="broadcast"] - 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"] - 11 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] - 10 [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"] - 8 [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"] - 7 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] - 5 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] - 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] - 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] - 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"] - 6 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] - 9 [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"] - 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] - 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] - 20 [comment="type=max" label="Max 0" color=brown shape=box style=filled type="max"] - 21 [comment="type=valdrop,outer=j,inner=val" label="ValDropper j,val" color=purple shape=box style=filled type="valdrop" outer="j" inner="val"] - 22 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] - 17 -> 16 [label="crd" style=dashed type="crd" comment=""] - 16 -> 15 [label="crd" style=dashed type="crd"] - 15 -> 14 [label="repsig" style=dotted type="repsig"] - 14 -> 13 [label="ref" style=bold type="ref"] - 13 -> 12 [label="crd" style=dashed type="crd" comment=""] - 12 -> 11 [label="crd" style=dashed type="crd"] - 11 -> 10 [label="repsig" style=dotted type="repsig"] - 10 -> 8 [label="ref" style=bold type="ref"] - 8 -> 7 [label="crd_in-B" style=dashed type="crd" comment="in-B"] - 7 -> 5 [label="ref_out-B" style=bold type="ref" comment="out-B"] - 5 -> 4 [label="val" type="val"] - 7 -> 6 [label="ref_out-C" style=bold type="ref" comment="out-C"] - 6 -> 4 [label="val" type="val"] - 8 -> 7 [label="ref_in-B" style=bold type="ref" comment="in-B"] - 13 -> 9 [label="ref" style=bold type="ref" comment=""] - 9 -> 7 [label="crd_in-C" style=dashed type="crd" comment="in-C"] - 9 -> 7 [label="ref_in-C" style=bold type="ref" comment="in-C"] - 17 -> 10 [label="ref" style=bold type="ref" comment=""] - - 4 -> 19 [label="val_inner-k" type="val" comment="inner-k"] - 12 -> 19 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"] - 19 -> 3 [label="val_inner-k" type="val" comment="inner-k"] - 3 -> 20 [label="val" type="val" comment="val"] - 20 -> 21 [label="val" type="val" comment="relu-val"] - 18 -> 21 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] - 21 -> 22 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] - 18 -> 22 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] - - 19 -> 18 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] - 16 -> 18 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] - 21 -> 0 [label="val" type="val"] - - 22 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] - 22 -> 1 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] -} diff --git a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv b/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv deleted file mode 100644 index d4a2c34a..00000000 --- a/compiler/sam-outputs/opal-dot/matmul_ijk_crddrop_relu_no_valdrop.gv +++ /dev/null @@ -1,54 +0,0 @@ -digraph SAM { - comment="X=ss01,B=ss01,C=ss10" - 17 [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"] - 16 [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"] - 15 [comment="type=repsiggen,index=i" label="RepeatSignalGenerator i" color=cyan3 shape=box style=filled type="repsiggen" index="i"] - 14 [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"] - 13 [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"] - 12 [comment="type=broadcast" shape=point style=invis type="broadcast"] - 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"] - 11 [comment="type=repsiggen,index=j" label="RepeatSignalGenerator j" color=cyan3 shape=box style=filled type="repsiggen" index="j"] - 10 [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"] - 8 [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"] - 7 [comment="type=intersect,index=k" label="intersect k" color=purple shape=box style=filled type="intersect" index="k"] - 5 [comment="type=arrayvals,tensor=B" label="Array Vals: B" color=green2 shape=box style=filled type="arrayvals" tensor="B"] - 4 [comment="type=mul" label="Mul" color=brown shape=box style=filled type="mul"] - 3 [comment="type=reduce" label="Reduce" color=brown shape=box style=filled type="reduce"] - 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"] - 6 [comment="type=arrayvals,tensor=C" label="Array Vals: C" color=green2 shape=box style=filled type="arrayvals" tensor="C"] - 9 [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"] - 18 [comment="type=crddrop,outer=i,inner=j" label="CrdDrop i,j" color=orange shape=box style=filled type="crddrop" outer="i" inner="j"] - 19 [comment="type=crddrop,outer=j,inner=k" label="CrdDrop j,k" color=orange shape=box style=filled type="crddrop" outer="j" inner="k"] - 20 [comment="type=max" label="Max 0" color=brown shape=box style=filled type="max"] - 17 -> 16 [label="crd" style=dashed type="crd" comment=""] - 16 -> 15 [label="crd" style=dashed type="crd"] - 15 -> 14 [label="repsig" style=dotted type="repsig"] - 14 -> 13 [label="ref" style=bold type="ref"] - 13 -> 12 [label="crd" style=dashed type="crd" comment=""] - 12 -> 11 [label="crd" style=dashed type="crd"] - 11 -> 10 [label="repsig" style=dotted type="repsig"] - 10 -> 8 [label="ref" style=bold type="ref"] - 8 -> 7 [label="crd_in-B" style=dashed type="crd" comment="in-B"] - 7 -> 5 [label="ref_out-B" style=bold type="ref" comment="out-B"] - 5 -> 4 [label="val" type="val"] - 7 -> 6 [label="ref_out-C" style=bold type="ref" comment="out-C"] - 6 -> 4 [label="val" type="val"] - 8 -> 7 [label="ref_in-B" style=bold type="ref" comment="in-B"] - 13 -> 9 [label="ref" style=bold type="ref" comment=""] - 9 -> 7 [label="crd_in-C" style=dashed type="crd" comment="in-C"] - 9 -> 7 [label="ref_in-C" style=bold type="ref" comment="in-C"] - 17 -> 10 [label="ref" style=bold type="ref" comment=""] - - 4 -> 19 [label="val_inner-k" type="val" comment="inner-k"] - 12 -> 19 [label="crd_outer-j" style=dashed type="crd" comment="outer-j"] - 19 -> 3 [label="val_inner-k" type="val" comment="inner-k"] - 3 -> 20 [label="val" type="val" comment="val"] - - 19 -> 18 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] - 16 -> 18 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] - 20 -> 0 [label="val" type="val"] - - 18 -> 2 [label="crd_outer-i" style=dashed type="crd" comment="outer-i"] - 18 -> 1 [label="crd_inner-j" style=dashed type="crd" comment="inner-j"] -} From 5dd14cd3e5f9d3f554db5af2db6f308313a5d916 Mon Sep 17 00:00:00 2001 From: Bo Wun Cheng Date: Tue, 17 Oct 2023 10:47:04 -0700 Subject: [PATCH 32/32] added unit test for valdropper --- sam/sim/test/primitives/test_compression.py | 85 +++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 sam/sim/test/primitives/test_compression.py diff --git a/sam/sim/test/primitives/test_compression.py b/sam/sim/test/primitives/test_compression.py new file mode 100644 index 00000000..b3163dbc --- /dev/null +++ b/sam/sim/test/primitives/test_compression.py @@ -0,0 +1,85 @@ +import pytest +from sam.sim.src.compression import ValDropper +from sam.sim.src.base import remove_emptystr +from sam.sim.test.test import TIMEOUT +import numpy as np + + +@pytest.mark.parametrize("dim1", [8]) +def test_compress_1d(dim1, debug_sim): + nums = np.random.choice([0, 1], size=dim1, p=[.4, .6]) + in1 = nums.tolist() + ['S0', 'D'] + crd_nums = np.arange(dim1) + crd = crd_nums.tolist() + ['S0', 'D'] + # assert (len(in1) == len(in1)) + + gold_val = nums[nums != 0].tolist() + ['S0', 'D'] + gold_crd = np.delete(crd_nums, np.where(nums == 0)).tolist() + ['S0', 'D'] + + comp = ValDropper(debug=debug_sim) + + done = False + time = 0 + + out_val = [] + out_crd = [] + + while not done and time < TIMEOUT: + + if len(in1) > 0: + comp.set_val(in1.pop(0)) + comp.set_crd(crd.pop(0)) + + comp.update() + out_val.append(comp.out_val()) + out_crd.append(comp.out_crd()) + + if debug_sim: + print("Timestep", time, "\t Out:", comp.out_val()) + + done = comp.out_done() + time += 1 + + out_val = remove_emptystr(out_val) + out_crd = remove_emptystr(out_crd) + print("Ref val:", gold_val) + print("Out val:", out_val) + + print("Ref crd:", gold_crd) + print("Out crd:", out_crd) + + assert (out_val == gold_val) + assert (out_crd == gold_crd) + +# @pytest.mark.parametrize("dim1", [4, 16, 32, 64]) +# def test_exp_1d(dim1, debug_sim): +# in1 = [x for x in range(dim1)] + ['S0', 'D'] +# in2 = None +# # assert (len(in1) == len(in1)) + +# gold_val = np.exp(np.arange(dim1)).tolist() + ['S0', 'D'] + +# exp1 = Exp(debug=debug_sim) + +# done = False +# time = 0 +# out_val = [] +# exp1.set_in2(in2) +# while not done and time < TIMEOUT: +# if len(in1) > 0: +# exp1.set_in1(in1.pop(0)) + +# exp1.update() + +# out_val.append(exp1.out_val()) + +# print("Timestep", time, "\t Out:", exp1.out_val()) + +# done = exp1.out_done() +# time += 1 + +# out_val = remove_emptystr(out_val) +# print("Ref:", gold_val) +# print("Out:", out_val) + +# assert (out_val == gold_val)