Skip to content

Commit

Permalink
fix(explorer): reduced potential for false positives, more pessimisti…
Browse files Browse the repository at this point in the history
…c analysis
  • Loading branch information
lukasrothenberger committed Mar 5, 2024
1 parent bc94ac0 commit a46df39
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
64 changes: 33 additions & 31 deletions discopop_explorer/PEGraphX.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,37 +768,39 @@ def calculateFunctionMetadata(self, hotspot_information=None, func_nodes=None) -
print("\tMetadata calculation done.")

# cleanup dependencies (remove dependencies, if it is overwritten by a more specific Intra-iteration dependency
print("Cleaning duplicated dependencies...")
to_be_removed = []
for cu_node in self.all_nodes(CUNode):
out_deps = self.out_edges(cu_node.id, EdgeType.DATA)
for dep_1 in out_deps:
for dep_2 in out_deps:
if dep_1 == dep_2:
continue
if (
dep_1[2].dtype == dep_2[2].dtype
and dep_1[2].etype == dep_2[2].etype
and dep_1[2].memory_region == dep_2[2].memory_region
and dep_1[2].sink_line == dep_2[2].sink_line
and dep_1[2].source_line == dep_2[2].source_line
and dep_1[2].var_name == dep_2[2].var_name
):
if not dep_1[2].intra_iteration and dep_2[2].intra_iteration:
# dep_2 is a more specific duplicate of dep_1
# remove dep_1
to_be_removed.append(dep_1)

to_be_removed_with_keys = []
for dep in to_be_removed:
graph_edges = self.g.out_edges(dep[0], keys=True, data="data")

for s, t, key, data in graph_edges:
if dep[0] == s and dep[1] == t and dep[2] == data:
to_be_removed_with_keys.append((s, t, key))
for edge in set(to_be_removed_with_keys):
self.g.remove_edge(edge[0], edge[1], edge[2])
print("Cleaning dependencies done.")
# note: this can introduce false positives! Keep the analysis pessimistic to ensure correctness
if False:
print("Cleaning duplicated dependencies...")
to_be_removed = []
for cu_node in self.all_nodes(CUNode):
out_deps = self.out_edges(cu_node.id, EdgeType.DATA)
for dep_1 in out_deps:
for dep_2 in out_deps:
if dep_1 == dep_2:
continue
if (
dep_1[2].dtype == dep_2[2].dtype
and dep_1[2].etype == dep_2[2].etype
and dep_1[2].memory_region == dep_2[2].memory_region
and dep_1[2].sink_line == dep_2[2].sink_line
and dep_1[2].source_line == dep_2[2].source_line
and dep_1[2].var_name == dep_2[2].var_name
):
if not dep_1[2].intra_iteration and dep_2[2].intra_iteration:
# dep_2 is a more specific duplicate of dep_1
# remove dep_1
to_be_removed.append(dep_1)

to_be_removed_with_keys = []
for dep in to_be_removed:
graph_edges = self.g.out_edges(dep[0], keys=True, data="data")

for s, t, key, data in graph_edges:
if dep[0] == s and dep[1] == t and dep[2] == data:
to_be_removed_with_keys.append((s, t, key))
for edge in set(to_be_removed_with_keys):
self.g.remove_edge(edge[0], edge[1], edge[2])
print("Cleaning dependencies done.")

# cleanup dependencies II : only consider the Intra-iteration dependencies with the highest level
print("Cleaning duplicated dependencies II...")
Expand Down
8 changes: 5 additions & 3 deletions rtlib/iFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ namespace __dp {
if(unpackLIDMetadata_getLoopID(curr) != (LID) 0xFF && unpackLIDMetadata_getLoopID(depOn) != (LID) 0xFF){
if(unpackLIDMetadata_getLoopID(curr) == unpackLIDMetadata_getLoopID(depOn)){
// check innermost loop first
if(unpackLIDMetadata_getLoopIteration_0(curr) == unpackLIDMetadata_getLoopIteration_0(depOn)){
if((unpackLIDMetadata_getLoopIteration_0(curr) == unpackLIDMetadata_getLoopIteration_0(depOn)) && unpackLIDMetadata_getLoopIteration_0(curr) != 0){

// modify depType if intraIterationDependency identified
switch(type) {
Expand All @@ -142,7 +142,9 @@ namespace __dp {
}
}
// check second loop
else if(unpackLIDMetadata_getLoopIteration_1(curr) == unpackLIDMetadata_getLoopIteration_1(depOn)){
else if((unpackLIDMetadata_getLoopIteration_1(curr) == unpackLIDMetadata_getLoopIteration_1(depOn)) && unpackLIDMetadata_getLoopIteration_2(curr) != 0){



// modify depType if intraIterationDependency identified
switch(type) {
Expand All @@ -160,7 +162,7 @@ namespace __dp {
}
}
// check outer loop
else if(unpackLIDMetadata_getLoopIteration_2(curr) == unpackLIDMetadata_getLoopIteration_2(depOn)){
else if((unpackLIDMetadata_getLoopIteration_2(curr) == unpackLIDMetadata_getLoopIteration_2(depOn)) && unpackLIDMetadata_getLoopIteration_2(curr) != 0){
// modify depType if intraIterationDependency identified
switch(type) {
case RAW:
Expand Down

0 comments on commit a46df39

Please sign in to comment.