Reference Guide
2.5.0
|
Public Member Functions | |
def | apply (self, node, options=None) |
def | validate (self, node, options=None) |
Public Member Functions inherited from psyclone.psyGen.Transformation | |
def | name (self) |
This transformation takes a Call (which may have a return value) and replaces it with the body of the target routine. It is used as follows: >>> from psyclone.psyir.backend.fortran import FortranWriter >>> from psyclone.psyir.frontend.fortran import FortranReader >>> from psyclone.psyir.nodes import Call, Routine >>> from psyclone.psyir.transformations import InlineTrans >>> code = """ ... module test_mod ... contains ... subroutine run_it() ... integer :: i ... real :: a(10) ... do i=1,10 ... a(i) = 1.0 ... call sub(a(i)) ... end do ... end subroutine run_it ... subroutine sub(x) ... real, intent(inout) :: x ... x = 2.0*x ... end subroutine sub ... end module test_mod""" >>> psyir = FortranReader().psyir_from_source(code) >>> call = psyir.walk(Call)[0] >>> inline_trans = InlineTrans() >>> inline_trans.apply(call) >>> # Uncomment the following line to see a text view of the schedule >>> # print(psyir.walk(Routine)[0].view()) >>> print(FortranWriter()(psyir.walk(Routine)[0])) subroutine run_it() integer :: i real, dimension(10) :: a <BLANKLINE> do i = 1, 10, 1 a(i) = 1.0 a(i) = 2.0 * a(i) enddo <BLANKLINE> end subroutine run_it <BLANKLINE> .. warning:: Routines/calls with any of the following characteristics are not supported and will result in a TransformationError: * the routine is not in the same file as the call; * the routine contains an early Return statement; * the routine contains a variable with UnknownInterface; * the routine contains a variable with StaticInterface; * the routine contains an UnsupportedType variable with ArgumentInterface; * the routine has a named argument; * the shape of any array arguments as declared inside the routine does not match the shape of the arrays being passed as arguments; * the routine accesses an un-resolved symbol; * the routine accesses a symbol declared in the Container to which it belongs. Some of these restrictions will be lifted by #924.
Definition at line 60 of file inline_trans.py.
def psyclone.psyir.transformations.inline_trans.InlineTrans.apply | ( | self, | |
node, | |||
options = None |
|||
) |
Takes the body of the routine that is the target of the supplied call and replaces the call with it. :param node: target PSyIR node. :type node: :py:class:`psyclone.psyir.nodes.Routine` :param options: a dictionary with options for transformations. :type options: Optional[Dict[str, Any]]
Reimplemented from psyclone.psyGen.Transformation.
Definition at line 125 of file inline_trans.py.
References psyclone.psyir.transformations.inline_trans.InlineTrans._create_inlined_idx(), psyclone.psyir.transformations.inline_trans.InlineTrans._find_routine(), psyclone.psyir.transformations.inline_trans.InlineTrans._replace_formal_arg(), psyclone.psyir.transformations.inline_trans.InlineTrans._replace_formal_struc_arg(), psyclone.psyir.transformations.inline_trans.InlineTrans._symbols_to_skip(), psyclone.psyir.transformations.inline_trans.InlineTrans._update_actual_indices(), 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.inline_trans.InlineTrans.validate | ( | self, | |
node, | |||
options = None |
|||
) |
Checks that the supplied node is a valid target for inlining. :param node: target PSyIR node. :type node: subclass of :py:class:`psyclone.psyir.nodes.Call` :param options: a dictionary with options for transformations. :type options: Optional[Dict[str, Any]] :raises TransformationError: if the supplied node is not a Call or is \ an IntrinsicCall. :raises TransformationError: if the routine has a return value. :raises TransformationError: if the routine body contains a Return \ that is not the first or last statement. :raises TransformationError: if the routine body contains a CodeBlock. :raises TransformationError: if the called routine has a named \ argument. :raises TransformationError: if any of the variables declared within \ the called routine are of UnknownInterface. :raises TransformationError: if any of the variables declared within \ the called routine have a StaticInterface. :raises TransformationError: if any of the subroutine arguments is of \ UnsupportedType. :raises TransformationError: if a symbol of a given name is imported \ from different containers at the call site and within the routine. :raises TransformationError: if the routine accesses an un-resolved \ symbol. :raises TransformationError: if the number of arguments in the call \ does not match the number of formal arguments of the routine. :raises TransformationError: if a symbol declared in the parent \ container is accessed in the target routine. :raises TransformationError: if the shape of an array formal argument \ does not match that of the corresponding actual argument.
Reimplemented from psyclone.psyGen.Transformation.
Definition at line 604 of file inline_trans.py.
References psyclone.psyir.transformations.inline_trans.InlineTrans._find_routine(), and psyclone.psyir.transformations.inline_trans.InlineTrans._symbols_to_skip().