Reference Guide  2.5.0
psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective Class Reference
Inheritance diagram for psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective:
Collaboration diagram for psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective:

Public Member Functions

def __init__ (self, **kwargs)
 
def gen_code (self, parent)
 
def lower_to_language_level (self)
 
def begin_string (self)
 
def end_string (self)
 
def validate_global_constraints (self)
 
- Public Member Functions inherited from psyclone.psyir.nodes.omp_directives.OMPParallelDirective
def default_clause (self)
 
def private_clause (self)
 
def infer_sharing_attributes (self)
 
- Public Member Functions inherited from psyclone.psyir.nodes.directive.RegionDirective
def __init__ (self, ast=None, children=None, parent=None)
 
def dir_body (self)
 
def clauses (self)
 
def gen_post_region_code (self, parent)
 
- Public Member Functions inherited from psyclone.psyir.nodes.directive.Directive
def create_data_movement_deep_copy_refs (self)
 
- Public Member Functions inherited from psyclone.psyir.nodes.node.Node
def __init__ (self, ast=None, children=None, parent=None, annotations=None)
 
def coloured_name (self, colour=True)
 
def __str__ (self)
 
def ast (self)
 
def ast_end (self)
 
def ast (self, ast)
 
def ast_end (self, ast_end)
 
def annotations (self)
 
def dag (self, file_name='dag', file_format='svg')
 
def dag_gen (self, graph)
 
def dag_name (self)
 
def args (self)
 
def backward_dependence (self)
 
def forward_dependence (self)
 
def is_valid_location (self, new_node, position="before")
 
def depth (self)
 
def view (self, depth=0, colour=True, indent=" ", _index=None)
 
def addchild (self, child, index=None)
 
def children (self)
 
def children (self, my_children)
 
def parent (self)
 
def siblings (self)
 
def has_constructor_parent (self)
 
def position (self)
 
def abs_position (self)
 
def root (self)
 
def sameParent (self, node_2)
 
def walk (self, my_type, stop_type=None, depth=None)
 
def get_sibling_lists (self, my_type, stop_type=None)
 
def ancestor (self, my_type, excluding=None, include_self=False, limit=None, shared_with=None)
 
def kernels (self)
 
def following (self, routine=True)
 
def preceding (self, reverse=False, routine=True)
 
def immediately_precedes (self, node_2)
 
def immediately_follows (self, node_1)
 
def coded_kernels (self)
 
def loops (self)
 
def reductions (self, reprod=None)
 
def is_openmp_parallel (self)
 
def reference_accesses (self, var_accesses)
 
def scope (self)
 
def replace_with (self, node, keep_name_in_context=True)
 
def pop_all_children (self)
 
def detach (self)
 
def copy (self)
 
def debug_string (self)
 
def origin_string (self)
 
def update_signal (self)
 
def path_from (self, ancestor)
 
- Public Member Functions inherited from psyclone.psyir.nodes.commentable_mixin.CommentableMixin
def preceding_comment (self)
 
def preceding_comment (self, comment)
 
def inline_comment (self)
 
def inline_comment (self, comment)
 
- Public Member Functions inherited from psyclone.psyir.nodes.omp_directives.OMPDoDirective
def __init__ (self, omp_schedule="none", collapse=None, reprod=None, **kwargs)
 
def __eq__ (self, other)
 
def collapse (self)
 
def collapse (self, value)
 
def node_str (self, colour=True)
 
def omp_schedule (self)
 
def omp_schedule (self, value)
 
def reprod (self)
 
def reprod (self, value)
 

Additional Inherited Members

- Static Public Member Functions inherited from psyclone.psyir.nodes.omp_directives.OMPParallelDirective
def create (children=None)
 
- Public Attributes inherited from psyclone.psyir.nodes.node.Node
 position
 
- Public Attributes inherited from psyclone.psyir.nodes.omp_directives.OMPDoDirective
 collapse
 
 omp_schedule
 
 reprod
 
- Static Public Attributes inherited from psyclone.psyir.nodes.node.Node
int START_DEPTH = 0
 
int START_POSITION = 0
 
 valid_annotations = tuple()
 

Detailed Description

 Class for the !$OMP PARALLEL DO directive. This inherits from
    both OMPParallelDirective (because it creates a new OpenMP
    thread-parallel region) and OMPDoDirective (because it
    causes a loop to be parallelised).

    :param kwargs: additional keyword arguments provided to the PSyIR node.
    :type kwargs: unwrapped dict.

Definition at line 2182 of file omp_directives.py.

Member Function Documentation

◆ begin_string()

def psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective.begin_string (   self)
Returns the beginning statement of this directive, i.e.
"omp parallel do ...". The visitor is responsible for adding the
correct directive beginning (e.g. "!$").

:returns: the beginning statement for this directive.
:rtype: str

