diff --git a/discopop_explorer/pattern_detection.py b/discopop_explorer/pattern_detection.py index 27cda8f79..0044923e7 100644 --- a/discopop_explorer/pattern_detection.py +++ b/discopop_explorer/pattern_detection.py @@ -91,7 +91,7 @@ def detect_patterns( print("\tDONE.") if "*" in enable_patterns or "doall" in enable_patterns: print("DOALL...") - res.patterns.do_all = detect_do_all(self.pet, hotspots) + res.patterns.do_all = detect_do_all(self.pet, hotspots, res.patterns.reduction) print("\tDONE.") if "*" in enable_patterns or "pipeline" in enable_patterns: print("PIPELINE...") diff --git a/discopop_explorer/pattern_detectors/do_all_detector.py b/discopop_explorer/pattern_detectors/do_all_detector.py index cf9241bea..36d48a1a6 100644 --- a/discopop_explorer/pattern_detectors/do_all_detector.py +++ b/discopop_explorer/pattern_detectors/do_all_detector.py @@ -12,6 +12,7 @@ from alive_progress import alive_bar # type: ignore from .PatternInfo import PatternInfo +from .reduction_detector import ReductionInfo from ..PEGraphX import ( CUNode, LoopNode, @@ -67,7 +68,7 @@ def __str__(self): global_pet = None -def run_detection(pet: PEGraphX, hotspots) -> List[DoAllInfo]: +def run_detection(pet: PEGraphX, hotspots, reduction_info: List[ReductionInfo]) -> List[DoAllInfo]: """Search for do-all loop pattern :param pet: PET graph @@ -80,6 +81,13 @@ def run_detection(pet: PEGraphX, hotspots) -> List[DoAllInfo]: result: List[DoAllInfo] = [] nodes = pet.all_nodes(LoopNode) + # remove reduction loops + print("ASDF: ", [r.node_id for r in reduction_info]) + print("Nodes: ", [n.id for n in nodes]) + print("pre:", len(nodes)) + nodes = [n for n in nodes if n.id not in [r.node_id for r in reduction_info]] + print("post:", len(nodes)) + nodes = cast(List[LoopNode], filter_for_hotspots(pet, cast(List[Node], nodes), hotspots)) param_list = [(node) for node in nodes] diff --git a/discopop_explorer/pattern_detectors/reduction_detector.py b/discopop_explorer/pattern_detectors/reduction_detector.py index aaacc2247..c17c82c1d 100644 --- a/discopop_explorer/pattern_detectors/reduction_detector.py +++ b/discopop_explorer/pattern_detectors/reduction_detector.py @@ -82,7 +82,7 @@ def run_detection(pet: PEGraphX, hotspots) -> List[ReductionInfo]: tmp_result = list(tqdm.tqdm(pool.imap_unordered(__check_node, param_list), total=len(param_list))) for local_result in tmp_result: result += local_result - print("GLOBAL RES: ", result) + print("GLOBAL RES: ", [r.start_line for r in result]) for pattern in result: pattern.get_workload(pet) diff --git a/rtlib/iFunctions.cpp b/rtlib/iFunctions.cpp index 6f6d4d37e..76a766a4a 100755 --- a/rtlib/iFunctions.cpp +++ b/rtlib/iFunctions.cpp @@ -119,12 +119,19 @@ namespace __dp { type = INIT; // End HA +// cout << "AddDep: CURR: " << decodeLID(curr) << " DepOn: " << decodeLID(depOn) << " LoopIDS: " << hex << unpackLIDMetadata_getLoopID(curr) << ";" << hex << unpackLIDMetadata_getLoopID(depOn); +// cout << " Loop Iterations: " << unpackLIDMetadata_getLoopIteration_0(curr) << ";" << unpackLIDMetadata_getLoopIteration_1(curr) << ";" << unpackLIDMetadata_getLoopIteration_2(curr); +// cout << " " << unpackLIDMetadata_getLoopIteration_0(depOn) << ";" << unpackLIDMetadata_getLoopIteration_1(depOn) << ";" << unpackLIDMetadata_getLoopIteration_2(depOn) << " orig.type: " << type; + // Compare metadata (Loop ID's and Loop Iterations) from LID's if loop id's are overwritten (not 0xFF anymore) and check for intra-iteration dependencies // Intra-Iteration dependency exists, if LoopId's and Iteration Id's are equal if(unpackLIDMetadata_getLoopID(curr) != (LID) 0xFF && unpackLIDMetadata_getLoopID(depOn) != (LID) 0xFF){ +// cout << "1 CURR: " << decodeLID(curr) << " DepOn: " << decodeLID(depOn) << "\n"; if(unpackLIDMetadata_getLoopID(curr) == unpackLIDMetadata_getLoopID(depOn)){ +// cout << "2 CURR: " << decodeLID(curr) << " DepOn: " << decodeLID(depOn) << "\n"; // check innermost loop first - if((unpackLIDMetadata_getLoopIteration_0(curr) == unpackLIDMetadata_getLoopIteration_0(depOn)) && unpackLIDMetadata_getLoopIteration_0(curr) != 0){ + if((unpackLIDMetadata_getLoopIteration_0(curr) == unpackLIDMetadata_getLoopIteration_0(depOn))){ +// cout << "3 CURR: " << decodeLID(curr) << " DepOn: " << decodeLID(depOn) << "\n"; // modify depType if intraIterationDependency identified switch(type) { @@ -142,8 +149,8 @@ namespace __dp { } } // check second loop - else if((unpackLIDMetadata_getLoopIteration_1(curr) == unpackLIDMetadata_getLoopIteration_1(depOn)) && unpackLIDMetadata_getLoopIteration_2(curr) != 0){ - + else if((unpackLIDMetadata_getLoopIteration_1(curr) == unpackLIDMetadata_getLoopIteration_1(depOn))){ +// cout << "4 CURR: " << decodeLID(curr) << " DepOn: " << decodeLID(depOn) << "\n"; // modify depType if intraIterationDependency identified @@ -162,7 +169,8 @@ namespace __dp { } } // check outer loop - else if((unpackLIDMetadata_getLoopIteration_2(curr) == unpackLIDMetadata_getLoopIteration_2(depOn)) && unpackLIDMetadata_getLoopIteration_2(curr) != 0){ + else if((unpackLIDMetadata_getLoopIteration_2(curr) == unpackLIDMetadata_getLoopIteration_2(depOn))){ +// cout << "5 CURR: " << decodeLID(curr) << " DepOn: " << decodeLID(depOn) << "\n"; // modify depType if intraIterationDependency identified switch(type) { case RAW: @@ -182,6 +190,8 @@ namespace __dp { } } +// cout << " --> CURR: " << decodeLID(curr) << " DepOn: " << decodeLID(depOn) << " Final Type: " << type << "\n"; + // Remove metadata to preserve result correctness and add metadata to `Dep` object curr &= 0x00000000FFFFFFFF;