Skip to content

Commit e5ca89c

Browse files
committed
Ignore reversed edges on graph loading. Add them back ater intersection.
1 parent d7b8e28 commit e5ca89c

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

cfpq_add_context/add_contexts.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ def to_label_decomposed_graph(graph):
3131
print("Boolean matrix for alloc nvals: ", alloc.nvals)
3232

3333
alloc_r = Matrix(BOOL, graph.ncols, graph.nrows, name = "alloc_r_after_intersection")
34-
alloc_r << graph.select(graphblas.select.select_alloc_r)
34+
#alloc_r << graph.select(graphblas.select.select_alloc_r)
35+
alloc_r << alloc.T
3536
print("Boolean matrix for alloc_r nvals: ", alloc_r.nvals)
3637

3738
assign = Matrix(BOOL, graph.ncols, graph.nrows, name = "assign_after_intersection")
3839
assign << graph.select(graphblas.select.select_assign)
3940
print("Boolean matrix for assign nvals: ", assign.nvals)
4041

4142
assign_r = Matrix(BOOL, graph.ncols, graph.nrows, name = "assign_r_after_intersection")
42-
assign_r << graph.select(graphblas.select.select_assign_r)
43-
assign_r << assign_r + graph.select(graphblas.select.select_pass_and_return).T
43+
#assign_r << graph.select(graphblas.select.select_assign_r)
44+
#assign_r << assign_r + graph.select(graphblas.select.select_pass_and_return).T
45+
assign_r << assign.T
4446
print("Boolean matrix for assign_r nvals: ", assign_r.nvals)
4547

4648
#print_matrix_to_dot(assign_r,"assign_r.dot")
@@ -49,13 +51,15 @@ def to_label_decomposed_graph(graph):
4951
load_i << graph.select(graphblas.select.select_load).apply(graphblas.unary.decode_load)
5052

5153
load_r_i = Matrix(UINT64, graph.ncols, graph.nrows, name = "load_r_i_after_intersection")
52-
load_r_i << graph.select(graphblas.select.select_load_r).apply(graphblas.unary.decode_load_r)
54+
#load_r_i << graph.select(graphblas.select.select_load_r).apply(graphblas.unary.decode_load_r)
55+
load_r_i << load_i.T
5356

5457
store_i = Matrix(UINT64, graph.ncols, graph.nrows, name = "store_i_after_intersection")
5558
store_i << graph.select(graphblas.select.select_store).apply(graphblas.unary.decode_store)
5659

5760
store_r_i = Matrix(UINT64, graph.ncols, graph.nrows, name = "store_r_i_after_intersection")
58-
store_r_i << graph.select(graphblas.select.select_store_r).apply(graphblas.unary.decode_store_r)
61+
#store_r_i << graph.select(graphblas.select.select_store_r).apply(graphblas.unary.decode_store_r)
62+
store_r_i << store_i.T
5963

6064
store_block_count = store_i.reduce_scalar("max").get(0) + 1
6165
load_block_count = load_i.reduce_scalar("max").get(0) + 1

cfpq_add_context/intersection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def intersection (graph, automata) :
7070
entrypoints << graph.select(graphblas.select.select_not_reversed).reduce_columnwise(graphblas.monoid.lor)
7171
entrypoints = set(range(0,graph.nrows)).difference(entrypoints.to_coo(values=False)[0])
7272

73-
print("entypoints:", entrypoints)
73+
#print("entypoints:", entrypoints)
7474

7575
#sources = [i * automata.nrows for i in range(0,graph.nrows)]
7676
sources = [i * automata.nrows for i in entrypoints]
@@ -84,7 +84,7 @@ def intersection (graph, automata) :
8484
unreachable_vertices_removing_end = time.perf_counter()
8585
print("Removing of unreachable vertices done in ", unreachable_vertices_removing_end - zeroes_removing_from_intersection_end)
8686

87-
#print_matrix_to_dot(result, "kron_filtered.dot")
87+
print_matrix_to_dot(result, "kron_filtered.dot")
8888
return result
8989

9090

cfpq_add_context/labels.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ def intersection_op (x:int, y:int) -> int:
2929
BinaryOp.register_new("intersection_op", intersection_op)
3030
Monoid.register_new("labels_intersection", binary.intersection_op, identity=NOTHING)
3131

32-
#def mk_open_context(x:int) -> int :
33-
# return NOTHING | (x << 43)
34-
#def mk_close_context(x:int) -> int :
35-
# return NOTHING | (x << 22)
36-
3732
def mk_open_context_from_pass(x:int) -> int :
3833
return NOTHING | ((2 * (x + 1) + 1) << 43)
3934
def mk_close_context_from_ret(x:int) -> int :

cfpq_add_context/load_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def get_edge_lbl(data_arr):
2525
return labels.mk_store(int(data_arr[3]))
2626
elif data_arr[2] == "assign":
2727
return labels.mk_other(labels.ASSIGN)
28-
elif data_arr[2] == "assign_r":
29-
return labels.mk_other(labels.ASSIGN_R)
28+
#elif data_arr[2] == "assign_r":
29+
# return labels.mk_other(labels.ASSIGN_R)
3030
elif data_arr[2] == "alloc":
3131
return labels.mk_other(labels.ALLOC)
3232
elif data_arr[2] == "alloc_r":
@@ -66,7 +66,7 @@ def handle_line(line):
6666
return (_from, _to, _lbl)
6767

6868
with open (file_path,'r') as file:
69-
edges = [handle_line(line) for line in file if len(line.strip()) > 0]
69+
edges = [handle_line(line) for line in file if len(line.strip()) > 0 and not("_r") in line]
7070
#TODO Remove dup_op! It is a hack to avoid edges duplication.
7171
result = Matrix.from_edgelist(edges, dtype=UINT64, nrows=nvertices + 1, ncols=nvertices + 1, name="graph",dup_op="max")
7272
#print_matrix_to_dot(result, "graph.dot")

0 commit comments

Comments
 (0)