loki.transformations.build_system.dependency
Classes
|
Basic |
- class DependencyTransformation(suffix, module_suffix=None, include_path=None, replace_ignore_items=True, remove_inactive_items=True)
Bases:
TransformationBasic
Transformationclass that facilitates dependency injection for transformedModuleandSubroutineinto complex source treesThis transformation appends a provided
suffixargument to transformed subroutine and module objects and changes the target names ofImportandCallStatementnodes on the call-site accordingly.For subroutines declared via an interface block, these interfaces are updated accordingly. For subroutines that are not wrapped in a module, an updated interface block is also written as a header file to
include_path. Where interface blocks to renamed subroutines are included via C-style imports, the import name is updated accordingly.To ensure that every subroutine is wrapped in a module, the accompanying
ModuleWrapTransformationshould be applied first. This restores the behaviour of themodulemode in an earlier version of this transformation.When applying the transformation to a source object, one of two “roles” can be specified via the
rolekeyword:'driver': Only renames imports and calls to kernel routines'kernel': Renames routine or enclosing modules, as well as renaming any further imports and calls.
Note that
routine.apply(transformation, role='driver')entails that theroutinestill mimicks its original counterpart and can therefore be used as a drop-in replacement during compilation that then diverts the dependency tree to the modified sub-tree.- Parameters:
suffix (str) – The suffix to apply during renaming
module_suffix (str) – Special suffix to signal module names like _MOD
path (include) – Directory for generating additional header files
replace_ignore_items (bool) – Debug flag to toggle the replacement of calls to subroutines in the
ignore. Default isTrue.remove_inactive_items (bool) – Debug flag to toggle the removal of items (modules, subroutines) in the sourcefile that are not part of the scheduler graph. Default is
True.
- reverse_traversal = True
- traverse_file_graph = True
- recurse_to_modules = True
- recurse_to_procedures = True
- recurse_to_internal_procedures = False
- renames_items = True
- creates_items = True
- transform_file(sourcefile, **kwargs)
Remove non-active scope nodes if
remove_inactive_itemsis true
- transform_module(module, **kwargs)
Rename kernel modules and re-point module-level imports.
- transform_subroutine(routine, **kwargs)
Rename kernel subroutine and all imports and calls to target routines
For subroutines that are not wrapped in a module, re-generate the interface block.
- remove_inactive_ir_nodes(body, transformed_scope_name, **kwargs)
Utility to filter
Scopenodes inbodyto include only those given inkwargs['items'].
- derive_module_name(modname)
Utility to derive a new module name from
suffixandmodule_suffix- Parameters:
modname (str) – Current module name
- rename_calls(routine, targets=None, item=None)
Update
CallStatementandInlineCallto actively transformed procedures
- rename_imports(source, imports, targets=None)
Update imports of actively transformed subroutines.
- Parameters:
source (
ProgramUnit) – The IR object to transformimports (list of
Import) – The list of imports to update. This includes both, C-style header includes and Fortran import statements (USEandIMPORT)targets (list of str) – Optional list of subroutine names for which to modify imports
- rename_interfaces(intfs, targets=None)
Update explicit interfaces to actively transformed subroutines.
- generate_interfaces(routine)
Generate external header file with interface block for this subroutine.