Skip to content

Commit

Permalink
fix(explorer): incorrect variable clauses due to pass by value arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Jul 26, 2024
1 parent c5e3458 commit 2c2ca03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion discopop_explorer/pattern_detectors/reduction_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def __check_node(param_tuple: LoopNode) -> List[ReductionInfo]:

def __detect_reduction(pet: PEGraphX, root: LoopNode) -> bool:
"""Detects reduction pattern in loop
:param pet: PET graph
:param root: the loop node
:return: true if is reduction loop
Expand Down
13 changes: 13 additions & 0 deletions discopop_explorer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,24 @@ def get_child_loops(pet: PEGraphX, node: Node) -> Tuple[List[Node], List[Node]]:
def get_initialized_memory_regions_in(pet: PEGraphX, cu_nodes: List[CUNode]) -> Dict[Variable, Set[MemoryRegion]]:
initialized_memory_regions: Dict[Variable, Set[MemoryRegion]] = dict()
for cu in cu_nodes:
parent_function = pet.get_parent_function(cu)
for s, t, d in pet.out_edges(cu.id, EdgeType.DATA):
if d.dtype == DepType.INIT and d.memory_region is not None:
# get variable object from cu
for var in cu.global_vars + cu.local_vars:
if var.name == d.var_name:
# ignore pass by value type function arguments
is_passed_by_value = False
if str(parent_function.start_position()) == var.defLine:
for arg in parent_function.args:
if arg.name == var.name:
if "*" not in arg.type:
# found pass by value argument
is_passed_by_value = True
break
if is_passed_by_value:
continue

if var not in initialized_memory_regions:
initialized_memory_regions[var] = set()
# create entry for initialized variable
Expand Down

0 comments on commit 2c2ca03

Please sign in to comment.