Package: gt4py
GT4Py: GridTools for PythonGT4Py is a Python library for generating high performance implementations of stencil kernels from a high-level definition using regular Python functions. GT4Py is part of the GridTools framework, a set of libraries and utilities to develop performance portable applications in the area of weather and climate modeling.NOTE:Thegt4py.nextsubpackage contains a new version of GT4Py which is not compatible with the currentstableversion defined ingt4py.cartesian. The new version is highly experimental, it only works with unstructured meshes and it requirespython >= 3.10.📃 DescriptionGT4Py is a Python library for expressing computational motifs as found in weather and climate applications. These computations are expressed in a domain specific language (GTScript) which is translated to high-performance implementations for CPUs and GPUs.The DSL expresses computations on a 3-dimensional Cartesian grid. The horizontal axes (I,J) are always computed in parallel, while the vertical (K) can be iterated in sequential, forward or backward, order. Cartesian offsets are expressed relative to a center index.In addition, GT4Py provides functions to allocate arrays with memory layout suited for a particular backend.The following backends are supported:numpy: Pure-Python backendgt:cpu_ifirst: GridTools C++ CPU backend usingI-first data orderinggt:cpu_kfirst: GridTools C++ CPU backend usingK-first data orderinggt:gpu: GridTools backend for CUDAcuda: CUDA backend minimally using utilities from GridToolsdace:cpu: Dace code-generated CPU backenddace:gpu: Dace code-generated GPU backend🚜 InstallationGT4Py can be installed as a regular Python package usingpip(or any other PEP-517 frontend). As usual, we strongly recommended to create a new virtual environment to work on this project.The performance backends also require theBoost <https://www.boost.org/>__ library, a dependency ofGridTools C++, which needs to be installed by the user.⚙ ConfigurationIf GridTools or Boost are not found in the compiler's standard include path, or a custom version is desired, then a couple configuration environment variables will allow the compiler to use them:GT_INCLUDE_PATH: Path to the GridTools installation.BOOST_ROOT: Path to a boost installation.Other commonly used environment variables are:CUDA_ARCH: Set the compute capability of the NVIDIA GPU if it is not detected automatically bycupy.CXX: Set the C++ compiler.GT_CACHE_DIR_NAME: Name of the compiler's cache directory (defaults to.gt_cache)GT_CACHE_ROOT: Path to the compiler cache (defaults to./)More options and details are available inconfig.py.📖 DocumentationGT4Py uses Sphinx documentation. To build the documentation install the dependencies inrequirements-dev.txtpipinstall-r./gt4py/requirements-dev.txtand then build the docs withcdgt4py/docs/user/cartesian
makehtml# run 'make help' for a list of targets🛠 Development InstructionsFollow the installation instructions below to initialize a development virtual environment containing aneditableinstallation of the GT4Py package. Make sure you read theCONTRIBUTING.mdandCODING_GUIDELINES.mddocuments before you start working on the project.Recommended Installation usingtoxIftoxis already installed in your system (toxis available in PyPI and many other package managers), the easiest way to create a virtual environment ready for development is:# Clone the repositorygitclonehttps://github.com/gridtools/gt4py.gitcdgt4py# Create the development environment in any location (usually `.venv`)# selecting one of the following templates:#     dev-py310       -> base environment#     dev-py310-atlas -> base environment + atlas4py bindingstoxdevenv-edev-py310.venv# Finally, activate the environmentsource.venv/bin/activateManual InstallationAlternatively, a development environment can be created from scratch installing the frozen dependencies packages :# Clone the repositorygitclonehttps://github.com/gridtools/gt4py.gitcdgt4py# Create a (Python 3.10) virtual environment (usually at `.venv`)python3.10-mvenv.venv# Activate the virtual environment and update basic packagessource.venv/bin/activate
pipinstall--upgradewheelsetuptoolspip# Install the required development toolspipinstall-rrequirements-dev.txt# Install GT4Py project in editable modepipinstall-e.# Optionally, install atlas4py bindings directly from the repo# pip install git+https://github.com/GridTools/atlas4py#egg=atlas4py⚖️ LicenseGT4Py is licensed under the terms of theGPLv3.