Reference Guide
2.5.0
|
Public Member Functions | |
def | __init__ (self, ast=None, children=None, parent=None, annotations=None) |
def | __eq__ (self, other) |
def | coloured_name (self, colour=True) |
def | node_str (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 | lower_to_language_level (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 | validate_global_constraints (self) |
def | debug_string (self) |
def | origin_string (self) |
def | update_signal (self) |
def | path_from (self, ancestor) |
Public Attributes | |
position | |
Static Public Attributes | |
int | START_DEPTH = 0 |
int | START_POSITION = 0 |
valid_annotations = tuple() | |
Base class for a PSyIR node. :param ast: reference into the fparser2 AST corresponding to this node. :type ast: sub-class of :py:class:`fparser.two.Fortran2003.Base` :param children: the PSyIR nodes that are children of this node. :type children: list of :py:class:`psyclone.psyir.nodes.Node` :param parent: that parent of this node in the PSyIR tree. :type parent: :py:class:`psyclone.psyir.nodes.Node` :param annotations: Tags that provide additional information about \ the node. The node should still be functionally correct when \ ignoring these tags. :type annotations: list of str :raises TypeError: if a parent is supplied that is not an instance of Node. :raises InternalError: if an invalid annotation tag is supplied.
def psyclone.psyir.nodes.node.Node.__eq__ | ( | self, | |
other | |||
) |
Checks whether two nodes are equal. The basic implementation of this checks whether the nodes are the same type, and whether all children of the nodes are equal, and if so then they are considered equal. :param object other: the object to check equality to. :returns: whether other is equal to self. :rtype: bool
Reimplemented in psyclone.psyir.nodes.scoping_node.ScopingNode, psyclone.psyir.nodes.routine.Routine, psyclone.psyir.nodes.reference.Reference, psyclone.psyir.nodes.psy_data_node.PSyDataNode, psyclone.psyir.nodes.operation.Operation, psyclone.psyir.nodes.omp_directives.OMPLoopDirective, psyclone.psyir.nodes.omp_directives.OMPDoDirective, psyclone.psyir.nodes.omp_clauses.OMPDependClause, psyclone.psyir.nodes.omp_clauses.OMPScheduleClause, psyclone.psyir.nodes.member.Member, psyclone.psyir.nodes.loop.Loop, psyclone.psyir.nodes.literal.Literal, psyclone.psyir.nodes.extract_node.ExtractNode, psyclone.psyir.nodes.container.Container, psyclone.psyir.nodes.codeblock.CodeBlock, psyclone.psyir.nodes.call.Call, psyclone.psyir.nodes.acc_directives.ACCUpdateDirective, psyclone.psyir.nodes.acc_directives.ACCKernelsDirective, and psyclone.psyir.nodes.acc_directives.ACCLoopDirective.
Definition at line 410 of file node.py.
References psyclone.f2pygen.BaseGen.children(), psyclone.psyGen.InlinedKern.children, and psyclone.psyir.nodes.node.Node.children().
def psyclone.psyir.nodes.node.Node.abs_position | ( | self | ) |
Find a Node's absolute position in the tree (starting with 0 if it is the root). Needs to be computed dynamically from the starting position (0) as its position may change. :returns: absolute position of a Node in the tree. :rtype: int :raises InternalError: if the absolute position cannot be found.
Definition at line 994 of file node.py.
References psyclone.psyir.nodes.node.Node._find_position(), psyclone.f2pygen.BaseGen.root(), psyclone.f2pygen.BaseDeclGen.root(), psyclone.psyir.nodes.node.Node.root(), and psyclone.psyir.nodes.node.Node.START_POSITION.
def psyclone.psyir.nodes.node.Node.addchild | ( | self, | |
child, | |||
index = None |
|||
) |
Adds the supplied node as a child of this node (at position index if supplied). The supplied node must not have an existing parent. :param child: the node to add as a child of this one. :type child: :py:class:`psyclone.psyir.nodes.Node` :param index: optional position at which to insert new child. Default \ is to append new child to the list of existing children. :type index: Optional[int]
Definition at line 909 of file node.py.
References psyclone.f2pygen.BaseGen._children, psyclone.psyir.nodes.node.Node._children, and psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children.
def psyclone.psyir.nodes.node.Node.ancestor | ( | self, | |
my_type, | |||
excluding = None , |
|||
include_self = False , |
|||
limit = None , |
|||
shared_with = None |
|||
) |
Search back up the tree and check whether this node has an ancestor that is an instance of the supplied type. If it does then we return it otherwise we return None. An individual (or tuple of) (sub-) class(es) to ignore may be provided via the `excluding` argument. If `include_self` is True then the current node is included in the search. If `limit` is provided then the search ceases if/when the supplied node is encountered. If `shared_with` is provided, then the ancestor search will find an ancestor of both this node and the node provided as `shared_with` if such an ancestor exists. :param my_type: class(es) to search for. :type my_type: type | Tuple[type, ...] :param excluding: (sub-)class(es) to ignore or None. :type excluding: Optional[type | Tuple[type, ...]] :param bool include_self: whether or not to include this node in the \ search. :param limit: an optional node at which to stop the search. :type limit: Optional[:py:class:`psyclone.psyir.nodes.Node`] :param shared_with: an optional node which must also have the found node as an ancestor. :type shared_with: Optional[:py:class:`psyclone.psyir.nodes.Node`] :returns: First ancestor Node that is an instance of any of the \ requested classes or None if not found. :rtype: Optional[:py:class:`psyclone.psyir.nodes.Node`] :raises TypeError: if `excluding` is provided but is not a type or \ tuple of types. :raises TypeError: if `limit` is provided but is not an instance \ of Node.
Definition at line 1160 of file node.py.
References psyclone.f2pygen.BaseGen.parent(), and psyclone.psyir.nodes.node.Node.parent().
def psyclone.psyir.nodes.node.Node.annotations | ( | self | ) |
Return the list of annotations attached to this Node. :returns: List of anotations :rtype: list of str
Definition at line 540 of file node.py.
References psyclone.psyir.nodes.node.Node._annotations.
def psyclone.psyir.nodes.node.Node.args | ( | self | ) |
Return the list of arguments associated with this Node. The default implementation assumes the Node has no directly associated arguments (i.e. is not a Kern class or subclass). Arguments of any of this nodes descendants are considered to be associated.
Definition at line 679 of file node.py.
References psyclone.psyir.nodes.node.Node.kernels().
def psyclone.psyir.nodes.node.Node.ast | ( | self | ) |
:returns: a reference to that part of the fparser2 parse tree that \ this node represents or None. :rtype: sub-class of :py:class:`fparser.two.utils.Base`
Definition at line 502 of file node.py.
References psyclone.alg_gen.Alg._ast, psyclone.parse.kernel.KernelType._ast, and psyclone.psyir.nodes.node.Node._ast.
def psyclone.psyir.nodes.node.Node.ast | ( | self, | |
ast | |||
) |
Set a reference to the fparser2 node associated with this Node. :param ast: fparser2 node associated with this Node. :type ast: :py:class:`fparser.two.utils.Base`
Definition at line 520 of file node.py.
References psyclone.alg_gen.Alg._ast, psyclone.parse.kernel.KernelType._ast, psyclone.psyir.nodes.node.Node._ast, and psyclone.psyir.nodes.node.Node.ast().
def psyclone.psyir.nodes.node.Node.ast_end | ( | self | ) |
:returns: a reference to the last node in the fparser2 parse tree \ that represents a child of this PSyIR node or None. :rtype: sub-class of :py:class:`fparser.two.utils.Base`
Definition at line 511 of file node.py.
References psyclone.psyir.nodes.node.Node._ast_end.
def psyclone.psyir.nodes.node.Node.ast_end | ( | self, | |
ast_end | |||
) |
Set a reference to the last fparser2 node associated with this Node. :param ast: last fparser2 node associated with this Node. :type ast: :py:class:`fparser.two.utils.Base`
Definition at line 530 of file node.py.
References psyclone.psyir.nodes.node.Node._ast_end, and psyclone.psyir.nodes.node.Node.ast_end().
def psyclone.psyir.nodes.node.Node.backward_dependence | ( | self | ) |
Returns the closest preceding Node that this Node has a direct dependence with or None if there is not one. Only Nodes with the same parent as self are returned. Nodes inherit their descendants' dependencies. The reason for this is that for correctness a node must maintain its parent if it is moved. For example a halo exchange and a kernel call may have a dependence between them but it is the loop body containing the kernel call that the halo exchange must not move beyond i.e. the loop body inherits the dependencies of the routines within it.
Definition at line 690 of file node.py.
References psyclone.expression.FunctionVar.args, psyclone.f2pygen.SubroutineGen.args(), psyclone.parse.algorithm.ParsedCall.args(), psyclone.psyGen.GlobalSum.args(), psyclone.psyGen.HaloExchange.args(), psyclone.psyGen.Kern.args(), psyclone.psyGen.Arguments.args(), psyclone.psyir.nodes.node.Node.args(), psyclone.psyir.nodes.node.Node.depth(), psyclone.gocean1p0.GOStencil.depth(), and psyclone.psyir.nodes.node.Node.sameParent().
def psyclone.psyir.nodes.node.Node.children | ( | self | ) |
:returns: the immediate children of this Node. :rtype: List[:py:class:`psyclone.psyir.nodes.Node`]
Definition at line 927 of file node.py.
References psyclone.f2pygen.BaseGen._children, psyclone.psyir.nodes.node.Node._children, and psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children.
def psyclone.psyir.nodes.node.Node.children | ( | self, | |
my_children | |||
) |
Set a new children list. :param my_children: new list of children. :type my_children: list :raises TypeError: if the given children parameter is not a list.
Definition at line 935 of file node.py.
References psyclone.f2pygen.BaseGen._children, psyclone.psyir.nodes.node.Node._children, psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children, psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall._children_valid_format, psyclone.domain.common.algorithm.psyir.KernelFunctor._children_valid_format, psyclone.domain.lfric.algorithm.psyir.lfric_alg_invoke_call.LFRicAlgorithmInvokeCall._children_valid_format, psyclone.psyGen.GlobalSum._children_valid_format, psyclone.psyGen.HaloExchange._children_valid_format, psyclone.psyGen.Kern._children_valid_format, psyclone.psyGen.InlinedKern._children_valid_format, psyclone.psyir.nodes.acc_clauses.ACCCopyClause._children_valid_format, psyclone.psyir.nodes.acc_clauses.ACCCopyInClause._children_valid_format, psyclone.psyir.nodes.acc_clauses.ACCCopyOutClause._children_valid_format, psyclone.psyir.nodes.array_member.ArrayMember._children_valid_format, psyclone.psyir.nodes.array_of_structures_member.ArrayOfStructuresMember._children_valid_format, psyclone.psyir.nodes.array_of_structures_reference.ArrayOfStructuresReference._children_valid_format, psyclone.psyir.nodes.array_reference.ArrayReference._children_valid_format, psyclone.psyir.nodes.assignment.Assignment._children_valid_format, psyclone.psyir.nodes.call.Call._children_valid_format, psyclone.psyir.nodes.clause.Clause._children_valid_format, psyclone.psyir.nodes.codeblock.CodeBlock._children_valid_format, psyclone.psyir.nodes.container.Container._children_valid_format, psyclone.psyir.nodes.directive.RegionDirective._children_valid_format, psyclone.psyir.nodes.directive.StandaloneDirective._children_valid_format, psyclone.psyir.nodes.dynamic_omp_task_directive.DynamicOMPTaskDirective._children_valid_format, psyclone.psyir.nodes.if_block.IfBlock._children_valid_format, psyclone.psyir.nodes.intrinsic_call.IntrinsicCall._children_valid_format, psyclone.psyir.nodes.literal.Literal._children_valid_format, psyclone.psyir.nodes.loop.Loop._children_valid_format, psyclone.psyir.nodes.member.Member._children_valid_format, psyclone.psyir.nodes.node.Node._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPNowaitClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPGrainsizeClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPNumTasksClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPNogroupClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPSharedClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPPrivateClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPFirstprivateClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPDefaultClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPScheduleClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPDependClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPReductionClause._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPSingleDirective._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPTaskloopDirective._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective._children_valid_format, psyclone.psyir.nodes.omp_task_directive.OMPTaskDirective._children_valid_format, psyclone.psyir.nodes.operation.UnaryOperation._children_valid_format, psyclone.psyir.nodes.operation.BinaryOperation._children_valid_format, psyclone.psyir.nodes.psy_data_node.PSyDataNode._children_valid_format, psyclone.psyir.nodes.ranges.Range._children_valid_format, psyclone.psyir.nodes.reference.Reference._children_valid_format, psyclone.psyir.nodes.return_stmt.Return._children_valid_format, psyclone.psyir.nodes.routine.Routine._children_valid_format, psyclone.psyir.nodes.schedule.Schedule._children_valid_format, psyclone.psyir.nodes.structure_member.StructureMember._children_valid_format, psyclone.psyir.nodes.structure_reference.StructureReference._children_valid_format, psyclone.psyir.nodes.while_loop.WhileLoop._children_valid_format, psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall._validate_child(), psyclone.domain.common.algorithm.psyir.KernelFunctor._validate_child(), psyclone.domain.lfric.algorithm.psyir.lfric_alg_invoke_call.LFRicAlgorithmInvokeCall._validate_child(), psyclone.psyGen.InlinedKern._validate_child(), psyclone.psyir.nodes.acc_clauses.ACCCopyClause._validate_child(), psyclone.psyir.nodes.acc_clauses.ACCCopyInClause._validate_child(), psyclone.psyir.nodes.acc_clauses.ACCCopyOutClause._validate_child(), psyclone.psyir.nodes.acc_directives.ACCDataDirective._validate_child(), psyclone.psyir.nodes.array_mixin.ArrayMixin._validate_child(), psyclone.psyir.nodes.array_of_structures_mixin.ArrayOfStructuresMixin._validate_child(), psyclone.psyir.nodes.assignment.Assignment._validate_child(), psyclone.psyir.nodes.call.Call._validate_child(), psyclone.psyir.nodes.container.Container._validate_child(), psyclone.psyir.nodes.directive.RegionDirective._validate_child(), psyclone.psyir.nodes.directive.StandaloneDirective._validate_child(), psyclone.psyir.nodes.if_block.IfBlock._validate_child(), psyclone.psyir.nodes.loop.Loop._validate_child(), psyclone.psyir.nodes.node.Node._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPGrainsizeClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPNumTasksClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPSharedClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPPrivateClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPFirstprivateClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPDependClause._validate_child(), psyclone.psyir.nodes.omp_directives.OMPSingleDirective._validate_child(), psyclone.psyir.nodes.omp_directives.OMPParallelDirective._validate_child(), psyclone.psyir.nodes.omp_directives.OMPTaskloopDirective._validate_child(), psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective._validate_child(), psyclone.psyir.nodes.omp_task_directive.OMPTaskDirective._validate_child(), psyclone.psyir.nodes.operation.UnaryOperation._validate_child(), psyclone.psyir.nodes.operation.BinaryOperation._validate_child(), psyclone.psyir.nodes.psy_data_node.PSyDataNode._validate_child(), psyclone.psyir.nodes.ranges.Range._validate_child(), psyclone.psyir.nodes.schedule.Schedule._validate_child(), psyclone.psyir.nodes.structure_member.StructureMember._validate_child(), psyclone.psyir.nodes.structure_reference.StructureReference._validate_child(), psyclone.psyir.nodes.while_loop.WhileLoop._validate_child(), psyclone.psyir.nodes.node.Node.children(), and psyclone.psyir.nodes.node.Node.pop_all_children().
def psyclone.psyir.nodes.node.Node.coded_kernels | ( | self | ) |
Returns a list of all of the user-supplied kernels (as opposed to builtins) that are beneath this node in the PSyIR. :returns: all user-supplied kernel calls below this node. :rtype: List[:py:class:`psyclone.psyGen.CodedKern`]
Definition at line 1374 of file node.py.
References psyclone.psyir.nodes.node.Node.walk().
def psyclone.psyir.nodes.node.Node.coloured_name | ( | self, | |
colour = True |
|||
) |
Returns the display name of this Node, optionally with colour control codes (requires that the termcolor package be installed). :param bool colour: whether or not to include colour control codes \ in the result. :returns: the name of this node, optionally with colour control codes. :rtype: str
Definition at line 453 of file node.py.
References psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall._colour, psyclone.domain.common.psylayer.psyloop.PSyLoop._colour, psyclone.dynamo0p3.LFRicHaloExchangeStart._colour, psyclone.dynamo0p3.LFRicHaloExchangeEnd._colour, psyclone.psyGen.GlobalSum._colour, psyclone.psyGen.HaloExchange._colour, psyclone.psyGen.CodedKern._colour, psyclone.psyGen.InlinedKern._colour, psyclone.psyGen.BuiltIn._colour, psyclone.psyir.nodes.assignment.Assignment._colour, psyclone.psyir.nodes.call.Call._colour, psyclone.psyir.nodes.clause.Clause._colour, psyclone.psyir.nodes.codeblock.CodeBlock._colour, psyclone.psyir.nodes.container.Container._colour, psyclone.psyir.nodes.directive.Directive._colour, psyclone.psyir.nodes.extract_node.ExtractNode._colour, psyclone.psyir.nodes.file_container.FileContainer._colour, psyclone.psyir.nodes.if_block.IfBlock._colour, psyclone.psyir.nodes.intrinsic_call.IntrinsicCall._colour, psyclone.psyir.nodes.literal.Literal._colour, psyclone.psyir.nodes.loop.Loop._colour, psyclone.psyir.nodes.member.Member._colour, psyclone.psyir.nodes.nan_test_node.NanTestNode._colour, psyclone.psyir.nodes.node.Node._colour, psyclone.psyir.nodes.operation.Operation._colour, psyclone.psyir.nodes.profile_node.ProfileNode._colour, psyclone.psyir.nodes.psy_data_node.PSyDataNode._colour, psyclone.psyir.nodes.ranges.Range._colour, psyclone.psyir.nodes.read_only_verify_node.ReadOnlyVerifyNode._colour, psyclone.psyir.nodes.reference.Reference._colour, psyclone.psyir.nodes.return_stmt.Return._colour, psyclone.psyir.nodes.schedule.Schedule._colour, psyclone.psyir.nodes.while_loop.WhileLoop._colour, psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall._text_name, psyclone.domain.common.algorithm.psyir.KernelFunctor._text_name, psyclone.domain.common.psylayer.psyloop.PSyLoop._text_name, psyclone.domain.lfric.algorithm.psyir.lfric_alg_invoke_call.LFRicAlgorithmInvokeCall._text_name, psyclone.domain.lfric.algorithm.psyir.lfric_kernel_functor.LFRicFunctor._text_name, psyclone.domain.lfric.algorithm.psyir.lfric_kernel_functor.LFRicKernelFunctor._text_name, psyclone.domain.lfric.algorithm.psyir.lfric_kernel_functor.LFRicBuiltinFunctor._text_name, psyclone.dynamo0p3.LFRicHaloExchangeStart._text_name, psyclone.dynamo0p3.LFRicHaloExchangeEnd._text_name, psyclone.gocean1p0.GOInvokeSchedule._text_name, psyclone.nemo.NemoInvokeSchedule._text_name, psyclone.psyGen.InvokeSchedule._text_name, psyclone.psyGen.GlobalSum._text_name, psyclone.psyGen.HaloExchange._text_name, psyclone.psyGen.CodedKern._text_name, psyclone.psyGen.InlinedKern._text_name, psyclone.psyGen.BuiltIn._text_name, psyclone.psyir.nodes.array_member.ArrayMember._text_name, psyclone.psyir.nodes.array_of_structures_member.ArrayOfStructuresMember._text_name, psyclone.psyir.nodes.array_of_structures_reference.ArrayOfStructuresReference._text_name, psyclone.psyir.nodes.array_reference.ArrayReference._text_name, psyclone.psyir.nodes.assignment.Assignment._text_name, psyclone.psyir.nodes.call.Call._text_name, psyclone.psyir.nodes.codeblock.CodeBlock._text_name, psyclone.psyir.nodes.container.Container._text_name, psyclone.psyir.nodes.extract_node.ExtractNode._text_name, psyclone.psyir.nodes.file_container.FileContainer._text_name, psyclone.psyir.nodes.if_block.IfBlock._text_name, psyclone.psyir.nodes.intrinsic_call.IntrinsicCall._text_name, psyclone.psyir.nodes.kernel_schedule.KernelSchedule._text_name, psyclone.psyir.nodes.literal.Literal._text_name, psyclone.psyir.nodes.loop.Loop._text_name, psyclone.psyir.nodes.member.Member._text_name, psyclone.psyir.nodes.nan_test_node.NanTestNode._text_name, psyclone.psyir.nodes.node.Node._text_name, psyclone.psyir.nodes.omp_directives.OMPSingleDirective._text_name, psyclone.psyir.nodes.omp_directives.OMPMasterDirective._text_name, psyclone.psyir.nodes.profile_node.ProfileNode._text_name, psyclone.psyir.nodes.psy_data_node.PSyDataNode._text_name, psyclone.psyir.nodes.ranges.Range._text_name, psyclone.psyir.nodes.read_only_verify_node.ReadOnlyVerifyNode._text_name, psyclone.psyir.nodes.reference.Reference._text_name, psyclone.psyir.nodes.return_stmt.Return._text_name, psyclone.psyir.nodes.routine.Routine._text_name, psyclone.psyir.nodes.schedule.Schedule._text_name, psyclone.psyir.nodes.structure_member.StructureMember._text_name, and psyclone.psyir.nodes.structure_reference.StructureReference._text_name.
def psyclone.psyir.nodes.node.Node.copy | ( | self | ) |
Return a copy of this node. This is a bespoke implementation for PSyIR nodes that will deepcopy some of its recursive data-structure (e.g. the children tree), while not copying other attributes (e.g. top-level parent reference). :returns: a copy of this node and its children. :rtype: :py:class:`psyclone.psyir.node.Node`
Reimplemented in psyclone.psyir.nodes.call.Call.
Definition at line 1588 of file node.py.
def psyclone.psyir.nodes.node.Node.dag | ( | self, | |
file_name = 'dag' , |
|||
file_format = 'svg' |
|||
) |
Create a dag of this node and its children, write it to file and return the graph object. :param str file_name: name of the file to create. :param str file_format: format of the file to create. (Must be one \ recognised by Graphviz.) :returns: the graph object or None (if the graphviz bindings are not \ installed). :rtype: :py:class:`graphviz.Digraph` or NoneType :raises GenerationError: if the specified file format is not \ recognised by Graphviz.
Definition at line 548 of file node.py.
References psyclone.psyir.nodes.node.Node.dag_gen().
def psyclone.psyir.nodes.node.Node.dag_gen | ( | self, | |
graph | |||
) |
Output my node's graph (dag) information and call any children. Nodes with children are represented as two vertices, a start and an end. Forward dependencies are represented as green edges, backward dependencies are represented as red edges (but their direction is reversed so the layout looks reasonable) and parent child dependencies are represented as blue edges.
Definition at line 577 of file node.py.
References psyclone.gocean1p0.GOKernelGridArgument.backward_dependence(), psyclone.psyGen.Argument.backward_dependence(), psyclone.psyir.nodes.node.Node.backward_dependence(), psyclone.f2pygen.BaseGen.children(), psyclone.psyGen.InlinedKern.children, psyclone.psyir.nodes.node.Node.children(), psyclone.domain.common.psylayer.psyloop.PSyLoop.dag_name(), psyclone.psyGen.GlobalSum.dag_name(), psyclone.psyGen.HaloExchange.dag_name(), psyclone.psyGen.CodedKern.dag_name(), psyclone.psyGen.BuiltIn.dag_name(), psyclone.psyir.nodes.loop.Loop.dag_name(), psyclone.psyir.nodes.node.Node.dag_name(), psyclone.psyir.nodes.routine.Routine.dag_name(), psyclone.gocean1p0.GOKernelGridArgument.forward_dependence(), psyclone.psyGen.Argument.forward_dependence(), psyclone.psyir.nodes.node.Node.forward_dependence(), psyclone.psyir.nodes.loop.Loop.loop_body(), psyclone.psyir.nodes.while_loop.WhileLoop.loop_body(), psyclone.f2pygen.BaseGen.parent(), and psyclone.psyir.nodes.node.Node.parent().
def psyclone.psyir.nodes.node.Node.dag_name | ( | self | ) |
Return the dag name for this node. This includes the name of the class and the index of its relative position to the parent Routine. If no parent Routine is found, the index used is the absolute position in the tree. :returns: the dag name for this node. :rtype: str
Reimplemented in psyclone.psyir.nodes.routine.Routine, and psyclone.psyir.nodes.loop.Loop.
Definition at line 659 of file node.py.
References psyclone.psyir.nodes.node.Node._find_position(), psyclone.psyir.nodes.node.Node.abs_position(), psyclone.psyir.nodes.node.Node.ancestor(), and psyclone.psyir.nodes.node.Node.coloured_name().
def psyclone.psyir.nodes.node.Node.debug_string | ( | self | ) |
Generates a Fortran-like output representation but without lowering high-level nodes. This is fast to generate because it doesn't deepcopy the tree like the Language backends and its output, although not compilable, is readable for error messages. :returns: a Fortran-like output representation of the tree. :rtype: str
Definition at line 1619 of file node.py.
def psyclone.psyir.nodes.node.Node.depth | ( | self | ) |
Returns this Node's depth in the tree: 1 for the Schedule and increasing for its descendants at each level. :returns: depth of the Node in the tree :rtype: int
Definition at line 840 of file node.py.
References psyclone.psyir.nodes.node.Node.START_DEPTH.
def psyclone.psyir.nodes.node.Node.detach | ( | self | ) |
Detach this node from the tree it belongs to. This is necessary as a precursor to inserting it as the child of another node. :returns: this node detached from its parent. :rtype: :py:class:`psyclone.psyir.node.Node`
Definition at line 1554 of file node.py.
References psyclone.psyir.nodes.node.Node._annotations, psyclone.f2pygen.BaseGen._children, psyclone.psyir.nodes.node.Node._children, psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children, psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall._children_valid_format, psyclone.domain.common.algorithm.psyir.KernelFunctor._children_valid_format, psyclone.domain.lfric.algorithm.psyir.lfric_alg_invoke_call.LFRicAlgorithmInvokeCall._children_valid_format, psyclone.psyGen.GlobalSum._children_valid_format, psyclone.psyGen.HaloExchange._children_valid_format, psyclone.psyGen.Kern._children_valid_format, psyclone.psyGen.InlinedKern._children_valid_format, psyclone.psyir.nodes.acc_clauses.ACCCopyClause._children_valid_format, psyclone.psyir.nodes.acc_clauses.ACCCopyInClause._children_valid_format, psyclone.psyir.nodes.acc_clauses.ACCCopyOutClause._children_valid_format, psyclone.psyir.nodes.array_member.ArrayMember._children_valid_format, psyclone.psyir.nodes.array_of_structures_member.ArrayOfStructuresMember._children_valid_format, psyclone.psyir.nodes.array_of_structures_reference.ArrayOfStructuresReference._children_valid_format, psyclone.psyir.nodes.array_reference.ArrayReference._children_valid_format, psyclone.psyir.nodes.assignment.Assignment._children_valid_format, psyclone.psyir.nodes.call.Call._children_valid_format, psyclone.psyir.nodes.clause.Clause._children_valid_format, psyclone.psyir.nodes.codeblock.CodeBlock._children_valid_format, psyclone.psyir.nodes.container.Container._children_valid_format, psyclone.psyir.nodes.directive.RegionDirective._children_valid_format, psyclone.psyir.nodes.directive.StandaloneDirective._children_valid_format, psyclone.psyir.nodes.dynamic_omp_task_directive.DynamicOMPTaskDirective._children_valid_format, psyclone.psyir.nodes.if_block.IfBlock._children_valid_format, psyclone.psyir.nodes.intrinsic_call.IntrinsicCall._children_valid_format, psyclone.psyir.nodes.literal.Literal._children_valid_format, psyclone.psyir.nodes.loop.Loop._children_valid_format, psyclone.psyir.nodes.member.Member._children_valid_format, psyclone.psyir.nodes.node.Node._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPNowaitClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPGrainsizeClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPNumTasksClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPNogroupClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPSharedClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPPrivateClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPFirstprivateClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPDefaultClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPScheduleClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPDependClause._children_valid_format, psyclone.psyir.nodes.omp_clauses.OMPReductionClause._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPSingleDirective._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPTaskloopDirective._children_valid_format, psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective._children_valid_format, psyclone.psyir.nodes.omp_task_directive.OMPTaskDirective._children_valid_format, psyclone.psyir.nodes.operation.UnaryOperation._children_valid_format, psyclone.psyir.nodes.operation.BinaryOperation._children_valid_format, psyclone.psyir.nodes.psy_data_node.PSyDataNode._children_valid_format, psyclone.psyir.nodes.ranges.Range._children_valid_format, psyclone.psyir.nodes.reference.Reference._children_valid_format, psyclone.psyir.nodes.return_stmt.Return._children_valid_format, psyclone.psyir.nodes.routine.Routine._children_valid_format, psyclone.psyir.nodes.schedule.Schedule._children_valid_format, psyclone.psyir.nodes.structure_member.StructureMember._children_valid_format, psyclone.psyir.nodes.structure_reference.StructureReference._children_valid_format, psyclone.psyir.nodes.while_loop.WhileLoop._children_valid_format, psyclone.psyir.nodes.node.Node._disable_tree_update, psyclone.psyir.nodes.node.Node._has_constructor_parent, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.GridArg._parent, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.FieldArg._parent, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.ScalarArg._parent, psyclone.domain.lfric.lfric_kern.LFRicKern._parent, psyclone.f2pygen.BaseGen._parent, psyclone.psyir.nodes.node.Node._parent, psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall._validate_child(), psyclone.domain.common.algorithm.psyir.KernelFunctor._validate_child(), psyclone.domain.lfric.algorithm.psyir.lfric_alg_invoke_call.LFRicAlgorithmInvokeCall._validate_child(), psyclone.psyGen.InlinedKern._validate_child(), psyclone.psyir.nodes.acc_clauses.ACCCopyClause._validate_child(), psyclone.psyir.nodes.acc_clauses.ACCCopyInClause._validate_child(), psyclone.psyir.nodes.acc_clauses.ACCCopyOutClause._validate_child(), psyclone.psyir.nodes.acc_directives.ACCDataDirective._validate_child(), psyclone.psyir.nodes.array_mixin.ArrayMixin._validate_child(), psyclone.psyir.nodes.array_of_structures_mixin.ArrayOfStructuresMixin._validate_child(), psyclone.psyir.nodes.assignment.Assignment._validate_child(), psyclone.psyir.nodes.call.Call._validate_child(), psyclone.psyir.nodes.container.Container._validate_child(), psyclone.psyir.nodes.directive.RegionDirective._validate_child(), psyclone.psyir.nodes.directive.StandaloneDirective._validate_child(), psyclone.psyir.nodes.if_block.IfBlock._validate_child(), psyclone.psyir.nodes.loop.Loop._validate_child(), psyclone.psyir.nodes.node.Node._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPGrainsizeClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPNumTasksClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPSharedClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPPrivateClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPFirstprivateClause._validate_child(), psyclone.psyir.nodes.omp_clauses.OMPDependClause._validate_child(), psyclone.psyir.nodes.omp_directives.OMPSingleDirective._validate_child(), psyclone.psyir.nodes.omp_directives.OMPParallelDirective._validate_child(), psyclone.psyir.nodes.omp_directives.OMPTaskloopDirective._validate_child(), psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective._validate_child(), psyclone.psyir.nodes.omp_task_directive.OMPTaskDirective._validate_child(), psyclone.psyir.nodes.operation.UnaryOperation._validate_child(), psyclone.psyir.nodes.operation.BinaryOperation._validate_child(), psyclone.psyir.nodes.psy_data_node.PSyDataNode._validate_child(), psyclone.psyir.nodes.ranges.Range._validate_child(), psyclone.psyir.nodes.schedule.Schedule._validate_child(), psyclone.psyir.nodes.structure_member.StructureMember._validate_child(), psyclone.psyir.nodes.structure_reference.StructureReference._validate_child(), psyclone.psyir.nodes.while_loop.WhileLoop._validate_child(), psyclone.f2pygen.BaseGen.children(), psyclone.psyGen.InlinedKern.children, psyclone.psyir.nodes.node.Node.children(), psyclone.f2pygen.BaseGen.parent(), psyclone.psyir.nodes.node.Node.parent(), psyclone.f2pygen.Directive.position(), and psyclone.psyir.nodes.node.Node.position.
def psyclone.psyir.nodes.node.Node.following | ( | self, | |
routine = True |
|||
) |
Return all :py:class:`psyclone.psyir.nodes.Node` nodes after this node. Ordering is depth first. If the `routine` argument is set to `True` then nodes are only returned if they are descendents of this node's closest ancestor routine if one exists. :param bool routine: an optional (default `True`) argument \ that only returns nodes that are within this node's \ closest ancestor Routine node if one exists. :returns: a list of nodes. :rtype: :func:`list` of :py:class:`psyclone.psyir.nodes.Node`
Definition at line 1275 of file node.py.
References psyclone.psyir.nodes.node.Node.ancestor(), psyclone.f2pygen.BaseGen.root(), psyclone.f2pygen.BaseDeclGen.root(), and psyclone.psyir.nodes.node.Node.root().
def psyclone.psyir.nodes.node.Node.forward_dependence | ( | self | ) |
Returns the closest following Node that this Node has a direct dependence with or None if there is not one. Only Nodes with the same parent as self are returned. Nodes inherit their descendants' dependencies. The reason for this is that for correctness a node must maintain its parent if it is moved. For example a halo exchange and a kernel call may have a dependence between them but it is the loop body containing the kernel call that the halo exchange must not move beyond i.e. the loop body inherits the dependencies of the routines within it.
Definition at line 727 of file node.py.
References psyclone.expression.FunctionVar.args, psyclone.f2pygen.SubroutineGen.args(), psyclone.parse.algorithm.ParsedCall.args(), psyclone.psyGen.GlobalSum.args(), psyclone.psyGen.HaloExchange.args(), psyclone.psyGen.Kern.args(), psyclone.psyGen.Arguments.args(), psyclone.psyir.nodes.node.Node.args(), psyclone.psyir.nodes.node.Node.depth(), psyclone.gocean1p0.GOStencil.depth(), and psyclone.psyir.nodes.node.Node.sameParent().
def psyclone.psyir.nodes.node.Node.get_sibling_lists | ( | self, | |
my_type, | |||
stop_type = None |
|||
) |
Recurse through the PSyIR tree and return lists of Nodes that are instances of 'my_type' and are immediate siblings. Here 'my_type' is either a single class or a tuple of classes. In the latter case all nodes are returned that are instances of any classes in the tuple. The recursion into the tree is stopped if an instance of 'stop_type' (which is either a single class or a tuple of classes) is found. :param my_type: the class(es) for which the instances are collected. :type my_type: type | Tuple[type, ...] :param stop_type: class(es) at which recursion is halted (optional). :type stop_type: Optional[type | Tuple[type, ...]] :returns: list of lists, each of which containing nodes that are instances of my_type and are immediate siblings, starting at and including this node. :rtype: List[List[:py:class:`psyclone.psyir.nodes.Node`]]
Definition at line 1116 of file node.py.
References psyclone.psyir.nodes.node.Node.walk().
def psyclone.psyir.nodes.node.Node.has_constructor_parent | ( | self | ) |
:returns: whether the constructor has predefined a parent connection but the parent's children list doesn't include this node yet. :rtype: bool
Definition at line 970 of file node.py.
References psyclone.psyir.nodes.node.Node._has_constructor_parent.
def psyclone.psyir.nodes.node.Node.immediately_follows | ( | self, | |
node_1 | |||
) |
:returns: True if this node immediately follows `node_1`, False otherwise :rtype: bool
Definition at line 1362 of file node.py.
References psyclone.f2pygen.Directive.position(), psyclone.psyir.nodes.node.Node.position, and psyclone.psyir.nodes.node.Node.sameParent().
def psyclone.psyir.nodes.node.Node.immediately_precedes | ( | self, | |
node_2 | |||
) |
:returns: True if this node immediately precedes `node_2`, False otherwise :rtype: bool
Definition at line 1350 of file node.py.
References psyclone.f2pygen.Directive.position(), psyclone.psyir.nodes.node.Node.position, and psyclone.psyir.nodes.node.Node.sameParent().
def psyclone.psyir.nodes.node.Node.is_openmp_parallel | ( | self | ) |
:returns: True if this Node is within an OpenMP parallel region, \ False otherwise. :rtype: bool
Definition at line 1429 of file node.py.
References psyclone.psyir.nodes.node.Node.ancestor().
def psyclone.psyir.nodes.node.Node.is_valid_location | ( | self, | |
new_node, | |||
position = "before" |
|||
) |
If this Node can be moved to the new_node (where position determines whether it is before of after the new_node) without breaking any data dependencies then return True, otherwise return False. :param new_node: Node to which this node should be moved. :type new_node: :py:class:`psyclone.psyir.nodes.Node` :param str position: either 'before' or 'after'. :raises GenerationError: if new_node is not an\ instance of :py:class:`psyclone.psyir.nodes.Node`. :raises GenerationError: if position is not 'before' or 'after'. :raises GenerationError: if self and new_node do not have the same\ parent. :raises GenerationError: self and new_node are the same Node. :returns: whether or not the specified location is valid for this node. :rtype: bool
Definition at line 763 of file node.py.
References psyclone.gocean1p0.GOKernelGridArgument.backward_dependence(), psyclone.psyGen.Argument.backward_dependence(), psyclone.psyir.nodes.node.Node.backward_dependence(), psyclone.gocean1p0.GOKernelGridArgument.forward_dependence(), psyclone.psyGen.Argument.forward_dependence(), psyclone.psyir.nodes.node.Node.forward_dependence(), psyclone.f2pygen.Directive.position(), psyclone.psyir.nodes.node.Node.position, and psyclone.psyir.nodes.node.Node.sameParent().
def psyclone.psyir.nodes.node.Node.kernels | ( | self | ) |
:returns: all kernels that are descendants of this node in the PSyIR. :rtype: List[:py:class:`psyclone.psyGen.Kern`]
Definition at line 1266 of file node.py.
References psyclone.psyir.nodes.node.Node.walk().
def psyclone.psyir.nodes.node.Node.loops | ( | self | ) |
:returns: all loops currently in this schedule. :rtype: List[:py:class:`psyclone.psyir.nodes.Loop`]
Definition at line 1387 of file node.py.
References psyclone.psyir.nodes.node.Node.walk().
def psyclone.psyir.nodes.node.Node.lower_to_language_level | ( | self | ) |
In-place replacement of high-level concepts into generic language PSyIR constructs. This generic implementation only recurses down to its children, but this method must be re-implemented by Nodes that represent high-level concepts. :returns: the lowered version of this node. :rtype: :py:class:`psyclone.psyir.node.Node`
Reimplemented in psyclone.psyir.nodes.read_only_verify_node.ReadOnlyVerifyNode, psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective, psyclone.psyir.nodes.omp_directives.OMPParallelDirective, psyclone.psyir.nodes.omp_directives.OMPSerialDirective, psyclone.psyir.nodes.nan_test_node.NanTestNode, psyclone.psyir.nodes.extract_node.ExtractNode, psyclone.psyir.nodes.dynamic_omp_task_directive.DynamicOMPTaskDirective, and psyclone.psyir.nodes.acc_directives.ACCEnterDataDirective.
Definition at line 1443 of file node.py.
References psyclone.f2pygen.BaseGen.children(), psyclone.psyGen.InlinedKern.children, and psyclone.psyir.nodes.node.Node.children().
def psyclone.psyir.nodes.node.Node.node_str | ( | self, | |
colour = True |
|||
) |
:param bool colour: whether or not to include control codes for \ coloured text. :returns: a text description of this node. Will typically be \ overridden by sub-class. :rtype: str
Reimplemented in psyclone.psyir.nodes.routine.Routine, psyclone.psyir.nodes.reference.Reference, psyclone.psyir.nodes.operation.Operation, psyclone.psyir.nodes.omp_directives.OMPLoopDirective, psyclone.psyir.nodes.omp_directives.OMPDoDirective, psyclone.psyir.nodes.omp_clauses.OMPDependClause, psyclone.psyir.nodes.omp_clauses.OMPScheduleClause, psyclone.psyir.nodes.omp_clauses.OMPDefaultClause, psyclone.psyir.nodes.member.Member, psyclone.psyir.nodes.loop.Loop, psyclone.psyir.nodes.literal.Literal, psyclone.psyir.nodes.file_container.FileContainer, psyclone.psyir.nodes.container.Container, psyclone.psyir.nodes.codeblock.CodeBlock, psyclone.psyir.nodes.call.Call, and psyclone.psyir.nodes.acc_directives.ACCLoopDirective.
Definition at line 483 of file node.py.
References psyclone.psyir.nodes.node.Node.annotations(), psyclone.psyir.nodes.node.Node.coloured_name(), psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall.node_str(), psyclone.domain.common.psylayer.psyloop.PSyLoop.node_str(), psyclone.domain.lfric.lfric_invoke_schedule.LFRicInvokeSchedule.node_str(), psyclone.domain.lfric.lfric_loop.LFRicLoop.node_str(), psyclone.dynamo0p3.LFRicHaloExchange.node_str(), psyclone.psyGen.InvokeSchedule.node_str(), psyclone.psyGen.GlobalSum.node_str(), psyclone.psyGen.HaloExchange.node_str(), psyclone.psyGen.Kern.node_str(), psyclone.psyGen.CodedKern.node_str(), psyclone.psyGen.InlinedKern.node_str(), psyclone.psyir.nodes.acc_directives.ACCLoopDirective.node_str(), psyclone.psyir.nodes.call.Call.node_str(), psyclone.psyir.nodes.codeblock.CodeBlock.node_str(), psyclone.psyir.nodes.container.Container.node_str(), psyclone.psyir.nodes.file_container.FileContainer.node_str(), psyclone.psyir.nodes.literal.Literal.node_str(), psyclone.psyir.nodes.loop.Loop.node_str(), psyclone.psyir.nodes.member.Member.node_str(), psyclone.psyir.nodes.node.Node.node_str(), psyclone.psyir.nodes.omp_clauses.OMPDefaultClause.node_str(), psyclone.psyir.nodes.omp_clauses.OMPScheduleClause.node_str(), psyclone.psyir.nodes.omp_clauses.OMPDependClause.node_str(), psyclone.psyir.nodes.omp_directives.OMPDoDirective.node_str(), psyclone.psyir.nodes.omp_directives.OMPLoopDirective.node_str(), psyclone.psyir.nodes.operation.Operation.node_str(), psyclone.psyir.nodes.reference.Reference.node_str(), and psyclone.psyir.nodes.routine.Routine.node_str().
def psyclone.psyir.nodes.node.Node.origin_string | ( | self | ) |
Generates a string with the available information about where this node has been created. It currently only works with Fortran Statements or subchildren of them. :returns: a string specifing the origin of this node. :rtype: str
Definition at line 1634 of file node.py.
References psyclone.psyir.nodes.node.Node.ancestor(), and psyclone.psyir.nodes.node.Node.coloured_name().
def psyclone.psyir.nodes.node.Node.parent | ( | self | ) |
:returns: the parent node. :rtype: :py:class:`psyclone.psyir.nodes.Node` or NoneType
Definition at line 953 of file node.py.
References psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.GridArg._parent, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.FieldArg._parent, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.ScalarArg._parent, psyclone.domain.lfric.lfric_kern.LFRicKern._parent, psyclone.f2pygen.BaseGen._parent, and psyclone.psyir.nodes.node.Node._parent.
def psyclone.psyir.nodes.node.Node.path_from | ( | self, | |
ancestor | |||
) |
Find the path in the psyir tree between ancestor and node and returns a list containing the path. The result of this method can be used to find the node from its ancestor for example by: >>> index_list = node.path_from(ancestor) >>> cursor = ancestor >>> for index in index_list: >>> cursor = cursor.children[index] >>> assert cursor is node :param ancestor: an ancestor node of self to find the path from. :type ancestor: :py:class:`psyclone.psyir.nodes.Node` :raises ValueError: if ancestor is not an ancestor of self. :returns: a list of child indices representing the path between ancestor and self. :rtype: List[int]
Definition at line 1700 of file node.py.
def psyclone.psyir.nodes.node.Node.pop_all_children | ( | self | ) |
Remove all children of this node and return them as a list. :returns: all the children of this node as orphan nodes. :rtype: list of :py:class:`psyclone.psyir.node.Node`
Definition at line 1542 of file node.py.
References psyclone.f2pygen.BaseGen.children(), psyclone.psyGen.InlinedKern.children, and psyclone.psyir.nodes.node.Node.children().
def psyclone.psyir.nodes.node.Node.position | ( | self | ) |
Find a Node's position relative to its parent Node (starting with 0 if it does not have a parent). :returns: relative position of a Node to its parent :rtype: int
Definition at line 979 of file node.py.
References psyclone.f2pygen.BaseGen.parent(), psyclone.psyir.nodes.node.Node.parent(), and psyclone.psyir.nodes.node.Node.START_POSITION.
def psyclone.psyir.nodes.node.Node.preceding | ( | self, | |
reverse = False , |
|||
routine = True |
|||
) |
Return all :py:class:`psyclone.psyir.nodes.Node` nodes before this node. Ordering is depth first. If the `reverse` argument is set to `True` then the node ordering is reversed i.e. returning the nodes closest to this node first. if the `routine` argument is set to `True` then nodes are only returned if they are descendents of this node's closest ancestor routine if one exists. :param bool reverse: an optional (default `False`) argument \ that reverses the order of any returned nodes (i.e. makes \ them 'closest first' if set to true. :param bool routine: an optional (default `True`) argument \ that only returns nodes that are within this node's \ closest ancestor Routine node if one exists. :returns: a list of nodes. :rtype: :func:`list` of :py:class:`psyclone.psyir.nodes.Node`
Definition at line 1309 of file node.py.
References psyclone.psyir.nodes.node.Node.ancestor(), psyclone.f2pygen.BaseGen.root(), psyclone.f2pygen.BaseDeclGen.root(), and psyclone.psyir.nodes.node.Node.root().
def psyclone.psyir.nodes.node.Node.reductions | ( | self, | |
reprod = None |
|||
) |
Return all kernels that have reductions and are decendents of this node. If reprod is not provided, all reductions are returned. If reprod is False, all builtin reductions that are not set to reproducible are returned. If reprod is True, all builtins that are set to reproducible are returned. :param reprod: if provided, filter reductions by whether or not they \ are set to be reproducible. :type reprod: Optional[bool] :returns: all kernels involving reductions that are descendants of \ this node. :rtype: List[:py:class:`psyclone.psyir.nodes.Kern`]
Definition at line 1396 of file node.py.
References psyclone.psyir.nodes.node.Node.walk().
def psyclone.psyir.nodes.node.Node.reference_accesses | ( | self, | |
var_accesses | |||
) |
Get all variable access information. The default implementation just recurses down to all children. :param var_accesses: Stores the output results. :type var_accesses: \ :py:class:`psyclone.core.VariablesAccessInfo`
Reimplemented in psyclone.psyir.nodes.while_loop.WhileLoop, psyclone.psyir.nodes.reference.Reference, psyclone.psyir.nodes.loop.Loop, psyclone.psyir.nodes.intrinsic_call.IntrinsicCall, psyclone.psyir.nodes.if_block.IfBlock, psyclone.psyir.nodes.call.Call, and psyclone.psyir.nodes.assignment.Assignment.
Definition at line 1461 of file node.py.
References psyclone.f2pygen.BaseGen._children, psyclone.psyir.nodes.node.Node._children, and psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children.
def psyclone.psyir.nodes.node.Node.replace_with | ( | self, | |
node, | |||
keep_name_in_context = True |
|||
) |
Removes self, and its descendants, from the PSyIR tree to which it is connected, and replaces it with the supplied node (and its descendants). :param node: the node that will replace self in the PSyIR \ tree. :type node: :py:class:`psyclone.psyir.nodes.node` :param bool keep_name_in_context: whether to conserve the name \ referencing this node. :raises TypeError: if the argument 'node' is not a Node. :raises TypeError: if the argument 'keep_name_in_context' is not bool. :raises GenerationError: if this node does not have a parent. :raises GenerationError: if the argument 'node' has a parent.
Definition at line 1495 of file node.py.
References psyclone.f2pygen.BaseGen.parent(), psyclone.psyir.nodes.node.Node.parent(), psyclone.f2pygen.Directive.position(), and psyclone.psyir.nodes.node.Node.position.
def psyclone.psyir.nodes.node.Node.root | ( | self | ) |
:returns: the root node of the PSyIR tree. :rtype: :py:class:`psyclone.psyir.nodes.Node`
Definition at line 1049 of file node.py.
References psyclone.f2pygen.BaseGen.parent(), and psyclone.psyir.nodes.node.Node.parent().
def psyclone.psyir.nodes.node.Node.sameParent | ( | self, | |
node_2 | |||
) |
:returns: True if `node_2` has the same parent as this node, False \ otherwise. :rtype: bool
Definition at line 1065 of file node.py.
References psyclone.f2pygen.BaseGen.parent(), and psyclone.psyir.nodes.node.Node.parent().
def psyclone.psyir.nodes.node.Node.scope | ( | self | ) |
Some nodes (e.g. Schedule and Container) allow symbols to be scoped via an attached symbol table. This property returns the closest ScopingNode node including self. :returns: the closest ancestor ScopingNode node. :rtype: :py:class:`psyclone.psyir.node.ScopingNode` :raises SymbolError: if there is no ScopingNode ancestor.
Definition at line 1473 of file node.py.
References psyclone.psyir.nodes.node.Node.ancestor().
def psyclone.psyir.nodes.node.Node.siblings | ( | self | ) |
:returns: list of sibling nodes, including self. :rtype: List[:py:class:`psyclone.psyir.nodes.Node`]
Definition at line 961 of file node.py.
References psyclone.f2pygen.BaseGen.parent(), and psyclone.psyir.nodes.node.Node.parent().
def psyclone.psyir.nodes.node.Node.update_signal | ( | self | ) |
Called whenever there is a change in the PSyIR tree below this node. It is responsible for ensuring that this method does not get called recursively and then calls the _update_node() method of the current node (which is the only part that subclasses should specialise). Finally, it propagates the update signal up to the parent node (if any).
Definition at line 1666 of file node.py.
References psyclone.psyir.nodes.node.Node._disable_tree_update, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.GridArg._parent, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.FieldArg._parent, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.ScalarArg._parent, psyclone.domain.lfric.lfric_kern.LFRicKern._parent, psyclone.f2pygen.BaseGen._parent, psyclone.psyir.nodes.node.Node._parent, psyclone.psyir.nodes.acc_directives.ACCDataDirective._update_node(), and psyclone.psyir.nodes.node.Node._update_node().
def psyclone.psyir.nodes.node.Node.validate_global_constraints | ( | self | ) |
Validates this Node in the context of the whole PSyIR tree. Although there are validation checks for the parent<->child relationships, there are other constraints that can only be checked once the tree is complete and all transformations have been applied. (One example is that an OMP Do directive must be within the scope of an OMP Parallel directive.) By default, this routine does nothing. It must be overridden appropriately in any sub-classes to which constraints apply. If an error is found then a GenerationError should be raised.
Reimplemented in psyclone.psyir.nodes.omp_task_directive.OMPTaskDirective, psyclone.psyir.nodes.omp_directives.OMPSimdDirective, psyclone.psyir.nodes.omp_directives.OMPAtomicDirective, psyclone.psyir.nodes.omp_directives.OMPLoopDirective, psyclone.psyir.nodes.omp_directives.OMPParallelDoDirective, psyclone.psyir.nodes.omp_directives.OMPDoDirective, psyclone.psyir.nodes.omp_directives.OMPTaskloopDirective, psyclone.psyir.nodes.omp_directives.OMPParallelDirective, psyclone.psyir.nodes.omp_directives.OMPSerialDirective, psyclone.psyir.nodes.omp_directives.OMPTaskwaitDirective, psyclone.psyir.nodes.omp_directives.OMPDeclareTargetDirective, psyclone.psyir.nodes.acc_directives.ACCAtomicDirective, psyclone.psyir.nodes.acc_directives.ACCLoopDirective, and psyclone.psyir.nodes.acc_directives.ACCRegionDirective.
Definition at line 1605 of file node.py.
def psyclone.psyir.nodes.node.Node.view | ( | self, | |
depth = 0 , |
|||
colour = True , |
|||
indent = " " , |
|||
_index = None |
|||
) |
Output a human readable description of the current node and all of its descendents as a string. :param int depth: depth of the tree hierarchy for output \ text. Defaults to 0. :param bool colour: whether to include colour coding in the \ output. Defaults to True. :param str indent: the indent to apply as the depth \ increases. Defaults to 4 spaces. :param int _index: the position of this node wrt its siblings \ or None. Defaults to None. :returns: a representation of this node and its descendents. :rtype: str :raises TypeError: if one of the arguments is the wrong type. :raises ValueError: if the depth argument is negative.
Definition at line 854 of file node.py.
References psyclone.f2pygen.BaseGen._children, psyclone.psyir.nodes.node.Node._children, psyclone.psyir.nodes.omp_directives.OMPParallelDirective._children, psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall.node_str(), psyclone.domain.common.psylayer.psyloop.PSyLoop.node_str(), psyclone.domain.lfric.lfric_invoke_schedule.LFRicInvokeSchedule.node_str(), psyclone.domain.lfric.lfric_loop.LFRicLoop.node_str(), psyclone.dynamo0p3.LFRicHaloExchange.node_str(), psyclone.psyGen.InvokeSchedule.node_str(), psyclone.psyGen.GlobalSum.node_str(), psyclone.psyGen.HaloExchange.node_str(), psyclone.psyGen.Kern.node_str(), psyclone.psyGen.CodedKern.node_str(), psyclone.psyGen.InlinedKern.node_str(), psyclone.psyir.nodes.acc_directives.ACCLoopDirective.node_str(), psyclone.psyir.nodes.call.Call.node_str(), psyclone.psyir.nodes.codeblock.CodeBlock.node_str(), psyclone.psyir.nodes.container.Container.node_str(), psyclone.psyir.nodes.file_container.FileContainer.node_str(), psyclone.psyir.nodes.literal.Literal.node_str(), psyclone.psyir.nodes.loop.Loop.node_str(), psyclone.psyir.nodes.member.Member.node_str(), psyclone.psyir.nodes.node.Node.node_str(), psyclone.psyir.nodes.omp_clauses.OMPDefaultClause.node_str(), psyclone.psyir.nodes.omp_clauses.OMPScheduleClause.node_str(), psyclone.psyir.nodes.omp_clauses.OMPDependClause.node_str(), psyclone.psyir.nodes.omp_directives.OMPDoDirective.node_str(), psyclone.psyir.nodes.omp_directives.OMPLoopDirective.node_str(), psyclone.psyir.nodes.operation.Operation.node_str(), psyclone.psyir.nodes.reference.Reference.node_str(), psyclone.psyir.nodes.routine.Routine.node_str(), psyclone.f2pygen.BaseGen.parent(), and psyclone.psyir.nodes.node.Node.parent().
def psyclone.psyir.nodes.node.Node.walk | ( | self, | |
my_type, | |||
stop_type = None , |
|||
depth = None |
|||
) |
Recurse through the PSyIR tree and return all objects that are an instance of 'my_type', which is either a single class or a tuple of classes. In the latter case all nodes are returned that are instances of any classes in the tuple. The recursion into the tree is stopped if an instance of 'stop_type' (which is either a single class or a tuple of classes) is found. This can be used to avoid analysing e.g. inlined kernels, or as performance optimisation to reduce the number of recursive calls. The recursion into the tree is also stopped if the (optional) 'depth' level is reached. :param my_type: the class(es) for which the instances are collected. :type my_type: type | Tuple[type, ...] :param stop_type: class(es) at which recursion is halted (optional). :type stop_type: Optional[type | Tuple[type, ...]] :param depth: the depth value the instances must have (optional). :type depth: Optional[int] :returns: list with all nodes that are instances of my_type \ starting at and including this node. :rtype: List[:py:class:`psyclone.psyir.nodes.Node`]
Definition at line 1075 of file node.py.
References psyclone.f2pygen.BaseGen.children(), psyclone.psyGen.InlinedKern.children, psyclone.psyir.nodes.node.Node.children(), psyclone.psyir.nodes.node.Node.depth(), and psyclone.gocean1p0.GOStencil.depth().