gt4py.cartesian.backend package¶
Subpackages¶
Submodules¶
gt4py.cartesian.backend.base module¶
- class gt4py.cartesian.backend.base.Backend(builder: StencilBuilder)[source]¶
Bases:
ABC- _abc_impl = <_abc._abc_data object>¶
- builder: StencilBuilder¶
- property extra_cache_info: dict[str, Any]¶
Provide additional data to be stored in cache info file (subclass hook).
- property extra_cache_validation_keys: list[str]¶
List keys from extra_cache_info to be validated during consistency check.
- classmethod filter_options_for_id(options: BuildOptions) BuildOptions[source]¶
Filter a copy for options that should not be part of the stencil ID.
- abstractmethod generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- languages: ClassVar[dict[str, Any] | None] = None¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- abstractmethod load() type[StencilObject] | None[source]¶
Load the stencil class from the generated python module.
- type:
The generated stencil class after loading through python’s import API
This assumes that
Backend.generate()has been called already on the same stencil. The python module therefore already exists and any python extensions have been compiled. In case the stencil changed since the last generate call, it will not be rebuilt.
- options: ClassVar[dict[str, Any]]¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[gt_storage.layout.LayoutInfo]¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.base.BaseBackend(builder: StencilBuilder)[source]¶
Bases:
Backend- MODULE_GENERATOR_CLASS: ClassVar[type[BaseModuleGenerator]]¶
- _abc_impl = <_abc._abc_data object>¶
- _load() type[StencilObject][source]¶
- check_options(options: BuildOptions) None[source]¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- load() type[StencilObject] | None[source]¶
Load the stencil class from the generated python module.
- type:
The generated stencil class after loading through python’s import API
This assumes that
Backend.generate()has been called already on the same stencil. The python module therefore already exists and any python extensions have been compiled. In case the stencil changed since the last generate call, it will not be rebuilt.
- make_module() type[StencilObject][source]¶
- make_module_source(*, args_data: ModuleData | None = None) str[source]¶
Generate the module source code with or without stencil id.
- class gt4py.cartesian.backend.base.BasePyExtBackend(builder: StencilBuilder)[source]¶
Bases:
BaseBackend- _abc_impl = <_abc._abc_data object>¶
- build_extension_module(pyext_sources: dict[str, Any], pyext_build_opts: dict[str, str], *, uses_cuda: bool = False) None[source]¶
- property extra_cache_info: dict[str, Any]¶
Provide additional data to be stored in cache info file (subclass hook).
- property extra_cache_validation_keys: list[str]¶
List keys from extra_cache_info to be validated during consistency check.
- abstractmethod generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
gt4py.cartesian.backend.dace_backend module¶
- class gt4py.cartesian.backend.dace_backend.BaseDaceBackend(builder: StencilBuilder)[source]¶
Bases:
BaseGTBackend- GT_BACKEND_T = 'dace'¶
- PYEXT_GENERATOR_CLASS¶
alias of
DaCeExtGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- class gt4py.cartesian.backend.dace_backend.DaCeBindingsCodegen(backend: BaseDaceBackend)[source]¶
Bases:
object- classmethod apply(sdfg: SDFG, module_name: str, *, backend: BaseDaceBackend) str[source]¶
- generate_entry_params(sdfg: SDFG) list[tuple[str, str]][source]¶
Return the
(C++ type, name)pairs of therun_computationparameters.
- mako_template = <gt4py.eve.codegen.MakoTemplate object>¶
- class gt4py.cartesian.backend.dace_backend.DaCeCUDAPyExtModuleGenerator(builder: StencilBuilder)[source]¶
Bases:
DaCePyExtModuleGenerator,CUDAPyExtModuleGenerator- _abc_impl = <_abc._abc_data object>¶
- class gt4py.cartesian.backend.dace_backend.DaCeComputationCodegen[source]¶
Bases:
object- classmethod apply(builder: StencilBuilder, sdfg: SDFG) str[source]¶
- template = <gt4py.eve.codegen.MakoTemplate object>¶
- class gt4py.cartesian.backend.dace_backend.DaCeExtGenerator(class_name: str, module_name: str, backend: BaseDaceBackend)[source]¶
Bases:
BackendCodegen
- class gt4py.cartesian.backend.dace_backend.DaCePyExtModuleGenerator(builder: StencilBuilder)[source]¶
Bases:
PyExtModuleGenerator- _abc_impl = <_abc._abc_data object>¶
- class gt4py.cartesian.backend.dace_backend.DaceCPUBackend(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackend- MODULE_GENERATOR_CLASS¶
alias of
DaCePyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:cpu'¶
Backend name
- options = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.dace_backend.DaceCPUKFirstBackend(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackend- MODULE_GENERATOR_CLASS¶
alias of
DaCePyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:cpu_kfirst'¶
Backend name
- options = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.dace_backend.DaceCPU_KJI(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackend- MODULE_GENERATOR_CLASS¶
alias of
DaCePyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:cpu_KJI'¶
Backend name
- options = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.dace_backend.DaceGPUBackend(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackendGPU DaCe python with an optimal KJI loop layout
- MODULE_GENERATOR_CLASS¶
alias of
DaCeCUDAPyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'cuda'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:gpu'¶
Backend name
- options: ClassVar[GTBackendOptions] = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'device_sync': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'gpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.dace_backend.DaceGPUBackendIJK(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackendGPU DaCe python with an optimal IJK loop layout
- MODULE_GENERATOR_CLASS¶
alias of
DaCeCUDAPyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'cuda'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:gpu_IJK'¶
Backend name
- options: ClassVar[GTBackendOptions] = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'device_sync': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'gpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.dace_backend.SDFGManager(builder: StencilBuilder, debug_stree: bool = False)[source]¶
Bases:
object- schedule_tree() ScheduleTreeRoot[source]¶
Schedule tree representation of the gtir (taken from the builder).
This function is a three-step process:
oir = gtir_to_oir(self.builder.gtir) tree_ir = oir_to_tree_ir(oir) schedule_tree = tree_ir_to_schedule_tree(tree_ir)
- sdfg_via_schedule_tree(*, validate: bool = False, simplify: bool = True) SDFG[source]¶
Lower OIR into an SDFG via Schedule Tree transpile first.
Cache the SDFG into the manager for re-use, unless the builder has a no-caching policy.
- Parameters:
validate – Validate resulting SDFG
simplify – Simplify resulting SDFG
- gt4py.cartesian.backend.dace_backend._sdfg_add_arrays_and_edges(field_info: dict[str, FieldInfo], wrapper_sdfg: SDFG, state: SDFGState, inner_sdfg: SDFG, nsdfg: NestedSDFG, inputs: set[str] | dict[str, typeclass], outputs: set[str] | dict[str, typeclass], origins: dict[str, tuple[int, ...]], domain: tuple[int, ...]) None[source]¶
- gt4py.cartesian.backend.dace_backend._sdfg_specialize_symbols(wrapper_sdfg: SDFG, domain: tuple[int, ...]) None[source]¶
- gt4py.cartesian.backend.dace_backend._specialize_transient_strides(sdfg: SDFG, layout_info: LayoutInfo, replacement_dictionary: dict[str, str] | None = None) None[source]¶
- gt4py.cartesian.backend.dace_backend.freeze_origin_domain_sdfg(inner_sdfg_unfrozen: SDFG, arg_names: list[str], field_info: dict[str, FieldInfo], *, layout_info: LayoutInfo, origin: dict[str, tuple[int, ...]], domain: tuple[int, ...]) SDFG[source]¶
Create a new SDFG by wrapping a _copy_ of the original SDFG and freezing it’s origin and domain.
This wrapping is required because we do not expect any of the inner_sdfg bounds to have been specialized, e.g. we expect “__I/J/K” symbols to still be present. We wrap the call and specialize at top level, which will then be passed as a symbol to the inner sdfg.
Once we move specialization of array & maps bounds upstream, this will become moot and can be removed, see https://github.com/GridTools/gt4py/issues/2082.
Dev note: we need to wrap a copy to make sure we can use caching with no side effects in other parts of the SDFG making pipeline.
- Parameters:
inner_sdfg_unfrozen – SDFG with cartesian bounds as symbols
arg_names – names of arguments to freeze
field_info – full info stack on arguments
origin – tuple of offset into the memory
domain – tuple of size for the memory written by the stencil
gt4py.cartesian.backend.dace_lazy_stencil module¶
- class gt4py.cartesian.backend.dace_lazy_stencil.DaCeLazyStencil(builder: StencilBuilder)[source]¶
Bases:
LazyStencil,SDFGConvertible- closure_resolver(constant_args: Dict[str, Any], given_args: Set[str], parent_closure: SDFGClosure | None = None) SDFGClosure[source]¶
Returns an SDFGClosure object representing the closure of the object to be converted to an SDFG.
- Parameters:
constant_args – Arguments whose values are already resolved to compile-time values.
given_args – Arguments that were given at call-time (used for determining which arguments with defaults were provided).
parent_closure – The parent SDFGClosure object (used for, e.g., recursion detection).
- Returns:
New SDFG closure object representing the convertible object.
gt4py.cartesian.backend.dace_stencil_object module¶
- class gt4py.cartesian.backend.dace_stencil_object.DaCeFrozenStencil(stencil_object: 'DaCeStencilObject', origin: 'Dict[str, Tuple[int, ...]]', domain: 'Tuple[int, ...]', sdfg: 'dace.SDFG')[source]¶
Bases:
FrozenStencil,SDFGConvertible- closure_resolver(constant_args, given_args, parent_closure=None)[source]¶
Returns an SDFGClosure object representing the closure of the object to be converted to an SDFG.
- Parameters:
constant_args – Arguments whose values are already resolved to compile-time values.
given_args – Arguments that were given at call-time (used for determining which arguments with defaults were provided).
parent_closure – The parent SDFGClosure object (used for, e.g., recursion detection).
- Returns:
New SDFG closure object representing the convertible object.
- sdfg: SDFG¶
- stencil_object: DaCeStencilObject¶
- class gt4py.cartesian.backend.dace_stencil_object.DaCeStencilObject(*args, **kwargs)[source]¶
Bases:
StencilObject,SDFGConvertible- _abc_impl = <_abc._abc_data object>¶
- _sdfg = None¶
- closure_resolver(constant_args: Dict[str, Any], given_args: Set[str], parent_closure: SDFGClosure | None = None) SDFGClosure[source]¶
Returns an SDFGClosure object representing the closure of the object to be converted to an SDFG.
- Parameters:
constant_args – Arguments whose values are already resolved to compile-time values.
given_args – Arguments that were given at call-time (used for determining which arguments with defaults were provided).
parent_closure – The parent SDFGClosure object (used for, e.g., recursion detection).
- Returns:
New SDFG closure object representing the convertible object.
- freeze(*, origin: Dict[str, Tuple[int, ...]], domain: Tuple[int, ...]) DaCeFrozenStencil[source]¶
Return a StencilObject wrapper with a fixed domain and origin for each argument.
- Parameters:
origin (dict) – The origin for each Field argument.
domain (Sequence of int) – The compute domain shape for the frozen stencil.
Notes
Both origin and domain arguments should be compatible with the domain and origin specification defined in
StencilObject.- Returns:
The stencil wrapper. This should be called with the regular stencil arguments, but the field origins and domain cannot be changed. Note, no checking of origin or domain occurs at call time so it is the users responsibility to ensure correct usage.
- Return type:
FrozenStencil
- static normalize_arg_fields(*args, backend: str, arg_names: Iterable[str], domain_info: DomainInfo, field_info: Dict[str, FieldInfo], domain: Tuple[int, ...] | None = None, origin: Dict[str, Tuple[int, ...]] | None = None, **kwargs)[source]¶
Normalize Fields in argument list to the proper domain/origin
gt4py.cartesian.backend.debug_backend module¶
- class gt4py.cartesian.backend.debug_backend.DebugBackend(builder: StencilBuilder)[source]¶
Bases:
BaseBackendDebug backend using plain python loops.
- MODULE_GENERATOR_CLASS¶
alias of
PythonModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'python'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'debug'¶
Backend name
- options: ClassVar[dict[str, Any]] = {'ignore_np_errstate': {'type': <class 'bool'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
gt4py.cartesian.backend.gtc_common module¶
- class gt4py.cartesian.backend.gtc_common.BackendCodegen(class_name: str, module_name: str, backend: Backend)[source]¶
Bases:
object
- class gt4py.cartesian.backend.gtc_common.BaseGTBackend(builder: StencilBuilder)[source]¶
Bases:
BasePyExtBackend- GT_BACKEND_OPTS: Final[GTBackendOptions] = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
- MODULE_GENERATOR_CLASS¶
alias of
PyExtModuleGenerator
- PYEXT_GENERATOR_CLASS: type[BackendCodegen]¶
- _abc_impl = <_abc._abc_data object>¶
- _make_extension_sources() dict[str, dict[str, str]][source]¶
Generate the source for the stencil independently from use case.
- abstractmethod generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- class gt4py.cartesian.backend.gtc_common.CUDAPyExtModuleGenerator(builder: StencilBuilder)[source]¶
Bases:
PyExtModuleGenerator- _abc_impl = <_abc._abc_data object>¶
- class gt4py.cartesian.backend.gtc_common.PyExtModuleGenerator(builder: StencilBuilder)[source]¶
Bases:
BaseModuleGeneratorModule Generator for use with backends that generate c++ python extensions.
- __call__(args_data: ModuleData) str[source]¶
Generate source code for a Python module containing a StencilObject.
- _abc_impl = <_abc._abc_data object>¶
gt4py.cartesian.backend.gtcpp_backend module¶
- class gt4py.cartesian.backend.gtcpp_backend.GTBaseBackend(builder: StencilBuilder)[source]¶
Bases:
BaseGTBackend- PYEXT_GENERATOR_CLASS¶
alias of
GTExtGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- options = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- class gt4py.cartesian.backend.gtcpp_backend.GTCppBindingsCodegen(backend)[source]¶
Bases:
TemplatedGenerator- Program = <gt4py.eve.codegen.MakoTemplate object>¶
- _node_visitor_cache_: ClassVar[dict[type, str] | None] = {}¶
Cache for visitor method names per node class to speed up dispatching. Note that we cache the visitor method name, not the bound method itself, to avoid implicitly caching the visitor state, which could lead to unexpected behavior.
- classmethod apply(root, *, module_name='stencil', **kwargs) str[source]¶
Public method to build a class instance and visit an IR node.
- Parameters:
root – An IR node.
node_templates (optional) – see
NodeDumper.dump_function (optional) – see
NodeDumper.**kwargs (optional) – custom extra parameters forwarded to visit_NODE_TYPE_NAME().
- Returns:
String (or collection of strings) with the dumped version of the root IR node.
- visit_GlobalParamDecl(node: GlobalParamDecl, **kwargs)[source]¶
- class gt4py.cartesian.backend.gtcpp_backend.GTCpuIfirstBackend(builder: StencilBuilder)[source]¶
Bases:
GTBaseBackendGridTools python backend using gtc.
- GT_BACKEND_T = 'cpu_ifirst'¶
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'gt:cpu_ifirst'¶
Backend name
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.gtcpp_backend.GTCpuKfirstBackend(builder: StencilBuilder)[source]¶
Bases:
GTBaseBackendGridTools python backend using gtc.
- GT_BACKEND_T = 'cpu_kfirst'¶
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'gt:cpu_kfirst'¶
Backend name
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.gtcpp_backend.GTExtGenerator(class_name: str, module_name: str, backend: BaseGTBackend)[source]¶
Bases:
BackendCodegen
- class gt4py.cartesian.backend.gtcpp_backend.GTGpuBackend(builder: StencilBuilder)[source]¶
Bases:
GTBaseBackendGridTools python backend using gtc.
- GT_BACKEND_T = 'gpu'¶
- MODULE_GENERATOR_CLASS¶
alias of
CUDAPyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'cuda'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'gt:gpu'¶
Backend name
- options: ClassVar[GTBackendOptions] = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'device_sync': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 32, 'device': 'gpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
gt4py.cartesian.backend.module_generator module¶
- class gt4py.cartesian.backend.module_generator.BaseModuleGenerator(builder: StencilBuilder)[source]¶
Bases:
ABC- SOURCE_LINE_LENGTH = 120¶
- TEMPLATE_INDENT_SIZE = 4¶
- TEMPLATE_RESOURCE = 'stencil_module.py.in'¶
- __call__(args_data: ModuleData) str[source]¶
Generate source code for a Python module containing a StencilObject.
- _abc_impl = <_abc._abc_data object>¶
- args_data: ModuleData¶
- builder: StencilBuilder¶
- generate_backend_name() str[source]¶
Return the name of the backend.
There should never be a need to override this.
- generate_class_members() str[source]¶
Generate additional stencil class members.
May contain any class level code including methods.
- generate_class_name() str[source]¶
Generate the name of the stencil class.
This should usually be deferred to the chosen caching strategy via the builder object (see default implementation).
- generate_constants() dict[str, str][source]¶
Return a mapping of named numeric constants passed as externals.
This is unlikely to require overriding.
- generate_docstring() str[source]¶
Generate the docstring of the stencil object.
The default is to return the stencil definition’s docstring or an empty string. The output should be least based on the stencil definition’s docstring, if one exists.
- abstractmethod generate_implementation() str[source]¶
Generate the work code inside the stencil object’s run function.
- generate_imports() str[source]¶
Generate import statements and related code for the stencil class module.
- generate_module_members() str[source]¶
Generate additional module level code after all imports.
May contain any executable module level code including function and class defs.
- generate_options() dict[str, Any][source]¶
Return dictionary of build options.
Must exclude options that should never be cached.
- generate_post_run() str[source]¶
Additional code to be run just after the run method (implementation) is called.
- generate_pre_run() str[source]¶
Additional code to be run just before the run method (implementation) is called.
- generate_signature() str[source]¶
Generate the stencil definition specific part of the stencil object’s
__call__signature.Unlikely to require overriding.
- generate_sources() dict[str, str][source]¶
Return the source code of the stencil definition in string format.
This is unlikely to require overriding.
- template: jinja2.Template¶
- class gt4py.cartesian.backend.module_generator.ModuleData(domain_info: 'DomainInfo | None' = None, field_info: 'dict[str, FieldInfo]'=<factory>, parameter_info: 'dict[str, ParameterInfo]'=<factory>, unreferenced: 'list[str]' = <factory>)[source]¶
Bases:
object- domain_info: DomainInfo | None = None¶
- parameter_info: dict[str, ParameterInfo]¶
- gt4py.cartesian.backend.module_generator.make_args_data_from_gtir(pipeline: GtirPipeline) ModuleData[source]¶
Compute module data containing information about stencil arguments from gtir.
gt4py.cartesian.backend.numpy_backend module¶
- class gt4py.cartesian.backend.numpy_backend.NumpyBackend(builder: StencilBuilder)[source]¶
Bases:
BaseBackendNumPy backend using gtc.
- MODULE_GENERATOR_CLASS¶
alias of
PythonModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- _make_npir() Computation[source]¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'python'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'numpy'¶
Backend name
- property npir: Computation¶
- options: ClassVar[dict[str, Any]] = {'ignore_np_errstate': {'type': <class 'bool'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
gt4py.cartesian.backend.pyext_builder module¶
- class gt4py.cartesian.backend.pyext_builder.BuildExtension(dist: Distribution, **kw)[source]¶
Bases:
build_extA build_ext command that compiles without CPython’s own build flags.
GT4Py passes the flags it wants through extra_compile_args / extra_link_args, which distutils appends after the base flags, so scrubbing the base flags here keeps those effective.
- class gt4py.cartesian.backend.pyext_builder.CUDABuildExtension(dist: Distribution, **kw)[source]¶
Bases:
BuildExtension
- gt4py.cartesian.backend.pyext_builder._DISCARDED_BASE_FLAGS: Final = frozenset({'-DNDEBUG', '-Wstrict-prototypes', '-pg'})¶
Flags that CPython records in its own build configuration (CFLAGS, OPT, LDSHARED, …) and that distutils would otherwise pass on to every extension module we generate. They are dropped because:
-g* makes each object file and shared library carry full debug info, which inflates the GT4Py cache by more than an order of magnitude.
-O* and -DNDEBUG would compete with the optimization settings GT4Py appends itself (see get_gt_pyext_build_opts).
-pg adds profiling instrumentation GT4Py only wants on request.
-Wstrict-prototypes has no effect in C++ and warns about that for every translation unit.
- gt4py.cartesian.backend.pyext_builder._clean_compiler_flags(compiler: Any) None[source]¶
Remove CPython’s own build flags from an already configured compiler.
The flags listed in _DISCARDED_BASE_FLAGS and _DISCARDED_BASE_FLAG_PREFIXES are filtered out of every command list the compiler holds (compiler_so, compiler_so_cxx, linker_so, …), as named by its own executables mapping. Attributes that are absent or not a list of strings are left alone, so this degrades to a no-op rather than failing on compilers that do not follow the UnixCCompiler layout.
This operates on the compiler instance of a single build_ext command rather than on the sysconfig dictionaries it was configured from. Those dictionaries are process-global state shared by every thread compiling a stencil, and setuptools 84.0.0 stopped reading build configuration from distutils.sysconfig altogether (it reads the standard library’s sysconfig instead), which made patching them a silent no-op.
- gt4py.cartesian.backend.pyext_builder.build_pybind_cuda_ext(name: str, sources: list, build_path: str, target_path: str, *, include_dirs: List[str] | None = None, library_dirs: List[str] | None = None, libraries: List[str] | None = None, extra_compile_args: List[str] | Dict[str, List[str]] | None = None, extra_link_args: List[str] | None = None, verbose: bool = False, clean: bool = False) Tuple[str, str][source]¶
- gt4py.cartesian.backend.pyext_builder.build_pybind_ext(name: str, sources: list, build_path: str, target_path: str, *, include_dirs: List[str] | None = None, library_dirs: List[str] | None = None, libraries: List[str] | None = None, extra_compile_args: List[str] | Dict[str, List[str]] | None = None, extra_link_args: List[str] | None = None, build_ext_class: Type | None = None, verbose: bool = False, clean: bool = False) Tuple[str, str][source]¶
- gt4py.cartesian.backend.pyext_builder.get_gt_pyext_build_opts(*, debug_mode: bool = False, opt_level: Literal['0', '1', '2', '3', 's'] = '3', extra_opt_flags: str = '', add_profile_info: bool = False, uses_cuda: bool = False) Dict[str, str | List[str] | Dict[str, Any]][source]¶
- gt4py.cartesian.backend.pyext_builder.setuptools_setup(*, build_ext_class: type[build_ext] | None, **kwargs) None[source]¶
Calls setuptools.setup() with ‘cmdclass’ set to ‘build_ext_class’.
This is a workaround because any config file that sets an element of ‘cmdclass’ will override (instead of extend) the ‘cmdclass’ dict passed as argument to ‘setuptools.setup()’.
gt4py.cartesian.backend.python_common module¶
- class gt4py.cartesian.backend.python_common.PythonModuleGenerator(builder: StencilBuilder)[source]¶
Bases:
BaseModuleGeneratorModule Generator for use with backends that generate python code.
- _abc_impl = <_abc._abc_data object>¶
Module contents¶
- class gt4py.cartesian.backend.Backend(builder: StencilBuilder)[source]¶
Bases:
ABC- _abc_impl = <_abc._abc_data object>¶
- builder: StencilBuilder¶
- property extra_cache_info: dict[str, Any]¶
Provide additional data to be stored in cache info file (subclass hook).
- property extra_cache_validation_keys: list[str]¶
List keys from extra_cache_info to be validated during consistency check.
- classmethod filter_options_for_id(options: BuildOptions) BuildOptions[source]¶
Filter a copy for options that should not be part of the stencil ID.
- abstractmethod generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- languages: ClassVar[dict[str, Any] | None] = None¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- abstractmethod load() type[StencilObject] | None[source]¶
Load the stencil class from the generated python module.
- type:
The generated stencil class after loading through python’s import API
This assumes that
Backend.generate()has been called already on the same stencil. The python module therefore already exists and any python extensions have been compiled. In case the stencil changed since the last generate call, it will not be rebuilt.
- options: ClassVar[dict[str, Any]]¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[gt_storage.layout.LayoutInfo]¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.BaseBackend(builder: StencilBuilder)[source]¶
Bases:
Backend- MODULE_GENERATOR_CLASS: ClassVar[type[BaseModuleGenerator]]¶
- _abc_impl = <_abc._abc_data object>¶
- _load() type[StencilObject][source]¶
- check_options(options: BuildOptions) None[source]¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- load() type[StencilObject] | None[source]¶
Load the stencil class from the generated python module.
- type:
The generated stencil class after loading through python’s import API
This assumes that
Backend.generate()has been called already on the same stencil. The python module therefore already exists and any python extensions have been compiled. In case the stencil changed since the last generate call, it will not be rebuilt.
- make_module() type[StencilObject][source]¶
- make_module_source(*, args_data: ModuleData | None = None) str[source]¶
Generate the module source code with or without stencil id.
- class gt4py.cartesian.backend.BaseModuleGenerator(builder: StencilBuilder)[source]¶
Bases:
ABC- SOURCE_LINE_LENGTH = 120¶
- TEMPLATE_INDENT_SIZE = 4¶
- TEMPLATE_RESOURCE = 'stencil_module.py.in'¶
- __call__(args_data: ModuleData) str[source]¶
Generate source code for a Python module containing a StencilObject.
- _abc_impl = <_abc._abc_data object>¶
- args_data: ModuleData¶
- builder: StencilBuilder¶
- generate_backend_name() str[source]¶
Return the name of the backend.
There should never be a need to override this.
- generate_class_members() str[source]¶
Generate additional stencil class members.
May contain any class level code including methods.
- generate_class_name() str[source]¶
Generate the name of the stencil class.
This should usually be deferred to the chosen caching strategy via the builder object (see default implementation).
- generate_constants() dict[str, str][source]¶
Return a mapping of named numeric constants passed as externals.
This is unlikely to require overriding.
- generate_docstring() str[source]¶
Generate the docstring of the stencil object.
The default is to return the stencil definition’s docstring or an empty string. The output should be least based on the stencil definition’s docstring, if one exists.
- abstractmethod generate_implementation() str[source]¶
Generate the work code inside the stencil object’s run function.
- generate_imports() str[source]¶
Generate import statements and related code for the stencil class module.
- generate_module_members() str[source]¶
Generate additional module level code after all imports.
May contain any executable module level code including function and class defs.
- generate_options() dict[str, Any][source]¶
Return dictionary of build options.
Must exclude options that should never be cached.
- generate_post_run() str[source]¶
Additional code to be run just after the run method (implementation) is called.
- generate_pre_run() str[source]¶
Additional code to be run just before the run method (implementation) is called.
- generate_signature() str[source]¶
Generate the stencil definition specific part of the stencil object’s
__call__signature.Unlikely to require overriding.
- generate_sources() dict[str, str][source]¶
Return the source code of the stencil definition in string format.
This is unlikely to require overriding.
- template: jinja2.Template¶
- class gt4py.cartesian.backend.BasePyExtBackend(builder: StencilBuilder)[source]¶
Bases:
BaseBackend- _abc_impl = <_abc._abc_data object>¶
- build_extension_module(pyext_sources: dict[str, Any], pyext_build_opts: dict[str, str], *, uses_cuda: bool = False) None[source]¶
- property extra_cache_info: dict[str, Any]¶
Provide additional data to be stored in cache info file (subclass hook).
- property extra_cache_validation_keys: list[str]¶
List keys from extra_cache_info to be validated during consistency check.
- abstractmethod generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- class gt4py.cartesian.backend.DaceCPUBackend(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackend- MODULE_GENERATOR_CLASS¶
alias of
DaCePyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:cpu'¶
Backend name
- options = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.DaceCPUKFirstBackend(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackend- MODULE_GENERATOR_CLASS¶
alias of
DaCePyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:cpu_kfirst'¶
Backend name
- options = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.DaceGPUBackend(builder: StencilBuilder)[source]¶
Bases:
BaseDaceBackendGPU DaCe python with an optimal KJI loop layout
- MODULE_GENERATOR_CLASS¶
alias of
DaCeCUDAPyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'cuda'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'dace:gpu'¶
Backend name
- options: ClassVar[GTBackendOptions] = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'device_sync': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'gpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.DebugBackend(builder: StencilBuilder)[source]¶
Bases:
BaseBackendDebug backend using plain python loops.
- MODULE_GENERATOR_CLASS¶
alias of
PythonModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'python'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'debug'¶
Backend name
- options: ClassVar[dict[str, Any]] = {'ignore_np_errstate': {'type': <class 'bool'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.GTCpuIfirstBackend(builder: StencilBuilder)[source]¶
Bases:
GTBaseBackendGridTools python backend using gtc.
- GT_BACKEND_T = 'cpu_ifirst'¶
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'gt:cpu_ifirst'¶
Backend name
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.GTCpuKfirstBackend(builder: StencilBuilder)[source]¶
Bases:
GTBaseBackendGridTools python backend using gtc.
- GT_BACKEND_T = 'cpu_kfirst'¶
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'c++'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'gt:cpu_kfirst'¶
Backend name
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.GTGpuBackend(builder: StencilBuilder)[source]¶
Bases:
GTBaseBackendGridTools python backend using gtc.
- GT_BACKEND_T = 'gpu'¶
- MODULE_GENERATOR_CLASS¶
alias of
CUDAPyExtModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- generate_extension() None[source]¶
Generate and build a python extension for the stencil computation.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'cuda'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'gt:gpu'¶
Backend name
- options: ClassVar[GTBackendOptions] = {'add_profile_info': {'type': <class 'bool'>, 'versioning': True}, 'clean': {'type': <class 'bool'>, 'versioning': False}, 'debug_mode': {'type': <class 'bool'>, 'versioning': True}, 'device_sync': {'type': <class 'bool'>, 'versioning': True}, 'extra_opt_flags': {'type': <class 'str'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}, 'opt_level': {'type': <class 'str'>, 'versioning': True}, 'verbose': {'type': <class 'bool'>, 'versioning': False}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 32, 'device': 'gpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout
- class gt4py.cartesian.backend.NumpyBackend(builder: StencilBuilder)[source]¶
Bases:
BaseBackendNumPy backend using gtc.
- MODULE_GENERATOR_CLASS¶
alias of
PythonModuleGenerator
- _abc_impl = <_abc._abc_data object>¶
- _make_npir() Computation[source]¶
- generate() type[StencilObject][source]¶
Generate the stencil class from GTScript’s internal representation.
- Returns:
type – The generated stencil class after loading through python’s import API
In case the stencil class for the given ID is found in cache, this method can avoid
rebuilding it. Rebuilding can however be triggered through the
optionsparameterif supported by the backend.
- languages: ClassVar[dict] = {'bindings': ['python'], 'computation': 'python'}¶
Language support:
“computation”: name of the language in which the computation is implemented.
“bindings”: names of supported language bindings / wrappers. If a high-level language is compatible out-of-the-box, it should not be listed.
Languages should be spelled using the official spelling but lower case (“python”, “fortran”, “rust”).
- name = 'numpy'¶
Backend name
- property npir: Computation¶
- options: ClassVar[dict[str, Any]] = {'ignore_np_errstate': {'type': <class 'bool'>, 'versioning': True}, 'oir_pipeline': {'type': <class 'gt4py.cartesian.gtc.passes.oir_pipeline.OirPipeline'>, 'versioning': True}}¶
Backend-specific options:
info: - versioning: is versioning on? - description [optional] - type
- storage_info: ClassVar[layout.LayoutInfo] = {'alignment': 1, 'device': 'cpu', 'is_optimal_layout': <function layout_checker_factory.<locals>.layout_checker>, 'layout_map': <function layout_maker_factory.<locals>.layout_maker>}¶
Backend-specific storage parametrization:
“alignment”: in bytes
“device”: “cpu” | “gpu”
“layout_map”: callback converting a mask to a layout
“is_optimal_layout”: callback checking if a storage has compatible layout