Reimplemented from psyclone.psyir.nodes.omp_directives.OMPParallelDirective.

Definition at line 2315 of file omp_directives.py.

2315  def begin_string(self):
2316  '''Returns the beginning statement of this directive, i.e.
2317  "omp parallel do ...". The visitor is responsible for adding the
2318  correct directive beginning (e.g. "!$").
2319 
2320  :returns: the beginning statement for this directive.
2321  :rtype: str
2322 
2323  '''
2324  string = f"omp {self._directive_string}"
2325  if self._collapse:
2326  string += f" collapse({self._collapse})"
2327  string += self._reduction_string()
2328  return string
2329 

References psyclone.psyir.nodes.acc_directives.ACCLoopDirective._collapse, psyclone.psyir.nodes.omp_directives.OMPDoDirective._collapse, psyclone.psyir.nodes.omp_directives.OMPLoopDirective._collapse, and psyclone.psyir.nodes.omp_directives.OMPDoDirective._reduction_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end_string()

def psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective.end_string (   self)
Returns the end (or closing) statement of this directive, i.e.
"omp end parallel do". The visitor is responsible for adding the
correct directive beginning (e.g. "!$").

:returns: the end statement for this directive.
:rtype: str

Reimplemented from psyclone.psyir.nodes.omp_directives.OMPParallelDirective.

Definition at line 2330 of file omp_directives.py.

2330  def end_string(self):
2331  '''Returns the end (or closing) statement of this directive, i.e.
2332  "omp end parallel do". The visitor is responsible for adding the
2333  correct directive beginning (e.g. "!$").
2334 
2335  :returns: the end statement for this directive.
2336  :rtype: str
2337 
2338  '''
2339  return f"omp end {self._directive_string}"
2340 
Here is the caller graph for this function:

◆ gen_code()

def psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective.gen_code (   self,
  parent 
)
Generate the f2pygen AST entries in the Schedule for this OpenMP
directive.

TODO #1648: Note that gen_code ignores the collapse clause but the
generated code is still valid. Since gen_code is going to be removed
and it is only used for LFRic (which does not support GPU offloading
that gets improved with the collapse clause) it will not be supported.

:param parent: the parent Node in the Schedule to which to add our \
               content.
:type parent: sub-class of :py:class:`psyclone.f2pygen.BaseGen`

Reimplemented from psyclone.psyir.nodes.omp_directives.OMPParallelDirective.

Definition at line 2227 of file omp_directives.py.

2227  def gen_code(self, parent):
2228  '''
2229  Generate the f2pygen AST entries in the Schedule for this OpenMP
2230  directive.
2231 
2232  TODO #1648: Note that gen_code ignores the collapse clause but the
2233  generated code is still valid. Since gen_code is going to be removed
2234  and it is only used for LFRic (which does not support GPU offloading
2235  that gets improved with the collapse clause) it will not be supported.
2236 
2237  :param parent: the parent Node in the Schedule to which to add our \
2238  content.
2239  :type parent: sub-class of :py:class:`psyclone.f2pygen.BaseGen`
2240 
2241  '''
2242  # We're not doing nested parallelism so make sure that this
2243  # omp parallel do is not already within some parallel region
2244  # pylint: disable=import-outside-toplevel
2245  from psyclone.psyGen import zero_reduction_variables
2246  self.validate_global_constraints()
2247 
2248  calls = self.reductions()
2249  zero_reduction_variables(calls, parent)
2250 
2251  # Set default() private() and firstprivate() clauses
2252  # pylint: disable=protected-access
2253  default_str = self.children[1]._clause_string
2254  # pylint: enable=protected-access
2255  private, fprivate, need_sync = self.infer_sharing_attributes()
2256  private_clause = OMPPrivateClause.create(
2257  sorted(private, key=lambda x: x.name))
2258  fprivate_clause = OMPFirstprivateClause.create(
2259  sorted(fprivate, key=lambda x: x.name))
2260  if need_sync:
2261  raise GenerationError(
2262  f"OMPParallelDoDirective.gen_code() does not support symbols "
2263  f"that need synchronisation, but found: "
2264  f"{[x.name for x in need_sync]}")
2265 
2266  private_str = ""
2267  fprivate_str = ""
2268  private_list = [child.symbol.name for child in private_clause.children]
2269  if private_list:
2270  private_str = "private(" + ",".join(private_list) + ")"
2271  fp_list = [child.symbol.name for child in fprivate_clause.children]
2272  if fp_list:
2273  fprivate_str = "firstprivate(" + ",".join(fp_list) + ")"
2274 
2275  # Set schedule clause
2276  if self._omp_schedule != "none":
2277  schedule_str = f"schedule({self._omp_schedule})"
2278  else:
2279  schedule_str = ""
2280 
2281  # Add directive to the f2pygen tree
2282  parent.add(
2283  DirectiveGen(
2284  parent, "omp", "begin", "parallel do", ", ".join(
2285  text for text in [default_str, private_str, fprivate_str,
2286  schedule_str, self._reduction_string()]
2287  if text)))
2288 
2289  for child in self.dir_body:
2290  child.gen_code(parent)
2291 
2292  # make sure the directive occurs straight after the loop body
2293  position = parent.previous_loop()
2294  parent.add(DirectiveGen(parent, *self.end_string().split()),
2295  position=["after", position])
2296 
2297  self.gen_post_region_code(parent)
2298 

