diff --git a/discopop_explorer/PEGraphX.py b/discopop_explorer/PEGraphX.py index ebeeac67d..65b9b8475 100644 --- a/discopop_explorer/PEGraphX.py +++ b/discopop_explorer/PEGraphX.py @@ -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...") diff --git a/rtlib/iFunctions.cpp b/rtlib/iFunctions.cpp index 131104088..652595951 100755 --- a/rtlib/iFunctions.cpp +++ b/rtlib/iFunctions.cpp @@ -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) { @@ -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) { @@ -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: