Skip to content

GHOST 3.0.0

Latest

Choose a tag to compare

@pmininni pmininni released this 12 Oct 22:32
· 2 commits to master since this release

New GHOST v3 release

This is a major release of GHOST. GHOST 3 is a complete rewrite of our CFD code. The solvers, time steppers, initial conditions, forcings, and particles are now object-oriented Fortran 2023 classes, built with CMake, and configured entirely at run time. In all cases, benchmarks are comparable to the previous version of GHOST (v2), or up to 25% faster in CPUs. This release also adds full GPU support through OpenMP offload, for both NVIDIA and AMD GPUs. We have measured speed ups of up to 10x when running in GPUs, compared with simulations done using all CPUs in the same nodes containing the GPUs. This new version of GHOST also includes a Python library with a callable Python interface, allowing for interactive simulations, and for the integration of GHOST in machine learning workflows. Version 3 drops some legacy libraries, compilers, and solvers. Users who need them can keep using the stable GHOST_v2 or GHOST_v1 branches.

New architecture

  • Object-oriented. PDE solvers, particle solvers, time steppers, initial conditions, and forcing methods now are classes created through factories. This makes adding new solvers much easier, as each solver now lives in a single file (e.g., the HD solver is in src/pdes/hd_solver.f90).
  • One executable for all solvers. The solver is selected at run time in parameter.inp (&pdes solver = "HD"), instead of compiling a separate binary for each solver.
  • Resolution and box size set at run time. nx, ny, nz are read from the &grid namelist, and the domain size from &boxparams. Changing the resolution no longer requires recompiling.
  • Composable initial conditions (ICs) and forcings. ICs and forcings are given as lists (e.g., iclist = "random_v;random_b", forces = "tg_fv,constant_fv"). Each forcing pairs an initial method with an update scheme (constant, shift, shuffle, ...).
  • Workspace memory pool. GHOST now controls memory allocation, supporting memory allocation in the host and in the device (for GPU runs) for temporaries, with leak and exhaustion checks.
  • Per-class I/O directories. Each solver and particle class can have its own input/output directories, and all outputs can be redirected to separate directories.
  • Configurable level of detail for spectral and particle output (new spectlod, partlod options).

Solvers

The following solvers have been ported to the new framework. Rotation, uniform magnetic fields, Hall effects, and passive scalars are now run-time options of each solver rather than separate solvers:

  • HD: incompressible Navier–Stokes, with optional rotation and multiple passive scalars.
  • MHD: incompressible MHD, with optional guide field (B₀), Hall effect, and multiple passive scalars.
  • CMHD: compressible MHD, with optional B₀ and Hall effect. This solver includes abstract base classes to support compressible HD in future releases.
  • BOUSS: rotating and stratified Boussinesq flows.
  • MOIST: moist (multi-phase) Boussinesq flows.
  • GPE: Gross–Pitaevskii equation, with optional rotation and trapping potential (replaces GPE/RGPE in GHOST v2).
  • GL: advective real Ginzburg–Landau, with optional rotation (replaces ARGL/RARGL).

Particles

  • Particle solvers are now classes, integrated together with the fluid by the same time steppers. The new classes and the new time steppers allow two- and four-way coupled particles (in this release, all particles are one-way coupled). Multiple particles can also be integrated simultaneously with minimal modifications to main.F90 (an example file will be included in future releases). The new classes are:

    • lagpart: Lagrangian tracers.
    • inerpart: inertial particles, with optional gravity and the Clift–Gauvin (1971) nonlinear drag correction.
    • testpart: charged test particles in MHD and CMHD flows, with many kinetic plasma physics effects.
  • New initial conditions for particles. Positions: read_x, user_x, random_x. Velocities: read_v, null_v, fluid_v, thermal_v.

  • Improved Nearest-Neighbor (NN) communication interface for particles, with dynamic resizing of the particle buffers.

  • Particle-only stepping (pstep), in addition to coupled fluid + particle stepping.

  • Improved threaded particle loops and spline solves to ensure consistent and reproducible results when running in a single thread or with multiple OpenMP threads.

