Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def visit(self, node):
# be aware of metadata
md.visit(self, node)
return super(ExtendedDefUseChains, self).visit(node)
def handle_omp_for(self, node, local_iter):
"""
Fix OpenMP directives on For loops.
Add the target as private variable as a new variable may have been
introduce to handle cxx iterator.
Also, add the iterator as shared variable as all 'parallel for chunck'
have to use the same iterator.
"""
for directive in metadata.get(node, OMPDirective):
if any(key in directive.s for key in (' parallel ', ' task ')):
# Eventually add local_iter in a shared clause as iterable is
# shared in the for loop (for every clause with datasharing)
directive.s += ' shared({})'
directive.deps.append(ast.Name(local_iter, ast.Load(),
None, None))
directive.shared_deps.append(directive.deps[-1])
target = node.target
assert isinstance(target, ast.Name)
hasfor = 'for' in directive.s
nodefault = 'default' not in directive.s
noindexref = all(isinstance(x, ast.Name) and
x.id != target.id for x in directive.deps)
if (hasfor and nodefault and noindexref and
target.id not in self.scope[node]):