Reference Guide
2.5.0
|
Public Member Functions | |
def | __init__ (self, node_class=PSyDataNode) |
def | __str__ (self) |
def | name (self) |
def | get_default_options (self) |
def | merge_in_default_options (self, options) |
def | get_unique_region_name (self, nodes, options) |
def | validate (self, nodes, options=None) |
def | apply (self, nodes, options=None) |
Public Member Functions inherited from psyclone.psyir.transformations.region_trans.RegionTrans | |
def | get_node_list (self, nodes) |
Static Public Attributes | |
tuple | excluded_node_types = (Return,) |
Static Public Attributes inherited from psyclone.psyir.transformations.region_trans.RegionTrans | |
tuple | excluded_node_types = () |
Create a PSyData region around a list of statements. For example: >>> from psyclone.parse.algorithm import parse >>> from psyclone.parse.utils import ParseError >>> from psyclone.psyGen import PSyFactory >>> api = "gocean1.0" >>> ast, invoke_info = parse(SOURCE_FILE, api=api) >>> psy = PSyFactory(api).create(invoke_info) >>> >>> from psyclone.psyir.transformations import PSyDataTrans >>> data_trans = PSyDataTrans() >>> >>> schedule = psy.invokes.get('invoke_0').schedule >>> # Uncomment the following line to see a text view of the schedule >>> # print(schedule.view()) >>> >>> # Enclose all children within a single PSyData region >>> data_trans.apply(schedule.children) >>> # Uncomment the following line to see a text view of the schedule >>> # print(schedule.view()) >>> # Or to use custom region name: >>> data_trans.apply(schedule.children, ... {"region_name": ("module","region")}) :param node_class: The Node class of which an instance will be inserted \ into the tree (defaults to PSyDataNode). :type node_class: :py:class:`psyclone.psyir.nodes.ExtractNode`
Definition at line 50 of file psy_data_trans.py.
def psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.apply | ( | self, | |
nodes, | |||
options = None |
|||
) |
Apply this transformation to a subset of the nodes within a schedule - i.e. enclose the specified Nodes in the schedule within a single PSyData region. :param nodes: can be a single node or a list of nodes. :type nodes: :py:obj:`psyclone.psyir.nodes.Node` or list of \ :py:obj:`psyclone.psyir.nodes.Node` :param options: a dictionary with options for transformations. :type options: Optional[Dict[str, Any]] :param str options["prefix"]: 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 "". :param (str,str) options["region_name"]: an optional name to \ use for this PSyData area, provided as a 2-tuple containing a \ location name followed by a local name. The pair of strings \ should uniquely identify a region unless aggregate information \ is required (and is supported by the runtime library).
Reimplemented from psyclone.psyGen.Transformation.
Definition at line 301 of file psy_data_trans.py.
References psyclone.psyir.transformations.psy_data_trans.PSyDataTrans._node_class, psyclone.psyir.transformations.region_trans.RegionTrans.get_node_list(), psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.merge_in_default_options(), psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata.validate(), psyclone.transformations.MoveTrans.validate(), psyclone.transformations.Dynamo0p3AsyncHaloExchangeTrans.validate(), psyclone.domain.common.transformations.alg_invoke_2_psy_call_trans.AlgInvoke2PSyCallTrans.validate(), psyclone.domain.common.transformations.alg_trans.AlgTrans.validate(), psyclone.domain.common.transformations.kernel_module_inline_trans.KernelModuleInlineTrans.validate(), psyclone.domain.common.transformations.raise_psyir_2_alg_trans.RaisePSyIR2AlgTrans.validate(), psyclone.domain.gocean.transformations.gocean_const_loop_bounds_trans.GOConstLoopBoundsTrans.validate(), psyclone.domain.gocean.transformations.gocean_move_iteration_boundaries_inside_kernel_trans.GOMoveIterationBoundariesInsideKernelTrans.validate(), psyclone.domain.gocean.transformations.gocean_opencl_trans.GOOpenCLTrans.validate(), psyclone.domain.gocean.transformations.raise_psyir_2_gocean_kern_trans.RaisePSyIR2GOceanKernTrans.validate(), psyclone.domain.lfric.transformations.lfric_alg_invoke_2_psy_call_trans.LFRicAlgInvoke2PSyCallTrans.validate(), psyclone.domain.lfric.transformations.raise_psyir_2_lfric_kern_trans.RaisePSyIR2LFRicKernTrans.validate(), psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans.validate(), psyclone.domain.nemo.transformations.create_nemo_psy_trans.CreateNemoPSyTrans.validate(), psyclone.domain.nemo.transformations.nemo_allarrayrange2loop_trans.NemoAllArrayRange2LoopTrans.validate(), psyclone.domain.nemo.transformations.nemo_arrayrange2loop_trans.NemoArrayRange2LoopTrans.validate(), psyclone.domain.nemo.transformations.nemo_outerarrayrange2loop_trans.NemoOuterArrayRange2LoopTrans.validate(), psyclone.psyad.transformations.assignment_trans.AssignmentTrans.validate(), psyclone.psyGen.Transformation.validate(), psyclone.psyir.transformations.acc_update_trans.ACCUpdateTrans.validate(), psyclone.psyir.transformations.allarrayaccess2loop_trans.AllArrayAccess2LoopTrans.validate(), psyclone.psyir.transformations.arrayaccess2loop_trans.ArrayAccess2LoopTrans.validate(), psyclone.psyir.transformations.arrayrange2loop_trans.ArrayRange2LoopTrans.validate(), psyclone.psyir.transformations.chunk_loop_trans.ChunkLoopTrans.validate(), psyclone.psyir.transformations.fold_conditional_return_expressions_trans.FoldConditionalReturnExpressionsTrans.validate(), psyclone.psyir.transformations.hoist_local_arrays_trans.HoistLocalArraysTrans.validate(), psyclone.psyir.transformations.hoist_loop_bound_expr_trans.HoistLoopBoundExprTrans.validate(), psyclone.psyir.transformations.hoist_trans.HoistTrans.validate(), psyclone.psyir.transformations.inline_trans.InlineTrans.validate(), psyclone.psyir.transformations.intrinsics.array_reduction_base_trans.ArrayReductionBaseTrans.validate(), psyclone.psyir.transformations.intrinsics.dotproduct2code_trans.DotProduct2CodeTrans.validate(), psyclone.psyir.transformations.intrinsics.intrinsic2code_trans.Intrinsic2CodeTrans.validate(), psyclone.psyir.transformations.intrinsics.matmul2code_trans.Matmul2CodeTrans.validate(), psyclone.psyir.transformations.loop_swap_trans.LoopSwapTrans.validate(), psyclone.psyir.transformations.loop_tiling_2d_trans.LoopTiling2DTrans.validate(), psyclone.psyir.transformations.loop_trans.LoopTrans.validate(), psyclone.psyir.transformations.omp_task_trans.OMPTaskTrans.validate(), psyclone.psyir.transformations.omp_taskwait_trans.OMPTaskwaitTrans.validate(), psyclone.psyir.transformations.parallel_loop_trans.ParallelLoopTrans.validate(), psyclone.psyir.transformations.reference2arrayrange_trans.Reference2ArrayRangeTrans.validate(), psyclone.psyir.transformations.replace_induction_variables_trans.ReplaceInductionVariablesTrans.validate(), psyclone.transformations.OMPDeclareTargetTrans.validate(), psyclone.transformations.DynamoOMPParallelLoopTrans.validate(), psyclone.transformations.Dynamo0p3OMPLoopTrans.validate(), psyclone.transformations.GOceanOMPLoopTrans.validate(), psyclone.transformations.Dynamo0p3RedundantComputationTrans.validate(), psyclone.transformations.Dynamo0p3KernelConstTrans.validate(), psyclone.transformations.ACCRoutineTrans.validate(), psyclone.transformations.KernelImportsToArguments.validate(), psyclone.domain.gocean.transformations.gocean_loop_fuse_trans.GOceanLoopFuseTrans.validate(), psyclone.domain.lfric.transformations.lfric_loop_fuse_trans.LFRicLoopFuseTrans.validate(), psyclone.psyir.transformations.loop_fuse_trans.LoopFuseTrans.validate(), psyclone.domain.gocean.transformations.gocean_extract_trans.GOceanExtractTrans.validate(), psyclone.domain.lfric.transformations.lfric_extract_trans.LFRicExtractTrans.validate(), psyclone.psyir.transformations.extract_trans.ExtractTrans.validate(), psyclone.psyir.transformations.nan_test_trans.NanTestTrans.validate(), psyclone.psyir.transformations.read_only_verify_trans.ReadOnlyVerifyTrans.validate(), psyclone.transformations.ParallelRegionTrans.validate(), psyclone.transformations.OMPParallelTrans.validate(), psyclone.transformations.ACCParallelTrans.validate(), psyclone.transformations.ACCKernelsTrans.validate(), psyclone.transformations.ACCDataTrans.validate(), psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.validate(), psyclone.psyir.transformations.region_trans.RegionTrans.validate(), and psyclone.transformations.ACCEnterDataTrans.validate().
def psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.get_default_options | ( | self | ) |
Returns a new dictionary with additional options, specific to the transformation, that will be added to the user option. Any values specified by the user will take precedence. :returns: a dictionary with additional options. :rtype: Dict[str, Any]
Reimplemented in psyclone.psyir.transformations.read_only_verify_trans.ReadOnlyVerifyTrans, and psyclone.psyir.transformations.extract_trans.ExtractTrans.
Definition at line 115 of file psy_data_trans.py.
def psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.get_unique_region_name | ( | self, | |
nodes, | |||
options | |||
) |
This function returns the region and module name. If they are specified in the user options, these names will just be returned (it is then up to the user to guarantee uniqueness). Otherwise a name based on the module and invoke will be created using indices to make sure the name is unique. :param nodes: a list of nodes. :type nodes: list of :py:obj:`psyclone.psyir.nodes.Node` :param options: a dictionary with options for transformations. :type options: Dict[str, Any] :param (str,str) options["region_name"]: an optional name to \ use for this PSyData area, provided as a 2-tuple containing a \ location name followed by a local name. The pair of strings \ should uniquely identify a region unless aggregate information \ is required (and is supported by the runtime library).
Definition at line 148 of file psy_data_trans.py.
def psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.merge_in_default_options | ( | self, | |
options | |||
) |
This function returns a new dictionary which contains the default options for this transformation plus al user-specified options. Any user-specified option will take precedence over the default values. :param options: a dictionary with options for transformations. :type options: Dict[str, Any] :returns: a new dictionary which merges the default options with \ the user-specified options. :rtype: Dict[str:Any]
Definition at line 127 of file psy_data_trans.py.
References psyclone.psyir.transformations.extract_trans.ExtractTrans.get_default_options(), psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.get_default_options(), and psyclone.psyir.transformations.read_only_verify_trans.ReadOnlyVerifyTrans.get_default_options().
def psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.name | ( | self | ) |
This function returns the name of the transformation. It uses the Python 2/3 compatible way of returning the class name as a string, which means that the same function can be used for all derived classes. :returns: the name of this transformation as a string. :rtype: str
Reimplemented from psyclone.psyGen.Transformation.
Definition at line 102 of file psy_data_trans.py.
References psyclone.psyir.symbols.symbol.Symbol.__class__.
def psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.validate | ( | self, | |
nodes, | |||
options = None |
|||
) |
Checks that the supplied list of nodes is valid, that the location for this node is valid (not between a loop-directive and its loop), that there aren't any name clashes with symbols that must be imported from the appropriate PSyData library and finally, calls the validate method of the base class. :param nodes: a node or list of nodes to be instrumented with \ PSyData API calls. :type nodes: (list of) :py:class:`psyclone.psyir.nodes.Loop` :param options: a dictionary with options for transformations. :type options: Optional[Dict[str, Any]] :param str options["prefix"]: 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 "". :param (str,str) options["region_name"]: an optional name to \ use for this PSyData area, provided as a 2-tuple containing a \ location name followed by a local name. The pair of strings \ should uniquely identify a region unless aggregate information \ is required (and is supported by the runtime library). :raises TransformationError: if the supplied list of nodes is empty. :raises TransformationError: if the PSyData node is inserted \ between an OpenMP/ACC directive and the loop(s) to which it \ applies. :raises TransformationError: if the 'prefix' or 'region_name' options \ are not valid. :raises TransformationError: if there will be a name clash between \ any existing symbols and those that must be imported from the \ appropriate PSyData library.
Reimplemented from psyclone.psyir.transformations.region_trans.RegionTrans.
Reimplemented in psyclone.psyir.transformations.read_only_verify_trans.ReadOnlyVerifyTrans, and psyclone.psyir.transformations.extract_trans.ExtractTrans.
Definition at line 204 of file psy_data_trans.py.
References psyclone.psyir.transformations.psy_data_trans.PSyDataTrans._node_class, psyclone.psyir.transformations.region_trans.RegionTrans.get_node_list(), and psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.merge_in_default_options().