This directory contains the common GNU Make infrastructure used by both the OP2 and example app builds. The entry point common.mk
serves to set up compiler executables and library paths using compilers/
, profiles/
and dependencies/
, while {c, f}_app.mk
specify a complete set of build rules for the apps written in their respective languages. For OP2, the build rules are instead located in op2/Makefile
.
This is included at the start of both the primary OP2 makefile in op2/Makefile
, and before the {c, f}_app.mk
in the app Makefile
s. There is a selection of partially optional input variables used to specify the compilers, flags and libraries:
OP2_{C, C_CUDA, F}_COMPILER
: These specify the basenames of the makefiles in their respectivecompilers/{c, c_cuda, fortran}
directories that are automatically included to setup the compiler executables, flags and feature flags. If one of these is left undefined then the corresponding library and app functionality will not be built. At the very minimum anOP2_C_COMPILER
is required.OP2_COMPILER
: Equivalent toOP2_C_COMPILER=X OP2_F_COMPILER=X OP2_C_CUDA_COMPILER=nvhpc
.OP2_PROFILE
: A potential alternative (although not necessarily) to specifiyingOP2_COMPILER
or theOP2_{C, C_CUDA, F}_COMPILER
variables, this specifies the basename of the profile underprofiles/
that is included to help setup compilation in a particular build environment. More information below.- (optional)
OP2_BUILD_DIR
: The directory under which OP2'slib/
mod/
andobj/
folders and contents will be built. This defaults toOP2-Common/op2
which should be acceptable for most cases.
In addition, most variables defined as a result of the inclusion of common.mk
and the respective compiler/profile makefiles can be overriden on input, for example to use mpic++
instead of mpicxx
: make MPICXX=mpic++ ...
.
These are intended for cluster and/or custom compiler setup and are specified by setting OP2_PROFILE
as detailed above. They are included at the start of common.mk
, and thus can be used to override any Make variables that are initally assigned using ?=
. Variables set here have the same effect as those set on the command-line. Hard-coded paths to resources that are not part of the common infrastructure on a particular cluster should not be set here.
The compilers.mk
makefile first includes the specific compiler makefiles in compilers/
as dictated by the values of OP2_COMPILER
and OP2_{C, C_CUDA, F}_COMPILER
. Following this it then verifies that the compiler executables set by these makefiles are present, and then sets the HAVE_{C, C_CUDA, F, MPI_C, MPI_F}
variables which are used to calculate the buildable set of OP2 libraries and app variants.
The compilers/c
directory contains definitions for the C and C++ compilers, the compilers/c_cuda
directory contains definitions for CUDA compilers that can ingest .cu
files and the compilers/fortran
directory contains definitions for Fortran compilers that can ingest .F90
and optionally .CUF
. Each makefile in these directories is expected to set specific set of variables.
Basic compiler setup:
CC
: The plain C compiler executable name (e.g.gcc
).CXX
: The C++ compiler executable name (e.g.g++
).CFLAGS
: The flags to be used for plain C compilation. These are expected to adhere to whetherDEBUG
is defined.CXXFLAGS
: The flags to be used for C++ compilation. As withCFLAGS
these should adhere toDEBUG
.CXXLINK
: Any additional libraries required for linking objects produced byCXX
(e.g.-lstdc++
).
Available OpenMP features:
OMP_CXXFLAGS
: The flags to enable compilation of OpenMP pragmas (e.g.-fopenmp
).CPP_HAS_OMP
: Set totrue
if the C and C++ compilers support OpenMP.OMP_OFFLOAD_CXXFLAGS
: The flags to enable the compilation of OpenMP 4.0 offload pragmas (e.g.-foffload=nvptx-none
).CPP_HAS_OMP_OFFLOAD
: Set totrue
if the C and C++ compilers support OpenMP 4.0 offload.
Basic compiler setup:
NVCC
: The CUDA compiler executable (e.g.nvcc
).NVCCFLAGS
: The flags used for CUDA compilation. These are expected to adhere toDEBUG
and also enable target-specific code generation for each of the numerical architectures in theCUDA_GEN
list.
Basic compiler setup:
FC
: The Fortran compiler executable. (e.g.gfortran
)FFLAGS
: The flags to be used for Fortran compilation. These are expected to adhere to whetherDEBUG
is defined.F_MOD_OUT_OPT
: The flag to specify the.mod
output directory (e.g.-J
). This will be concatenated with the directory without a separating space.F_HAS_PARALLEL_BUILDS
: Set totrue
if running two instances of the compiler on the same source files at the same time is supported. This is likely to be the case unless the compiler emits object files in the same directory as the source files with no way to control this behaviour (nvfortran
...).
Available OpenMP features:
OMP_FFLAGS
: The flags to enable compilation of OpenMP pragmas (e.g.-fopenmp
).F_HAS_OMP
: Set totrue
if the Fortran compiler supports OpenMP.OMP_OFFLOAD_FFLAGS
: The flags to enable the compilation of OpenMP 4.0 offload pragmas (e.g.-foffload=nvptx-none
).F_HAS_OMP_OFFLOAD
: Set totrue
if the Fortran compiler supports OpenMP 4.0 offload.
Available CUDA features:
CUDA_FFLAGS
: The flags to enable compilation of CUDA Fortran (.CUF
) sources. These should enable target-specific code generation for each of the numerical architectures in theCUDA_GEN
list.F_HAS_CUDA
: Set totrue
if the Fortran compiler supports CUDA.
This directory contains makefiles corresponding to each library dependency of OP2. These all follow a specific structure, and test for the presence of the dependency by compiling the small test executables in dependencies/tests
. The structure is as follows:
- The
X_INC_PATH
andX_LIB_PATH
variables are set using theX_INSTALL_PATH
input variable. - The test executable is compiled with both the
X_INC_PATH
andX_LIB_PATH
set but without the expected flags needed to link to the library (for example-lparmetis -lmetis
). This is done to detect if the dependency is automatically linked by a compiler wrapper or similar. - If the previous test fails the
X_LINK
variable is then set to the expected flags needed to link the library, and the test executable is recompiled. - If either of the tests succeeded, then the
HAVE_X
variable is set totrue
, and theX_INC
andX_LIB
variables are set in accordance.
These are generic makefiles that define a complete set of build rules for the common source structures found in the apps. The variants that will be built depend on the available compilers and compiler features. All of the possible variants currently are:
seq
: Basic sequential variant that simply links with the OP2 libraries without code translation.genseq
: Translated sequential variant.vec
: A sequential variant with OpenMP SIMD vectorisation pragmas.openmp
: A multi-threaded variant using OpenMP pragmas.cuda
: A multi-threaded variant using NVIDIA CUDA.mpi_<variant>
: Many-core MPI variants of all other variants.
A few input variables must be defined before the inclusion of the makefiles. For the c_app.mk
makefile these are:
APP_NAME
: The name that will be used in the output executables and objects.APP_ENTRY
: The main.cpp
source file which will be run through the translators.APP_ENTRY_MPI
: The main.cpp
source file with MPI support that will be run through the translators.- (optional)
OP2_LIBS_WITH_HDF5
: Provides the HDF5 libraries along with the OP2 libraries in theOP2_LIB_*
helpers. Set totrue
when building an app that uses HDF5.
For the f_app.mk
makefile the following are available:
APP_NAME
: The name that will be used in the output executables and objects as well as the name (without.F90
) extension of the main app source file.- (optional)
OP2_LIBS_WITH_HDF5
: Provides the HDF5 libraries along with the OP2 libraries in theOP2_LIB_*
helpers. Set totrue
when building an app that uses HDF5.
The inclusion of common.mk
is required prior to the inclusion of the appropriate app makefile. Additional build rules may be added using GNU Make's prerequisite merging functionality. See airfoil_hdf5/dp/Makefile for an example.