Skip to content

Commit 95cc8fd

Browse files
committed
Turn transitive reduction on. From all start states, not entrypoints.
1 parent 6b0c667 commit 95cc8fd

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

cfpq_add_context/add_contexts.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def transitive_reduction(assigns, mask):
4646
break
4747
return result
4848

49-
def to_label_decomposed_graph(graph):
49+
def to_label_decomposed_graph(graph, automata_size, initial_graph_size):
5050
vertex_count = graph.nrows
5151
alloc = Matrix(BOOL, graph.ncols, graph.nrows, name = "alloc_after_intersection")
5252
alloc << graph.select(graphblas.select.select_alloc)
@@ -56,16 +56,17 @@ def to_label_decomposed_graph(graph):
5656
alloc_r << alloc.T
5757
print("Boolean matrix for alloc_r nvals: ", alloc_r.nvals)
5858

59-
#print("mask start")
60-
#mask_v = Vector(BOOL, graph.ncols, name = "mask_vector")
61-
#mask_v(op.lor) << alloc.reduce_columnwise("lor")
62-
#mask_v(op.lor) << alloc.reduce_rowwise("lor")
59+
print("mask start")
60+
mask_v = Vector(BOOL, graph.ncols, name = "mask_vector")
61+
mask_v(op.lor) << alloc.reduce_columnwise("lor")
62+
mask_v(op.lor) << alloc.reduce_rowwise("lor")
6363

64-
#print("entrypoints start")
64+
print("entrypoints start")
6565

6666
#entrypoints = Vector(bool,graph.nrows, name="entrypoints")
6767
#entrypoints << graph.reduce_columnwise(op.lor)
6868
#mask_v(op.lor) << Vector.from_coo(list(set(range(0,graph.nrows)).difference(entrypoints.to_coo(values=False)[0])), values=True, dtype = BOOL)
69+
mask_v(op.lor) << Vector.from_coo([i * automata_size for i in range(0, initial_graph_size)], values=True, dtype = BOOL, size= graph.ncols)
6970

7071
load_i = Matrix(UINT64, graph.ncols, graph.nrows, name = "load_i_after_intersection")
7172
load_i << graph.select(graphblas.select.select_load).apply(graphblas.unary.decode_load)
@@ -75,11 +76,11 @@ def to_label_decomposed_graph(graph):
7576
store_i << graph.select(graphblas.select.select_store).apply(graphblas.unary.decode_store)
7677
print("Matrix for store_i nvals: ", store_i.nvals)
7778

78-
#mask_v(op.lor) << load_i.reduce_columnwise("lor")
79-
#mask_v(op.lor) << load_i.reduce_rowwise("lor")
79+
mask_v(op.lor) << load_i.reduce_columnwise("lor")
80+
mask_v(op.lor) << load_i.reduce_rowwise("lor")
8081

81-
#mask_v(op.lor) << store_i.reduce_columnwise("lor")
82-
#mask_v(op.lor) << store_i.reduce_rowwise("lor")
82+
mask_v(op.lor) << store_i.reduce_columnwise("lor")
83+
mask_v(op.lor) << store_i.reduce_rowwise("lor")
8384

8485
store_block_count = store_i.reduce_scalar("max").get(0) + 1
8586
load_block_count = load_i.reduce_scalar("max").get(0) + 1
@@ -107,14 +108,14 @@ def to_label_decomposed_graph(graph):
107108

108109

109110

110-
#assign_mask = mask_v.diag(name = "assign_mask")
111+
assign_mask = mask_v.diag(name = "assign_mask")
111112

112113
assign = Matrix(BOOL, graph.ncols, graph.nrows, name = "assign_after_intersection")
113114
assign << graph.select(graphblas.select.select_assign)
114115
print("Boolean matrix for assign nvals: ", assign.nvals)
115116

116117

117-
# !!! assign << transitive_reduction(assign, assign_mask)
118+
assign << transitive_reduction(assign, assign_mask)
118119

119120
#assign_res = Matrix(BOOL, graph.ncols, graph.nrows, name = "assign_after_transitive_reduction")
120121
#assign_1 = Matrix.mxm(assign_mask, assign, "land_lor")
@@ -179,7 +180,7 @@ def add_context(file_path, max_num_of_contexts):
179180
print("Vertices in intersection: ", result.ncols)
180181
print("Edges in intersection: ", result.nvals)
181182

182-
decomposed_result = to_label_decomposed_graph(result)
183+
decomposed_result = to_label_decomposed_graph(result, automata.nrows, graph.nrows)
183184
decomposition_end = time.perf_counter()
184185
print("Graph decomposition competed in ", decomposition_end - intersection_end)
185186

0 commit comments

Comments
 (0)