Skip to content

Commit 36973cd

Browse files
committed
More logging for evaluation.
1 parent 2584656 commit 36973cd

3 files changed

Lines changed: 23 additions & 27 deletions

File tree

cfpq_add_context/add_contexts.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ 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")
63+
64+
#print("entrypoints start")
6365

64-
print("entrypoints start")
6566
#entrypoints = Vector(bool,graph.nrows, name="entrypoints")
6667
#entrypoints << graph.reduce_columnwise(op.lor)
6768
#mask_v(op.lor) << Vector.from_coo(list(set(range(0,graph.nrows)).difference(entrypoints.to_coo(values=False)[0])), values=True, dtype = BOOL)
@@ -74,11 +75,11 @@ def to_label_decomposed_graph(graph):
7475
store_i << graph.select(graphblas.select.select_store).apply(graphblas.unary.decode_store)
7576
print("Matrix for store_i nvals: ", store_i.nvals)
7677

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

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

8384
store_block_count = store_i.reduce_scalar("max").get(0) + 1
8485
load_block_count = load_i.reduce_scalar("max").get(0) + 1
@@ -106,7 +107,7 @@ def to_label_decomposed_graph(graph):
106107

107108

108109

109-
assign_mask = mask_v.diag(name = "assign_mask")
110+
#assign_mask = mask_v.diag(name = "assign_mask")
110111

111112
assign = Matrix(BOOL, graph.ncols, graph.nrows, name = "assign_after_intersection")
112113
assign << graph.select(graphblas.select.select_assign)
@@ -133,17 +134,6 @@ def to_label_decomposed_graph(graph):
133134

134135
#print_matrix_to_dot(assign_r,"assign_r.dot")
135136

136-
137-
138-
139-
140-
141-
142-
143-
144-
145-
146-
147137
matrices: Dict[Symbol, Matrix] = {}
148138

149139
matrices[Symbol('alloc')] = alloc
@@ -164,10 +154,10 @@ def to_label_decomposed_graph(graph):
164154
matrices=matrices
165155
)
166156

167-
def add_context(file_path):
157+
def add_context(file_path, max_num_of_contexts):
168158
load_graph_start = time.perf_counter()
169159

170-
graph,number_of_contexts = load_graph(file_path)
160+
graph,number_of_contexts = load_graph(file_path, max_num_of_contexts)
171161

172162
load_graph_end = time.perf_counter()
173163
print("Graph loaded in ", load_graph_end - load_graph_start)

cfpq_add_context/load_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010

11-
def load_graph(file_path):
11+
def load_graph(file_path, max_num_of_contexts = 30):
1212
nvertices = 0
1313
number_of_contexts = 0
1414
def get_edge_lbl(terminal):
@@ -25,13 +25,13 @@ def get_edge_lbl(terminal):
2525
elif data_arr[0] == "alloc":
2626
return labels.mk_other(labels.ALLOC)
2727
elif "open" in data_arr[0]:
28-
_context = int(data_arr[0].split('_')[1])
28+
_context = int(data_arr[0].split('_')[1]) % max_num_of_contexts
2929
res = labels.mk_open_context_from_pass(_context)
3030

3131
number_of_contexts = max(number_of_contexts, _context)
3232
return res
3333
elif "close" in data_arr[0]:
34-
_context = int(data_arr[0].split('_')[1])
34+
_context = int(data_arr[0].split('_')[1]) % max_num_of_contexts
3535
res = labels.mk_close_context_from_ret(_context)
3636
number_of_contexts = max(number_of_contexts, _context)
3737
return res

cfpq_cli/run_all_pairs_cflr.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ def run_all_pairs_cflr(
2626
settings: List[AlgoSetting],
2727
add_contexts: bool = False,
2828
expected_path: str = "",
29+
max_num_of_contexts = 30,
2930
):
31+
total_start = time()
3032
algo = get_all_pairs_cfl_reachability_algo(algo_name)
3133
if add_contexts:
32-
graph,initial_graph_nvertices = add_context(graph_path)
34+
graph,initial_graph_nvertices = add_context(graph_path, max_num_of_contexts)
3335
else:
3436
graph = LabelDecomposedGraph.read_from_pocr_graph_file(graph_path)
3537
grammar = CnfGrammarTemplate.read_from_pocr_cnf_file(grammar_path)
@@ -53,6 +55,8 @@ def run_all_pairs_cflr(
5355
with open(out_path, 'w', encoding="utf-8") as out_file:
5456
for (source, target) in res:
5557
out_file.write(f"{source}\t{target}\n")
58+
print ("Graph name: ", graph_path)
59+
print("Total execution time = ", time() - total_start)
5660
except TimeoutException:
5761
print("AnalysisTime\tNaN")
5862
print("#SEdges\tNaN")
@@ -83,6 +87,8 @@ def main(raw_args: List[str]):
8387
'`Count:\\n <START_NON_TERMINAL>`.')
8488
parser.add_argument('--time-limit', dest='time_limit', default=None, type=int,
8589
help='Sets a time limit in seconds.')
90+
parser.add_argument('--max-num-of-contexts', dest='max_num_of_contexts', default=30, type=int,
91+
help='Sets a maximal number of contexts.')
8692
parser.add_argument('--out', dest='out', default=None,
8793
help='Specifies the output file for saving vertex pairs. '
8894
'The line format is: `[START_VERTEX]\t[END_VERTEX]`. '

0 commit comments

Comments
 (0)