Time stepping

Time steppers are now independent classes, selected with the &stepper namelist. They can be changed at run time. This release includes:

  • traditional: the classic GHOST low-memory Runge–Kutta scheme (Canuto et al.).
  • gexrk: generic explicit Runge–Kutta using Butcher tableaux (orders 1–4). It works for fluids, particles, and both together. More stable and with smaller errors than traditional, at the cost of increased memory usage.

Performance and parallelization

  • GPU offload with OpenMP target directives for NVIDIA and AMD GPUs (-DP_GPU=ON). When using GPUs, all fluid and particle solvers run on the device.
    • FFTs use cuFFT or hipFFT through the new fftp-gpu backend.
    • Multiple GPU support: Communication uses GPU-aware MPI, with a staged fallback (GHOST_GPU_EXCHANGE=staged).
    • Supported compilers are NVIDIA nvfortran, LLVM flang, and AMD ROCm amdflang/flang.
    • Fast: We have measured speed ups of up to 10x when comparing one AMD MI210 against 48 CPU cores, and up to 20x when comparing one NVIDIA A100 against 48 CPU cores.
  • Single code path for CPU and GPU. Host and device versions of the kernels share one set of loops.
  • Hybrid MPI + OpenMP in the host using modern collapse / DO CONCURRENT loops, with FFTW multi-threading.
  • FFTW plans now use FFTW_MEASURE on the host.
  • MPI now uses the mpi_f08 bindings, supporting newer versions of MPI.

Python interface

  • New shared library (libghost_python) to run GHOST from Python, in batch or interactive sessions and in machine-learning workflows. It provides functions to:
    • initialize, advance, and finalize a run, and change the time step on the fly;
    • get direct access to the real- and complex-space fields and to the forcing.
  • The library works with threaded and offload builds.
  • Example scripts are provided in contrib/python.

Build system and tools

  • CMake build system replaces the old Makefiles.
    • Supports parallel builds (make -j) and includes an installer.
    • User options are set in UserConfig.cmake.
    • Example build scripts are provided for the host and for AMD and NVIDIA GPUs.
  • Compiler support: GNU, Intel, NVHPC, LLVM and AMD flang.
  • BOOTS (bootstrap regridding) was updated, and now is built together with the main code.
  • Post-processing examples for IDL, Matlab, Python, and VAPOR were updated.
  • Reorganized source tree under src/, with a new build directory.
  • New example input files for every solver are provided in src/examples/.

Bug fixes (also relevant to v2 users)

  • Vertical offset of particle field values. Fixed a one-grid-point (Δz) shift in the vertical direction in the fields sensed by particles. Reported by Anu V.S. Nath.
  • Fixed bugs in the BOUSS horizontally averaged diagnostics when using spectlod = 4.
  • Fixed a bug in the reproducible random numbers when using some compilers.

Breaking changes and removed features

  • Input files from GHOST v2 are not compatible with this version. The structure of parameter.inp changed (new namelists for grid, solver, stepper, ICs, forcings, and particles). See src/README and src/examples/.
  • Removed features:
    • 2D solvers (GHOST v3 can do runs in 2D by setting ny=1).
    • POSIX I/O. Only MPI-IO is supported in this version.
    • FFTW 2.x (fftp-2), Intel MKL FFTs (fftp-mkl), and the CUDA backend (fftp-cu). The CUDA backend is replaced by fftp-gpu.
    • Several subgrid-scale models (LAHD, CAHD, LHD, LAMHD, EDQNM).
    • Penalty-method solvers and hybrid PIC solvers.
    • Other legacy solvers not listed above.
    • Users who need any of these should use the GHOST_v2 branch.

Contributors

Pablo Mininni and Duane Rosenberg, with contributions from Patricio Clark di Leoni, Juan Giordano and Bernardo Español. We thank all users who reported issues.

Full Changelog: v2.1.0...v3.0.0