psyclone.psyir.nodes.extract_node

This module provides support for extraction of code within a specified invoke. The extracted code may be a single kernel, multiple occurrences of a kernel in an invoke, nodes in an invoke or the entire invoke (extraction applied to all Nodes).

There is currently only one class in this module: ExtractNode (see below).

Another class which contains helper functions for code extraction, such as wrapping up settings for generating driver for the extracted code, will be added in Issue #298.

Classes

  • ExtractNode: This class can be inserted into a Schedule to mark Nodes for code extraction using the ExtractRegionTrans transformation. By applying the transformation the Nodes marked for extraction become children of (the Schedule of) an ExtractNode.

class psyclone.psyir.nodes.extract_node.ExtractNode(ast=None, children=None, parent=None, options=None)

This class can be inserted into a Schedule to mark Nodes for code extraction using the ExtractRegionTrans transformation. By applying the transformation the Nodes marked for extraction become children of (the Schedule of) an ExtractNode.

Parameters:
  • ast (sub-class of fparser.two.Fortran2003.Base) – reference into the fparser2 parse tree corresponding to this node.

  • children (list of psyclone.psyir.nodes.Node) – the PSyIR nodes that are children of this node.

  • parent (psyclone.psyir.nodes.Node) – the parent of this node in the PSyIR tree.

  • options (Optional[Dict[str, Any]]) – a dictionary with options provided via transformations.

  • options["prefix"] (str) – a prefix to use for the PSyData module name (prefix_psy_data_mod) and the PSyDataType (prefix_PSyDataType) - a “_” will be added automatically. It defaults to “extract”, which means the module name used will be extract_psy_data_mode, and the data type extract_PSyDataType.

  • options["post_var_postfix"] (str) – a postfix to be used when creating names to store values of output variable. A variable ‘a’ would store its value as ‘a’, and its output values as ‘a_post’ with the default post_var_postfix of ‘_post’.

Inheritance

Inheritance diagram of ExtractNode
property extract_body
Returns:

the Schedule associated with this ExtractNode.

Return type:

psyclone.psyir.nodes.Schedule

gen_code(parent)

Generates the code required for extraction of one or more Nodes. It uses the PSyData API (via the base class PSyDataNode) to create the required callbacks that will allow a library to write the kernel data to a file.

Parameters:

parent (psyclone.psyir.nodes.Node.) – the parent of this Node in the PSyIR.

lower_to_language_level()

Lowers this node (and all children) to language-level PSyIR. The PSyIR tree is modified in-place.

Returns:

the lowered version of this node.

Return type:

psyclone.psyir.node.Node

property post_name
Returns:

the _post_name member of this ExtractNode.

Return type:

str