References psyclone.psyir.nodes.omp_directives.OMPDoDirective._omp_schedule, psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._omp_schedule, psyclone.psyir.nodes.omp_directives.OMPDoDirective._reduction_string(), psyclone.f2pygen.BaseGen.children(), psyclone.psyGen.InlinedKern.children, psyclone.psyir.nodes.node.Node.children(), psyclone.psyir.nodes.directive.RegionDirective.dir_body(), psyclone.psyir.nodes.acc_directives.ACCParallelDirective.end_string(), psyclone.psyir.nodes.acc_directives.ACCLoopDirective.end_string(), psyclone.psyir.nodes.acc_directives.ACCKernelsDirective.end_string(), psyclone.psyir.nodes.acc_directives.ACCDataDirective.end_string(), psyclone.psyir.nodes.acc_directives.ACCAtomicDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPSingleDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPMasterDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPParallelDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPTaskloopDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPDoDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPTargetDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPLoopDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPAtomicDirective.end_string(), psyclone.psyir.nodes.omp_directives.OMPSimdDirective.end_string(), psyclone.psyir.nodes.omp_task_directive.OMPTaskDirective.end_string(), psyclone.psyir.nodes.directive.RegionDirective.gen_post_region_code(), psyclone.psyir.nodes.omp_directives.OMPParallelDirective.infer_sharing_attributes(), psyclone.psyir.nodes.node.Node.reductions(), psyclone.domain.lfric.lfric_kern.LFRicKern.validate_global_constraints(), psyclone.psyir.nodes.acc_directives.ACCRegionDirective.validate_global_constraints(), psyclone.psyir.nodes.acc_directives.ACCLoopDirective.validate_global_constraints(), psyclone.psyir.nodes.acc_directives.ACCAtomicDirective.validate_global_constraints(), psyclone.psyir.nodes.node.Node.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPDeclareTargetDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPTaskwaitDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPSerialDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPParallelDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPTaskloopDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPDoDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPLoopDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPAtomicDirective.validate_global_constraints(), psyclone.psyir.nodes.omp_directives.OMPSimdDirective.validate_global_constraints(), and psyclone.psyir.nodes.omp_task_directive.OMPTaskDirective.validate_global_constraints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lower_to_language_level()

def psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective.lower_to_language_level (   self)
In-place construction of clauses as PSyIR constructs.
The clauses here may need to be updated if code has changed, or be
added if not yet present.

:returns: the lowered version of this node.
:rtype: :py:class:`psyclone.psyir.node.Node`

Reimplemented from psyclone.psyir.nodes.omp_directives.OMPParallelDirective.

Definition at line 2299 of file omp_directives.py.

2299  def lower_to_language_level(self):
2300  '''
2301  In-place construction of clauses as PSyIR constructs.
2302  The clauses here may need to be updated if code has changed, or be
2303  added if not yet present.
2304 
2305  :returns: the lowered version of this node.
2306  :rtype: :py:class:`psyclone.psyir.node.Node`
2307 
2308  '''
2309  # Calling the super() explicitly to avoid confusion
2310  # with the multiple-inheritance
2311  OMPParallelDirective.lower_to_language_level(self)
2312  self.addchild(OMPScheduleClause(self._omp_schedule))
2313  return self
2314 

References psyclone.psyir.nodes.omp_directives.OMPDoDirective._omp_schedule, psyclone.psyir.transformations.omp_loop_trans.OMPLoopTrans._omp_schedule, and psyclone.psyir.nodes.node.Node.addchild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_global_constraints()

def psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective.validate_global_constraints (   self)
Perform validation checks that can only be done at code-generation
time.

Reimplemented from psyclone.psyir.nodes.omp_directives.OMPParallelDirective.

Definition at line 2341 of file omp_directives.py.

2341  def validate_global_constraints(self):
2342  '''
2343  Perform validation checks that can only be done at code-generation
2344  time.
2345 
2346  '''
2347  OMPParallelDirective.validate_global_constraints(self)
2348 
2349  self._validate_single_loop()
2350  self._validate_collapse_value()
2351 
2352 

References psyclone.psyir.nodes.omp_directives.OMPDoDirective._validate_collapse_value(), and psyclone.psyir.nodes.omp_directives.OMPDoDirective._validate_single_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: