Skip to content

Commit

Permalink
fix: detection of intra iteration dependencies for first iteration fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Apr 10, 2024
1 parent 524f828 commit 3b71549
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion discopop_explorer/pattern_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down
10 changes: 9 additions & 1 deletion discopop_explorer/pattern_detectors/do_all_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion discopop_explorer/pattern_detectors/reduction_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 14 additions & 4 deletions rtlib/iFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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;
Expand Down

0 comments on commit 3b71549

Please sign in to comment.