Appearance
The tutorial
The tutorial teaches FUNDAL by growing one program, a solver of the 1-D heat equation, from a first device array to a multi-device MPI run with production checks. Each chapter is a complete program that is compiled and run; every output shown is the real output of that program. The cookbook then collects short recipes, and the reference has every argument of every procedure.
The problem
The temperature
Starting from one sine arch,
The chapters
| Chapter | You learn |
|---|---|
| 1. A first device array | dev_init, dev_alloc with a label, dev_memcpy_to_device/_from_device, dev_free, dev_get_alloc_stats |
| 2. Bounds, resizing, copies | lower bounds and ghost cells, init_value, dev_alloc_replace, dev_assign_to_device/_from_device and their bounds |
| 3. Portable kernels | fundal.H, the DEVICEVAR/DEVICEPTR/OMPLOOP macros, a diffusion step on the device, pointer swaps |
| 4. Routines and types | kernels in procedures with device dummy arguments, a derived type holding device arrays |
| 5. The unstructured model | host allocatables mapped to the device: dev_alloc_unstr, dev_memcpy_*_unstr, dev_free_unstr |
| 6. Several devices with MPI | mpih_object, one device per rank, halo exchange through host buffers |
| 7. Production runs | require_device, dev_is_host_fallback, the registry policy, dev_alloc_report, checked dev_free |
Building the examples
Every program of the tutorial and of the cookbook is in docs/examples/src. With FUNDAL built by make (see Installation):
bash
make COMPILER=gnu BACKEND=oac
gfortran -cpp -DCOMPILER_GNU -DDEV_OAC -fopenacc -I src/lib -I build/gnu-oac/mod \
docs/examples/src/heat_1.F90 build/gnu-oac/libfundal.a -o heat_1
./heat_1Chapter 6 needs the MPI handler: build the library with MPI=1 and compile the program with mpif90. bash scripts/docs_examples.sh builds and runs all of them as the documentation does: gfortran through the MPI wrapper, OpenACC backend, on the host (ACC_DEVICE_TYPE=host), regenerating the outputs shown in these pages.