Convert preprocessor use so that symbols are always defined
We will end up with no preprocessor constructs that check whether GROMACS preprocessor symbols are defined, because we will always define them to a value and check that instead. This is much more robust under maintenance, and is something other large projects have done also (e.g. https://sourceware.org/glibc/wiki/Wundef). We've had several issue arise through not doing this as well as we could (e.g. #1673). Once complete, we can use
gcc -Wundef to keep the code like that, and have fewer home-grown scripts checking things.
So far, the SIMD module is completed, but src/config.h.in needs a lot more
#cmakedefine01 (and associated code fixes).
Update use of preprocessor in managing GPU support
Once CMake has done detection of GPU library support, within CMake we
now use GMX_USE_CUDA and GMX_USE_OPENCL to handle details such as
which source code files should be compiled. This makes code in
CMakeLists.txt files slightly more clear.
To configure the GROMACS build via config.h, CMake sets GMX_GPU_TYPE
to match the name of one of three hard-coded defines in
config.h.cmake.in, and configures GMX_GPU with the value represented
by that name. This ensures GMX_GPU always has a value in source code,
so various kinds of mis-use will found by the compiler. It also means
we can use GMX_GPU and the values of those defines to simplify the
parts of high-level code that are different according to which GPU
configuration is in use - mostly in reporting to the user what is
going on. This reduces the number of complex preprocessor conditionals
that might want documenting or indenting, and makes it harder to write
a syntax error that can only be found with a particular build
Minor change to the start-of-run reporting. Rather than show that GPU
is disabled/enabled, and OpenCL likewise, show disabled or which of
CUDA or OpenCL is enabled for GPU acceleration. The OpenCL library
name will make clear whether AMD or NVIDIA libraries is providing the
No changes to user interface of CMake. Removed redundant declaration
of option(GMX_GPU) from main CMakeLists.txt, since gmxManageGpu()
already did that.
No changes required to current or future compute code, since CMake
still handles whether such code is compiled at all.
Change GMX_DOUBLE to be always defined
Also documented use of precision-related CMake variables
There may be some references in the SIMD documentation that still
refer to GMX_DOUBLE being defined, but we should solve that
separately, given the other changes at the moment.
Some abuse that un-defined GMX_DOUBLE was hard-coding some use of
single precision in mdebin_bar.cpp, so made that explicit.
Removed GMX_CPT_BUILD_DP, which can now be replaced by GMX_DOUBLE.
Removed some #ifdef in QM code, because floating-point arguments to
printf are automatically promoted to double. scanf still needs
remove duplicate macros and enable Wundef in CUDA
Commit adbada4 left a checks of the host-side undefined CUDA_ARCH
undefined macro behind in nbnxn_cuda.cu as well as some unused macros.
This change cleans up these leftovers.
Additionally, this change enables -Wundef for CUDA files, but only for
CUDA >=v7.5 as prior versions come with a header that uses a macro check
As the host-side code still includes kernels with CUDA_ARCH which is
not defined in the host compilation pass, we need create our own copy
of this arch macro in a new header that is meant to contain CUDA