loki.transformations.dependency module
- class DuplicateKernel(duplicate_kernels=None, duplicate_suffix='duplicated', duplicate_module_suffix=None, duplicate_subgraph=False)
Bases:
TransformationDuplicate subroutines which includes the creation of new :any:`Item`s as well as the addition of the corresponding new dependencies.
Therefore, this transformation creates a new item and also implements the relevant routines for dry-run pipeline planning runs.
- Parameters:
duplicate_kernels (str|tuple|list, optional) – Kernel name(s) to be duplicated.
duplicate_suffix (str, optional) – Suffix to be used to append the original kernel name(s).
duplicate_module_suffix (str, optional) – Suffix to be used to append the original module name(s), if defined, otherwise duplicate_suffix
duplicate_subgraph (bool, optional) – Whether or not duplicate the subgraph beneath the kernel(s) that are duplicated.
- creates_items = True
- reverse_traversal = True
- transform_subroutine(routine, **kwargs)
Defines the transformation to apply to
Subroutineitems.For transformations that modify
Subroutineobjects, this method should be implemented. It gets called via the dispatch methodapply().- Parameters:
routine (
Subroutine) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.
- plan_subroutine(routine, **kwargs)
Define the planning steps to apply for
Subroutineitems.For transformations that modify the dependencies of
routine(e.g., adding new procedure calls, inlining calls, renaming the interface) this should be implemented. It gets called via the dispatch methodapply()if the optionalplan_modeargument is set to True.- Parameters:
routine (
Subroutine) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.
- class RemoveKernel(remove_kernels=None)
Bases:
TransformationRemove subroutines which includes the removal of the relevant :any:`Item`s as well as the removal of the corresponding dependencies.
Therefore, this transformation creates a new item and also implements the relevant routines for dry-run pipeline planning runs.
- Parameters:
remove_kernels (str|tuple|list, optional) – Kernel name(s) to be removed.
- creates_items = True
- transform_subroutine(routine, **kwargs)
Defines the transformation to apply to
Subroutineitems.For transformations that modify
Subroutineobjects, this method should be implemented. It gets called via the dispatch methodapply().- Parameters:
routine (
Subroutine) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.
- plan_subroutine(routine, **kwargs)
Define the planning steps to apply for
Subroutineitems.For transformations that modify the dependencies of
routine(e.g., adding new procedure calls, inlining calls, renaming the interface) this should be implemented. It gets called via the dispatch methodapply()if the optionalplan_modeargument is set to True.- Parameters:
routine (
Subroutine) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.
- class SeparateModesKernel(rename_suffix='_loki_{mode}')
Bases:
TransformationDuplicate subroutines which includes the creation of new :any:`Item`s as well as the addition of the corresponding new dependencies.
Therefore, this transformation creates a new item and also implements the relevant routines for dry-run pipeline planning runs.
Parameters:
- rename_suffixstr, optional
Suffix to be used to append the original kernel name(s) and module name(s). Must be a valid format string that accepts a
modekeyword argument, which is used to generate the suffix for the new item names.
- creates_items = True
- renames_items = True
- reverse_traversal = True
- rename_interfaces(item, mapping)
Update
Interfacenames to actively transformed procedures.- Parameters:
item (
Item) – The item for which to rename interfaces.mapping (dict) – A mapping from old dependency item names to new dependency items.
- rename_imports(item, mapping)
Update
Importstatements to actively transformed procedures and modules.Updates imports of C-style headers and Fortran modules to match the new mode-specific names.
- Parameters:
item (
Item) – The item for which to rename imports.mapping (dict) – A mapping from old dependency item names to new dependency items.
- rename_calls(item, mapping)
Update
CallStatementandInlineCallto actively transformed procedures- Parameters:
item (
Item) – The item for which to rename calls.mapping (dict) – A mapping from old dependency item names to new dependency items.
- transform_subroutine(routine, **kwargs)
Transform the given subroutine by creating new items for the different modes and updating the dependencies accordingly.
- plan_subroutine(routine, **kwargs)
Transform the given subroutine by creating new items for the different modes and registering the new dependencies in the item’s plan_data accordingly.