@@ -25,13 +25,16 @@ def indexed_to_boolean_decomposition(graph, block_count):
2525 ncols = vertex_count , name = "boolean_decomposition_of_indexed" )
2626 return result
2727
28- def transitive_reduction (assigns , mask ):
28+ def transitive_reduction (assigns , mask , exit_mask ):
2929 result = Matrix (BOOL , assigns .ncols , assigns .ncols , name = "reduced_assigns" )
3030 result << Matrix .mxm (mask , assigns , "any_pair" )
31- total = Matrix (BOOL , assigns .ncols , assigns .ncols , name = "closure " )
31+ total = Matrix (BOOL , assigns .ncols , assigns .ncols , name = "total_closure " )
3232 unused_assigns = Matrix (BOOL , assigns .ncols , assigns .ncols , name = "unused_assigns" )
3333 unused_assigns (~ result .S ) << assigns
34- closure = unused_assigns
34+ closure = Matrix (BOOL , assigns .ncols , assigns .ncols , name = "closure" )
35+ print ("exit" , exit_mask )
36+ print ("unused assigns" , unused_assigns )
37+ closure << Matrix .mxm (exit_mask , unused_assigns , "any_pair" )
3538 total ("any" ) << closure
3639 #while closure.nvals > 0:
3740 while True :
@@ -59,16 +62,17 @@ def to_label_decomposed_graph(graph, automata_size, initial_graph_size):
5962
6063 print ("mask start" )
6164 mask_v = Vector (BOOL , graph .ncols , name = "mask_vector" )
62- mask_v (op .lor ) << alloc .reduce_columnwise ("lor" )
63- mask_v (op .lor ) << alloc .reduce_rowwise ("lor" )
65+ exit_mask_v = Vector (BOOL , graph .ncols , name = "exit_mask_vector" )
66+ mask_v (op .lor ) << alloc .reduce_columnwise ("lor" )
67+ exit_mask_v (op .lor ) << alloc .reduce_rowwise ("lor" )
6468
6569 #print("entrypoints start")
6670
6771 #entrypoints = Vector(bool,graph.nrows, name="entrypoints")
6872 #entrypoints << graph.reduce_columnwise(op.lor)
6973 #mask_v(op.lor) << Vector.from_coo(list(set(range(0,graph.nrows)).difference(entrypoints.to_coo(values=False)[0])), values=True, dtype = BOOL)
7074
71- 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 )
75+ exit_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 )
7276
7377 load_i = Matrix (UINT64 , graph .ncols , graph .nrows , name = "load_i_after_intersection" )
7478 load_i << graph .select (graphblas .select .select_load ).apply (graphblas .unary .decode_load )
@@ -79,10 +83,10 @@ def to_label_decomposed_graph(graph, automata_size, initial_graph_size):
7983 print ("Matrix for store_i nvals: " , store_i .nvals )
8084
8185 mask_v (op .lor ) << load_i .reduce_columnwise ("lor" )
82- mask_v (op .lor ) << load_i .reduce_rowwise ("lor" )
86+ exit_mask_v (op .lor ) << load_i .reduce_rowwise ("lor" )
8387
8488 mask_v (op .lor ) << store_i .reduce_columnwise ("lor" )
85- mask_v (op .lor ) << store_i .reduce_rowwise ("lor" )
89+ exit_mask_v (op .lor ) << store_i .reduce_rowwise ("lor" )
8690
8791 store_block_count = store_i .reduce_scalar ("max" ).get (0 ) + 1
8892 load_block_count = load_i .reduce_scalar ("max" ).get (0 ) + 1
@@ -109,15 +113,16 @@ def to_label_decomposed_graph(graph, automata_size, initial_graph_size):
109113 print ("Boolean matrix for store_r nvals: " , boolean_decompose_store_r .nvals )
110114
111115
112-
116+ mask_v ( "any" ) << exit_mask_v
113117 assign_mask = mask_v .diag (name = "assign_mask" )
118+ exit_mask = exit_mask_v .diag (name = "exit_mask" )
114119
115120 assign = Matrix (BOOL , graph .ncols , graph .nrows , name = "assign_after_intersection" )
116121 assign << graph .select (graphblas .select .select_assign )
117122 print ("Boolean matrix for assign nvals: " , assign .nvals )
118123
119124
120- assign << transitive_reduction (assign , assign_mask )
125+ assign << transitive_reduction (assign , assign_mask , exit_mask )
121126
122127 #assign_res = Matrix(BOOL, graph.ncols, graph.nrows, name = "assign_after_transitive_reduction")
123128 #assign_1 = Matrix.mxm(assign_mask, assign, "land_lor")
0 commit comments