diff --git a/generate_spmv_sparsity_sweep.py b/generate_spmv_sparsity_sweep.py index 7437d023..570777e7 100644 --- a/generate_spmv_sparsity_sweep.py +++ b/generate_spmv_sparsity_sweep.py @@ -15,7 +15,7 @@ # generating matrix dimensions and storing results in an array, array size is 2, 1 matrix and 2 dimensions per matrix -# conditions which need to be met for each set of 3 tensor dimensions: no dimension can't be 0, +# conditions which need to be met for each set of 3 tensor dimensions: no dimension can't be 0, # and can't have a tensor with more than 900 elements (meaning dimension1*dimension2*dimension3 <= 900) # note try to make it so no dimension is 1 or 2 (gives slight issues later, esp 2nd and 3rd dimensions) dimensions = [0] * 2 @@ -129,7 +129,7 @@ # first step: one randomly generated 3D tensor given first set dimensions # Note: generally if 2/3 elems in a tensor is 0, it can be considered sparse -# approach: 2/3 of the time add in a 0, 1/3 of the time add in an integer from 0 to 100 +# approach: 2/3 of the time add in a 0, 1/3 of the time add in an integer from 0 to 100 # (use randint to generate num from 1 to 9 inclusive, and depending on where the num is, insert number or not) # print('dimensions:') # print(dimensions[0]) diff --git a/maximum_tiling.py b/maximum_tiling.py index 33933671..dff29f3e 100644 --- a/maximum_tiling.py +++ b/maximum_tiling.py @@ -131,10 +131,10 @@ def pair_tiles(app_name): continue for f in f_tensors: f_loc = get_tile_id(f) - if (d_loc[1] == e_loc[0] and d_loc[3] == e_loc[2] and + if (d_loc[1] == e_loc[0] and d_loc[3] == e_loc[2] and c_loc[1] == d_loc[0] and c_loc[3] == d_loc[2] and - b_loc[1] == c_loc[0] and b_loc[3] == c_loc[2] and - e_loc[1] == f_loc[0] and e_loc[3] == f_loc[1]): + b_loc[1] == c_loc[0] and b_loc[3] == c_loc[2] and + e_loc[1] == f_loc[0] and e_loc[3] == f_loc[1]): tile_pairing[tile] = [b, c, d, e, f] tile += 1 diff --git a/sam/sim/src/tiling/tile.py b/sam/sim/src/tiling/tile.py index 96d4f96f..4733bf5d 100644 --- a/sam/sim/src/tiling/tile.py +++ b/sam/sim/src/tiling/tile.py @@ -22,18 +22,18 @@ sys.path.append(custom_path) SAM_STRS = { -"matmul_kij": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss:1,0 -f=C:ss -s=reorder(k,i,j)", -"matmul_ikj": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss -s=reorder(i,k,j)", -"matmul_ijk": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)", -"mat_elemadd": "X(i,j)=B(i,j)+C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)", -"mat_elemmul": "X(i,j)=B(i,j)*C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)", -"mat_mattransmul": "X(i,j)=B(j,i)*c(j)+d(i) -f=X:ss -f=B:ss -f=c:ss:0 -f=d:ss:0 -s=reorder(i,j)", -"mat_vecmul_ij": "X(i,j)=B(i,j)*c(j) -f=X:ss -f=B:ss -f=c:ss:0 -s=reorder(i,j)", -"mat_residual": "X(i,j)=b(i)-C(i,j)*d(j) -f=X:ss -f=C:ss -f=b:ss:0 -f=d:ss:0 -s=reorder(i,j)", -"mat_sddmm": "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:dd -f=D:dd:1,0 -s=reorder(i,j,k)", -"mat_elemadd3": "X(i,j)=B(i,j)+C(i,j)+D(i,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss", -"mat_mask_tri": "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)", -"mat_vecmul_iter": "X(i,j)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=X:ss -f=B:ss -f=C:ss -f=D:ss -f=E:ss -f=f:s -s=reorder(i,j,k,l,m)" + "matmul_kij": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss:1,0 -f=C:ss -s=reorder(k,i,j)", + "matmul_ikj": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss -s=reorder(i,k,j)", + "matmul_ijk": "X(i,j)=B(i,k)*C(k,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)", + "mat_elemadd": "X(i,j)=B(i,j)+C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)", + "mat_elemmul": "X(i,j)=B(i,j)*C(i,j) -f=X:ss -f=B:ss -f=C:ss:1,0 -s=reorder(i,j,k)", + "mat_mattransmul": "X(i,j)=B(j,i)*c(j)+d(i) -f=X:ss -f=B:ss -f=c:ss:0 -f=d:ss:0 -s=reorder(i,j)", + "mat_vecmul_ij": "X(i,j)=B(i,j)*c(j) -f=X:ss -f=B:ss -f=c:ss:0 -s=reorder(i,j)", + "mat_residual": "X(i,j)=b(i)-C(i,j)*d(j) -f=X:ss -f=C:ss -f=b:ss:0 -f=d:ss:0 -s=reorder(i,j)", + "mat_sddmm": "X(i,j)=B(i,j)*C(i,k)*D(k,j) -f=X:ss -f=B:ss -f=C:dd -f=D:dd:1,0 -s=reorder(i,j,k)", + "mat_elemadd3": "X(i,j)=B(i,j)+C(i,j)+D(i,j) -f=X:ss -f=B:ss -f=C:ss -f=D:ss", + "mat_mask_tri": "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)", + "mat_vecmul_iter": "X(i,j)=B(i,j)*C(j,k)*D(k,l)*E(l,m)*f(m) -f=X:ss -f=B:ss -f=C:ss -f=D:ss -f=E:ss -f=f:s -s=reorder(i,j,k,l,m)" } diff --git a/scripts/tiling/generate_gold_mattransmul.py b/scripts/tiling/generate_gold_mattransmul.py index 2401faa5..73cb6573 100644 --- a/scripts/tiling/generate_gold_mattransmul.py +++ b/scripts/tiling/generate_gold_mattransmul.py @@ -93,13 +93,13 @@ def generate_gold_mattransmul_tiled(tile_crd_b, tile_crd_c, tile_crd_d, dirname, # print(gold_nd) gold_out = gold_nd.tocoo() - assert (tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1] - and tile_crd_b[0] == tile_crd_d[0] and tile_crd_b[2] == tile_crd_d[1]) + assert (tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1] and + tile_crd_b[0] == tile_crd_d[0] and tile_crd_b[2] == tile_crd_d[1]) # assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[2] scipy.io.mmwrite( - dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1]) + "_" + str(tile_crd_b[3]) + "_" - + str(tile_crd_b[2]) + "_" + str(tile_crd_c[0]) + "_" + str(tile_crd_c[1]) - + "_" + str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out) + dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1]) + "_" + str(tile_crd_b[3]) + "_" + + str(tile_crd_b[2]) + "_" + str(tile_crd_c[0]) + "_" + str(tile_crd_c[1]) + + "_" + str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out) elif os.path.exists(d_filename): d_scipy = scipy.io.mmread(d_filename) # print("\nd_scipy: ", d_scipy) @@ -127,14 +127,14 @@ def generate_gold_mattransmul_tiled(tile_crd_b, tile_crd_c, tile_crd_d, dirname, return gold_out = gold_nd.tocoo() - # assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1] + # assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[1] # and tile_crd_b[0] == tile_crd_d[0] and tile_crd_b[2] == tile_crd_d[1] # assert tile_crd_b[1] == tile_crd_c[0] and tile_crd_b[3] == tile_crd_c[2] scipy.io.mmwrite( - dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1]) - + "_" + str(tile_crd_b[3]) + "_" + str(tile_crd_b[2]) + "_" - + str(tile_crd_c[0]) + "_" + str(tile_crd_c[1]) + "_" - + str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out) + dirname + "out_" + str(tile_crd_b[0]) + "_" + str(tile_crd_b[1]) + + "_" + str(tile_crd_b[3]) + "_" + str(tile_crd_b[2]) + "_" + + str(tile_crd_c[0]) + "_" + str(tile_crd_c[1]) + "_" + + str(tile_crd_d[0]) + "_" + str(tile_crd_d[1]) + ".mtx", gold_out) if __name__ == "__main__": diff --git a/setup_tiling_mat.py b/setup_tiling_mat.py index 1aa26241..286ed79b 100644 --- a/setup_tiling_mat.py +++ b/setup_tiling_mat.py @@ -10,7 +10,7 @@ # Usage: python3 setup_tiling_mat.py -# PARAMS +# PARAMS data = [sys.argv[2]] tilesizes = [int(sys.argv[3])] app_name = sys.argv[1] diff --git a/setup_tiling_tensors.py b/setup_tiling_tensors.py index a704b765..8ab5c76c 100644 --- a/setup_tiling_tensors.py +++ b/setup_tiling_tensors.py @@ -4,7 +4,7 @@ import shutil from scripts.util.util import FormatWriter, InputCacheSuiteSparse -# PARAMS +# PARAMS tile = True app_name = "tensor3_ttv" vector_names = ['c']