psyclone.psyir.nodes.directive

This module contains the Directive, RegionDirective, StandaloneDirective node implementation.

Classes

  • Directive: Abstract base class for all Directive statements.

  • RegionDirective: Base class for all Directive nodes that have an associated

  • StandaloneDirective: Base class for all StandaloneDirective statements. This class is

class psyclone.psyir.nodes.directive.Directive(ast=None, children=None, parent=None, annotations=None)

Abstract base class for all Directive statements.

Inheritance

Inheritance diagram of Directive
abstract property clauses
Returns:

the Clauses associated with this directive.

Return type:

List of psyclone.psyir.nodes.Clause

create_data_movement_deep_copy_refs()

Creates the References required to perform a deep copy (in e.g. OpenACC or OpenMP) of all of the quantities accessed in Nodes below this one in the tree. It distringuishes between those quantities that are only read, only written or are both read and written. The necessary References are added to the returned OrderedDicts in the order in which they must be copied.

Returns:

a 3-tuple containing dicts describing the quantities that are read-only, write-only and readwrite. Each dict contains References indexed by Signatures.

Return type:

Tuple[OrderedDict[psyclone.core.Signature, psyclone.psyir.nodes.Reference]]

class psyclone.psyir.nodes.directive.RegionDirective(ast=None, children=None, parent=None)

Base class for all Directive nodes that have an associated region of code with them.

All classes that generate RegionDirective statements (e.g. OpenMP, OpenACC, compiler-specific) inherit from this class.

Parameters:
  • ast (Optional[fparser.two.Fortran2003.Base]) – the entry in the fparser2 parse tree representing the code contained within this directive or None.

  • children (Optional[List[psyclone.psyir.nodes.Node]]) – the nodes that will be children of this Directive node or None.

  • parent (Optional[psyclone.psyir.nodes.Node]) – PSyIR node that is the parent of this Directive or None.

Inheritance

Inheritance diagram of RegionDirective
property clauses
Returns:

the Clauses associated with this directive.

Return type:

List of psyclone.psyir.nodes.Clause

property dir_body
Returns:

the Schedule associated with this directive.

Return type:

psyclone.psyir.nodes.Schedule

Raises:

InternalError – if this node does not have a Schedule as its first child.

gen_post_region_code(parent)

Generates any code that must be executed immediately after the end of the region defined by this directive.

TODO #1648 this method is only used by the gen_code() code-generation path and should be replaced by functionality in a ‘lower_to_language_level’ method in an LFRic-specific subclass of the appropriate directive.

Parameters:

parent (psyclone.f2pygen.BaseGen) – where to add new f2pygen nodes.

class psyclone.psyir.nodes.directive.StandaloneDirective(ast=None, children=None, parent=None, annotations=None)

Base class for all StandaloneDirective statements. This class is designed for directives which do not have code associated with them, e.g. OpenMP’s taskwait.

All classes that generate StandaloneDirective statements (e.g. OpenMP, OpenACC, compiler-specific) inherit from this class.

Inheritance

Inheritance diagram of StandaloneDirective
property clauses
Returns:

the Clauses associated with this directive.

Return type:

List of psyclone.psyir.nodes.Clause