Fixes for Intel and container build fixes
[gromacs.git] / docs / install-guide / index.rst
blob6f332dff78f33cc2670539335a7a2f9ed7c18d2b
1 .. Note that this must be a single rst file in order for Sphinx
2    to build into into a single plain-text file to place in the
3    installation tarball.
5 .. _install guide:
7 ******************
8 Installation guide
9 ******************
11 .. highlight:: bash
13 Introduction to building |Gromacs|
14 ----------------------------------
16 These instructions pertain to building |Gromacs|
17 |version|. You might also want to check the `up-to-date installation instructions`_.
19 Quick and dirty installation
20 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 1. Get the latest version of your C and C++ compilers.
22 2. Check that you have CMake version |CMAKE_MINIMUM_REQUIRED_VERSION| or later.
23 3. Get and unpack the latest version of the |Gromacs| tarball.
24 4. Make a separate build directory and change to it.
25 5. Run ``cmake`` with the path to the source as an argument
26 6. Run ``make``, ``make check``, and ``make install``
27 7. Source ``GMXRC`` to get access to |Gromacs|
29 Or, as a sequence of commands to execute:
31 .. parsed-literal::
33     tar xfz gromacs-|version|.tar.gz
34     cd gromacs-|version|
35     mkdir build
36     cd build
37     cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON
38     make
39     make check
40     sudo make install
41     source /usr/local/gromacs/bin/GMXRC
43 This will download and build first the prerequisite FFT library
44 followed by |Gromacs|. If you already have FFTW installed, you can
45 remove that argument to ``cmake``. Overall, this build of |Gromacs|
46 will be correct and reasonably fast on the machine upon which
47 ``cmake`` ran. On another machine, it may not run, or may not run
48 fast. If you want to get the maximum value for your hardware with
49 |Gromacs|, you will have to read further. Sadly, the interactions of
50 hardware, libraries, and compilers are only going to continue to get
51 more complex.
53 Quick and dirty cluster installation
54 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56 On a cluster where users are expected to be running across multiple
57 nodes using MPI, make one installation similar to the above, and
58 another using ``-DGMX_MPI=on`` and which is `building only
59 mdrun`_, because that is the only component of |Gromacs| that uses
60 MPI. The latter will install a single simulation engine binary,
61 i.e. ``mdrun_mpi`` when the default suffix is used. Hence it is safe
62 and common practice to install this into the same location where
63 the non-MPI build is installed.
65 Typical installation
66 ^^^^^^^^^^^^^^^^^^^^
68 As above, and with further details below, but you should consider
69 using the following `CMake options`_ with the
70 appropriate value instead of ``xxx`` :
72 * ``-DCMAKE_C_COMPILER=xxx`` equal to the name of the C99 `Compiler`_ you wish to use (or the environment variable ``CC``)
73 * ``-DCMAKE_CXX_COMPILER=xxx`` equal to the name of the C++98 `compiler`_ you wish to use (or the environment variable ``CXX``)
74 * ``-DGMX_MPI=on`` to build using `MPI support`_ (generally good to combine with `building only mdrun`_)
75 * ``-DGMX_GPU=on`` to build using nvcc to run using NVIDIA `CUDA GPU acceleration`_ or an OpenCL_ GPU
76 * ``-DGMX_USE_OPENCL=on`` to build with OpenCL_ support enabled. ``GMX_GPU`` must also be set.
77 * ``-DGMX_SIMD=xxx`` to specify the level of `SIMD support`_ of the node on which |Gromacs| will run
78 * ``-DGMX_BUILD_MDRUN_ONLY=on`` for `building only mdrun`_, e.g. for compute cluster back-end nodes
79 * ``-DGMX_DOUBLE=on`` to build |Gromacs| in double precision (slower, and not normally useful)
80 * ``-DCMAKE_PREFIX_PATH=xxx`` to add a non-standard location for CMake to `search for libraries, headers or programs`_
81 * ``-DCMAKE_INSTALL_PREFIX=xxx`` to install |Gromacs| to a `non-standard location`_ (default ``/usr/local/gromacs``)
82 * ``-DBUILD_SHARED_LIBS=off`` to turn off the building of shared libraries to help with `static linking`_
83 * ``-DGMX_FFT_LIBRARY=xxx`` to select whether to use ``fftw3``, ``mkl`` or ``fftpack`` libraries for `FFT support`_
84 * ``-DCMAKE_BUILD_TYPE=Debug`` to build |Gromacs| in debug mode
86 Building older versions
87 ^^^^^^^^^^^^^^^^^^^^^^^
89 Installation instructions for old |Gromacs| versions can be found at
90 the |Gromacs| `documentation page
91 <http://manual.gromacs.org/documentation>`_.
93 Prerequisites
94 -------------
96 Platform
97 ^^^^^^^^
99 |Gromacs| can be compiled for many operating systems and
100 architectures.  These include any distribution of Linux, Mac OS X or
101 Windows, and architectures including x86, AMD64/x86-64, several
102 PowerPC including POWER8, ARM v7, ARM v8, and SPARC VIII.
104 Compiler
105 ^^^^^^^^
107 |Gromacs| can be compiled on any platform with ANSI C99 and C++14
108 compilers, and their respective standard C/C++ libraries. Good
109 performance on an OS and architecture requires choosing a good
110 compiler. We recommend gcc, because it is free, widely available and
111 frequently provides the best performance.
113 You should strive to use the most recent version of your
114 compiler. Since we require full C++14 support the minimum supported
115 compiler versions are
117 * GNU (gcc) 5.1
118 * Intel (icc) 17.0.1
119 * LLVM (clang) 3.6
120 * Microsoft (MSVC) 2017
122 Other compilers may work (Cray, Pathscale, older clang) but do
123 not offer competitive performance. We recommend against PGI because
124 the performance with C++ is very bad.
126 The xlc compiler is not supported and version 16.1 does not compile on
127 POWER architectures for |Gromacs|\ -\ |version|. We recommend to use
128 the gcc compiler instead, as it is being extensively tested.
130 You may also need the most recent version of other compiler toolchain
131 components beside the compiler itself (e.g. assembler or linker);
132 these are often shipped by your OS distribution's binutils package.
134 C++14 support requires adequate support in both the compiler and the
135 C++ library. The gcc and MSVC compilers include their own standard
136 libraries and require no further configuration. If your vendor's
137 compiler also manages the standard library library via compiler flags,
138 these will be honored. For configuration of other compilers, read on.
140 On Linux, both the Intel and clang compiler use the libstdc++ which
141 comes with gcc as the default C++ library. For |Gromacs|, we require
142 the compiler to support libstc++ version 5.1 or higher. To select a
143 particular libstdc++ library, provide the path to g++ with
144 ``-DGMX_GPLUSPLUS_PATH=/path/to/g++``.
146 On Windows with the Intel compiler, the MSVC standard library is used,
147 and at least MSVC 2017 is required. Load the enviroment variables with
148 vcvarsall.bat.
150 To build with clang and llvm's libcxx standard library, use
151 ``-DCMAKE_CXX_FLAGS=-stdlib=libc++``.
153 If you are running on Mac OS X, the best option is the Intel
154 compiler. Both clang and gcc will work, but they produce lower
155 performance and each have some shortcomings. clang 3.8 now offers
156 support for OpenMP, and so may provide decent performance.
158 For all non-x86 platforms, your best option is typically to use gcc or
159 the vendor's default or recommended compiler, and check for
160 specialized information below.
162 For updated versions of gcc to add to your Linux OS, see
164 * Ubuntu: `Ubuntu toolchain ppa page`_
165 * RHEL/CentOS: `EPEL page`_ or the RedHat Developer Toolset
167 Compiling with parallelization options
168 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
170 For maximum performance you will need to examine how you will use
171 |Gromacs| and what hardware you plan to run on. Often OpenMP_
172 parallelism is an advantage for |Gromacs|, but support for this is
173 generally built into your compiler and detected automatically.
175 .. _gmx-gpu-support:
177 GPU support
178 ~~~~~~~~~~~
180 |Gromacs| has excellent support for NVIDIA GPUs supported via CUDA.
181 On Linux, NVIDIA CUDA_ toolkit with minimum version |REQUIRED_CUDA_VERSION|
182 is required, and the latest version is strongly encouraged. NVIDIA GPUs with at
183 least NVIDIA compute capability |REQUIRED_CUDA_COMPUTE_CAPABILITY| are
184 required. You are strongly recommended to
185 get the latest CUDA version and driver that supports your hardware, but
186 beware of possible performance regressions in newer CUDA versions on
187 older hardware.
188 While some CUDA compilers (nvcc) might not
189 officially support recent versions of gcc as the back-end compiler, we
190 still recommend that you at least use a gcc version recent enough to
191 get the best SIMD support for your CPU, since |Gromacs| always runs some
192 code on the CPU. It is most reliable to use the same C++ compiler
193 version for |Gromacs| code as used as the host compiler for nvcc.
195 To make it possible to use other accelerators, |Gromacs| also includes
196 OpenCL_ support. The minimum OpenCL version required is
197 |REQUIRED_OPENCL_MIN_VERSION| and only 64-bit implementations are supported.
198 The current OpenCL implementation is recommended for
199 use with GCN-based AMD GPUs, and on Linux we recommend the ROCm runtime.
200 Intel integrated GPUs are supported with the Neo drivers.
201 OpenCL is also supported with NVIDIA GPUs, but using
202 the latest NVIDIA driver (which includes the NVIDIA OpenCL runtime) is
203 recommended. Also note that there are performance limitations (inherent
204 to the NVIDIA OpenCL runtime).
205 It is not possible to configure both CUDA and OpenCL
206 support in the same build of |Gromacs|, nor to support both
207 Intel and other vendors' GPUs with OpenCL. A 64-bit implementation
208 of OpenCL is required and therefore OpenCL is only supported on 64-bit platforms.
210 .. _mpi-support:
212 MPI support
213 ~~~~~~~~~~~
215 |Gromacs| can run in parallel on multiple cores of a single
216 workstation using its built-in thread-MPI. No user action is required
217 in order to enable this.
219 If you wish to run in parallel on multiple machines across a network,
220 you will need to have
222 * an MPI library installed that supports the MPI 1.3
223   standard, and
224 * wrapper compilers that will compile code using that library.
226 To compile with MPI set your compiler to the normal (non-MPI) compiler
227 and add ``-DGMX_MPI=on`` to the cmake options. It is possible to set
228 the compiler to the MPI compiler wrapper but it is neither necessary
229 nor recommended.
231 The |Gromacs| team recommends OpenMPI_ version
232 1.6 (or higher), MPICH_ version 1.4.1 (or
233 higher), or your hardware vendor's MPI installation. The most recent
234 version of either of these is likely to be the best. More specialized
235 networks might depend on accelerations only available in the vendor's
236 library. LAM-MPI_ might work, but since it has
237 been deprecated for years, it is not supported.
239 For example, depending on your actual MPI library, use ``cmake
240 -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DGMX_MPI=on``.
243 CMake
244 ^^^^^
246 |Gromacs| builds with the CMake build system, requiring at least
247 version |CMAKE_MINIMUM_REQUIRED_VERSION|. You can check whether
248 CMake is installed, and what version it is, with ``cmake
249 --version``. If you need to install CMake, then first check whether
250 your platform's package management system provides a suitable version,
251 or visit the `CMake installation page`_ for pre-compiled binaries,
252 source code and installation instructions. The |Gromacs| team
253 recommends you install the most recent version of CMake you can.
255 .. _FFT support:
257 Fast Fourier Transform library
258 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
260 Many simulations in |Gromacs| make extensive use of fast Fourier
261 transforms, and a software library to perform these is always
262 required. We recommend FFTW_ (version 3 or higher only) or Intel
263 MKL_. The choice of library can be set with ``cmake
264 -DGMX_FFT_LIBRARY=<name>``, where ``<name>`` is one of ``fftw3``,
265 ``mkl``, or ``fftpack``. FFTPACK is bundled with |Gromacs| as a
266 fallback, and is acceptable if simulation performance is not a
267 priority. When choosing MKL, |Gromacs| will also use MKL for BLAS and
268 LAPACK (see `linear algebra libraries`_). Generally, there is no
269 advantage in using MKL with |Gromacs|, and FFTW is often faster.
270 With PME GPU offload support using CUDA, a GPU-based FFT library
271 is required. The CUDA-based GPU FFT library cuFFT is part of the
272 CUDA toolkit (required for all CUDA builds) and therefore no additional
273 software component is needed when building with CUDA GPU acceleration.
275 Using FFTW
276 ~~~~~~~~~~
278 FFTW_ is likely to be available for your platform via its package
279 management system, but there can be compatibility and significant
280 performance issues associated with these packages. In particular,
281 |Gromacs| simulations are normally run in "mixed" floating-point
282 precision, which is suited for the use of single precision in
283 FFTW. The default FFTW package is normally in double
284 precision, and good compiler options to use for FFTW when linked to
285 |Gromacs| may not have been used. Accordingly, the |Gromacs| team
286 recommends either
288 * that you permit the |Gromacs| installation to download and
289   build FFTW from source automatically for you (use
290   ``cmake -DGMX_BUILD_OWN_FFTW=ON``), or
291 * that you build FFTW from the source code.
293 If you build FFTW from source yourself, get the most recent version
294 and follow the `FFTW installation guide`_. Choose the precision for
295 FFTW (i.e. single/float vs. double) to match whether you will later
296 use mixed or double precision for |Gromacs|. There is no need to
297 compile FFTW with threading or MPI support, but it does no harm. On
298 x86 hardware, compile with *both* ``--enable-sse2`` and
299 ``--enable-avx`` for FFTW-3.3.4 and earlier. From FFTW-3.3.5, you
300 should also add ``--enable-avx2`` also. On Intel processors supporting
301 512-wide AVX, including KNL, add ``--enable-avx512`` also.
302 FFTW will create a fat library with codelets for all different instruction sets,
303 and pick the fastest supported one at runtime.
304 On ARM architectures with NEON SIMD support and IBM Power8 and later, you
305 definitely want version 3.3.5 or later,
306 and to compile it with ``--enable-neon`` and ``--enable-vsx``, respectively, for
307 SIMD support. If you are using a Cray, there is a special modified
308 (commercial) version of FFTs using the FFTW interface which can be
309 slightly faster.
311 Using MKL
312 ~~~~~~~~~
314 Use MKL bundled with Intel compilers by setting up the compiler
315 environment, e.g., through ``source /path/to/compilervars.sh intel64``
316 or similar before running CMake including setting
317 ``-DGMX_FFT_LIBRARY=mkl``.
319 If you need to customize this further, use
323     cmake -DGMX_FFT_LIBRARY=mkl \
324           -DMKL_LIBRARIES="/full/path/to/libone.so;/full/path/to/libtwo.so" \
325           -DMKL_INCLUDE_DIR="/full/path/to/mkl/include"
327 The full list and order(!) of libraries you require are found in Intel's MKL documentation for your system.
329 Using ARM Performance Libraries
330 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332 The ARM Performance Libraries provides FFT transforms implementation for ARM
333 architectures.
334 Preliminary support is provided for ARMPL in |Gromacs| through its FFTW-compatible API.
335 Assuming that the ARM HPC toolchain environment including the ARMPL paths
336 are set up (e.g. through loading the appropriate modules like
337 ``module load Module-Prefix/arm-hpc-compiler-X.Y/armpl/X.Y``) use the following cmake
338 options:
342     cmake -DGMX_FFT_LIBRARY=fftw3 \
343           -DFFTWF_LIBRARY="${ARMPL_DIR}/lib/libarmpl_lp64.so" \
344           -DFFTWF_INCLUDE_DIR=${ARMPL_DIR}/include
347 Other optional build components
348 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
350 * Run-time detection of hardware capabilities can be improved by
351   linking with hwloc, which is automatically enabled if detected.
352 * Hardware-optimized BLAS and LAPACK libraries are useful
353   for a few of the |Gromacs| utilities focused on normal modes and
354   matrix manipulation, but they do not provide any benefits for normal
355   simulations. Configuring these is discussed at
356   `linear algebra libraries`_.
357 * The built-in |Gromacs| trajectory viewer ``gmx view`` requires X11 and
358   Motif/Lesstif libraries and header files. You may prefer to use
359   third-party software for visualization, such as VMD_ or PyMol_.
360 * An external TNG library for trajectory-file handling can be used
361   by setting ``-DGMX_EXTERNAL_TNG=yes``, but TNG
362   |GMX_TNG_MINIMUM_REQUIRED_VERSION| is bundled in the |Gromacs|
363   source already.
364 * The lmfit library for Levenberg-Marquardt curve fitting is used in
365   |Gromacs|. Only lmfit |GMX_LMFIT_REQUIRED_VERSION| is supported.  A
366   reduced version of that library is bundled in the |Gromacs|
367   distribution, and the default build uses it. That default may be
368   explicitly enabled with ``-DGMX_USE_LMFIT=internal``. To use an
369   external lmfit library, set ``-DGMX_USE_LMFIT=external``, and adjust
370   ``CMAKE_PREFIX_PATH`` as needed.  lmfit support can be disabled with
371   ``-DGMX_USE_LMFIT=none``.
372 * zlib is used by TNG for compressing some kinds of trajectory data
373 * Building the |Gromacs| documentation is optional, and requires
374   ImageMagick, pdflatex, bibtex, doxygen, python 3.5, sphinx
375   |EXPECTED_SPHINX_VERSION|, and pygments.
376 * The |Gromacs| utility programs often write data files in formats
377   suitable for the Grace plotting tool, but it is straightforward to
378   use these files in other plotting programs, too.
379 * Set ``-DGMX_PYTHON_PACKAGE=ON`` when configuring |Gromacs| with CMake to
380   enable additional CMake targets for the gmxapi Python package and
381   sample_restraint package from the main |Gromacs| CMake build. This supports
382   additional testing and documentation generation.
384 Doing a build of |Gromacs|
385 --------------------------
387 This section will cover a general build of |Gromacs| with CMake_, but it
388 is not an exhaustive discussion of how to use CMake. There are many
389 resources available on the web, which we suggest you search for when
390 you encounter problems not covered here. The material below applies
391 specifically to builds on Unix-like systems, including Linux, and Mac
392 OS X. For other platforms, see the specialist instructions below.
394 .. _configure-cmake:
396 Configuring with CMake
397 ^^^^^^^^^^^^^^^^^^^^^^
399 CMake will run many tests on your system and do its best to work out
400 how to build |Gromacs| for you. If your build machine is the same as
401 your target machine, then you can be sure that the defaults and
402 detection will be pretty good. However, if you want to control aspects
403 of the build, or you are compiling on a cluster head node for back-end
404 nodes with a different architecture, there are a few things you
405 should consider specifying.
407 The best way to use CMake to configure |Gromacs| is to do an
408 "out-of-source" build, by making another directory from which you will
409 run CMake. This can be outside the source directory, or a subdirectory
410 of it. It also means you can never corrupt your source code by trying
411 to build it! So, the only required argument on the CMake command line
412 is the name of the directory containing the ``CMakeLists.txt`` file of
413 the code you want to build. For example, download the source tarball
414 and use
416 .. parsed-literal::
418     tar xfz gromacs-|version|.tgz
419     cd gromacs-|version|
420     mkdir build-gromacs
421     cd build-gromacs
422     cmake ..
424 You will see ``cmake`` report a sequence of results of tests and
425 detections done by the |Gromacs| build system. These are written to the
426 ``cmake`` cache, kept in ``CMakeCache.txt``. You can edit this file by
427 hand, but this is not recommended because you could make a mistake.
428 You should not attempt to move or copy this file to do another build,
429 because file paths are hard-coded within it. If you mess things up,
430 just delete this file and start again with ``cmake``.
432 If there is a serious problem detected at this stage, then you will see
433 a fatal error and some suggestions for how to overcome it. If you are
434 not sure how to deal with that, please start by searching on the web
435 (most computer problems already have known solutions!) and then
436 consult the gmx-users mailing list. There are also informational
437 warnings that you might like to take on board or not. Piping the
438 output of ``cmake`` through ``less`` or ``tee`` can be
439 useful, too.
441 Once ``cmake`` returns, you can see all the settings that were chosen
442 and information about them by using e.g. the curses interface
446     ccmake ..
448 You can actually use ``ccmake`` (available on most Unix platforms)
449 directly in the first step, but then
450 most of the status messages will merely blink in the lower part
451 of the terminal rather than be written to standard output. Most platforms
452 including Linux, Windows, and Mac OS X even have native graphical user interfaces for
453 ``cmake``, and it can create project files for almost any build environment
454 you want (including Visual Studio or Xcode).
455 Check out `running CMake`_ for
456 general advice on what you are seeing and how to navigate and change
457 things. The settings you might normally want to change are already
458 presented. You may make changes, then re-configure (using ``c``), so that it
459 gets a chance to make changes that depend on yours and perform more
460 checking. It may take several configuration passes to reach the desired
461 configuration, in particular if you need to resolve errors.
463 When you have reached the desired configuration with ``ccmake``, the
464 build system can be generated by pressing ``g``.  This requires that the previous
465 configuration pass did not reveal any additional settings (if it did, you need
466 to configure once more with ``c``).  With ``cmake``, the build system is generated
467 after each pass that does not produce errors.
469 You cannot attempt to change compilers after the initial run of
470 ``cmake``. If you need to change, clean up, and start again.
472 .. _non-standard location:
474 Where to install |Gromacs|
475 ~~~~~~~~~~~~~~~~~~~~~~~~~~
477 |Gromacs| is installed in the directory to which
478 ``CMAKE_INSTALL_PREFIX`` points. It may not be the source directory or
479 the build directory.  You require write permissions to this
480 directory. Thus, without super-user privileges,
481 ``CMAKE_INSTALL_PREFIX`` will have to be within your home directory.
482 Even if you do have super-user privileges, you should use them only
483 for the installation phase, and never for configuring, building, or
484 running |Gromacs|!
486 .. _cmake options:
488 Using CMake command-line options
489 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
491 Once you become comfortable with setting and changing options, you may
492 know in advance how you will configure |Gromacs|. If so, you can speed
493 things up by invoking ``cmake`` and passing the various options at once
494 on the command line. This can be done by setting cache variable at the
495 cmake invocation using ``-DOPTION=VALUE``. Note that some
496 environment variables are also taken into account, in particular
497 variables like ``CC`` and ``CXX``.
499 For example, the following command line
503     cmake .. -DGMX_GPU=ON -DGMX_MPI=ON -DCMAKE_INSTALL_PREFIX=/home/marydoe/programs
505 can be used to build with CUDA GPUs, MPI and install in a custom
506 location. You can even save that in a shell script to make it even
507 easier next time. You can also do this kind of thing with ``ccmake``,
508 but you should avoid this, because the options set with ``-D`` will not
509 be able to be changed interactively in that run of ``ccmake``.
511 .. _gmx-simd-support:
513 SIMD support
514 ~~~~~~~~~~~~
516 |Gromacs| has extensive support for detecting and using the SIMD
517 capabilities of many modern HPC CPU architectures. If you are building
518 |Gromacs| on the same hardware you will run it on, then you don't need
519 to read more about this, unless you are getting configuration warnings
520 you do not understand. By default, the |Gromacs| build system will
521 detect the SIMD instruction set supported by the CPU architecture (on
522 which the configuring is done), and thus pick the best
523 available SIMD parallelization supported by |Gromacs|. The build system
524 will also check that the compiler and linker used also support the
525 selected SIMD instruction set and issue a fatal error if they
526 do not.
528 Valid values are listed below, and the applicable value with the
529 largest number in the list is generally the one you should choose.
530 In most cases, choosing an inappropriate higher number will lead
531 to compiling a binary that will not run. However, on a number of
532 processor architectures choosing the highest supported value can
533 lead to performance loss, e.g. on Intel Skylake-X/SP and AMD Zen.
535 1. ``None`` For use only on an architecture either lacking SIMD,
536    or to which |Gromacs| has not yet been ported and none of the
537    options below are applicable.
538 2. ``SSE2`` This SIMD instruction set was introduced in Intel
539    processors in 2001, and AMD in 2003. Essentially all x86
540    machines in existence have this, so it might be a good choice if
541    you need to support dinosaur x86 computers too.
542 3. ``SSE4.1`` Present in all Intel core processors since 2007,
543    but notably not in AMD Magny-Cours. Still, almost all recent
544    processors support this, so this can also be considered a good
545    baseline if you are content with slow simulations and prefer
546    portability between reasonably modern processors.
547 4. ``AVX_128_FMA`` AMD Bulldozer, Piledriver (and later Family 15h) processors have this.
548 5. ``AVX_256`` Intel processors since Sandy Bridge (2011). While this
549    code will work on the  AMD Bulldozer and Piledriver processors, it is significantly less
550    efficient than the ``AVX_128_FMA`` choice above - do not be fooled
551    to assume that 256 is better than 128 in this case.
552 6. ``AVX2_128`` AMD Zen/Zen2 and Hygon Dhyana microarchitecture processors;
553    it will enable AVX2 with 3-way fused multiply-add instructions.
554    While these microarchitectures do support 256-bit AVX2 instructions,
555    hence ``AVX2_256`` is also supported, 128-bit will generally be faster,
556    in particular when the non-bonded tasks run on the CPU -- hence
557    the default ``AVX2_128``. With GPU offload however ``AVX2_256``
558    can be faster on Zen processors.
559 7. ``AVX2_256`` Present on Intel Haswell (and later) processors (2013),
560    and it will also enable Intel 3-way fused multiply-add instructions.
561 8. ``AVX_512`` Skylake-X desktop and Skylake-SP Xeon processors (2017);
562    it will generally be fastest on the higher-end desktop and server
563    processors with two 512-bit fused multiply-add units (e.g. Core i9
564    and Xeon Gold). However, certain desktop and server models
565    (e.g. Xeon Bronze and Silver) come with only one AVX512 FMA unit
566    and therefore on these processors ``AVX2_256`` is faster
567    (compile- and runtime checks try to inform about such cases).
568    Additionally, with GPU accelerated runs ``AVX2_256`` can also be
569    faster on high-end Skylake CPUs with both 512-bit FMA units enabled.
570 9. ``AVX_512_KNL`` Knights Landing Xeon Phi processors
571 10. ``Sparc64_HPC_ACE`` Fujitsu machines like the K computer have this.
572 11. ``IBM_VMX`` Power6 and similar Altivec processors have this.
573 12. ``IBM_VSX`` Power7, Power8, Power9 and later have this.
574 13. ``ARM_NEON`` 32-bit ARMv7 with NEON support.
575 14. ``ARM_NEON_ASIMD`` 64-bit ARMv8 and later.
577 The CMake configure system will check that the compiler you have
578 chosen can target the architecture you have chosen. mdrun will check
579 further at runtime, so if in doubt, choose the lowest number you
580 think might work, and see what mdrun says. The configure system also
581 works around many known issues in many versions of common HPC
582 compilers.
584 A further ``GMX_SIMD=Reference`` option exists, which is a special
585 SIMD-like implementation written in plain C that developers can use
586 when developing support in |Gromacs| for new SIMD architectures. It is
587 not designed for use in production simulations, but if you are using
588 an architecture with SIMD support to which |Gromacs| has not yet been
589 ported, you may wish to try this option instead of the default
590 ``GMX_SIMD=None``, as it can often out-perform this when the
591 auto-vectorization in your compiler does a good job. And post on the
592 |Gromacs| mailing lists, because |Gromacs| can probably be ported for new
593 SIMD architectures in a few days.
595 CMake advanced options
596 ~~~~~~~~~~~~~~~~~~~~~~
598 The options that are displayed in the default view of ``ccmake`` are
599 ones that we think a reasonable number of users might want to consider
600 changing. There are a lot more options available, which you can see by
601 toggling the advanced mode in ``ccmake`` on and off with ``t``. Even
602 there, most of the variables that you might want to change have a
603 ``CMAKE_`` or ``GMX_`` prefix. There are also some options that will be
604 visible or not according to whether their preconditions are satisfied.
606 .. _search for libraries, headers or programs:
608 Helping CMake find the right libraries, headers, or programs
609 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
611 If libraries are installed in non-default locations their location can
612 be specified using the following variables:
614 * ``CMAKE_INCLUDE_PATH`` for header files
615 * ``CMAKE_LIBRARY_PATH`` for libraries
616 * ``CMAKE_PREFIX_PATH`` for header, libraries and binaries
617   (e.g. ``/usr/local``).
619 The respective ``include``, ``lib``, or ``bin`` is
620 appended to the path. For each of these variables, a list of paths can
621 be specified (on Unix, separated with ":"). These can be set as
622 enviroment variables like:
626     CMAKE_PREFIX_PATH=/opt/fftw:/opt/cuda cmake ..
628 (assuming ``bash`` shell). Alternatively, these variables are also
629 ``cmake`` options, so they can be set like
630 ``-DCMAKE_PREFIX_PATH=/opt/fftw:/opt/cuda``.
632 The ``CC`` and ``CXX`` environment variables are also useful
633 for indicating to ``cmake`` which compilers to use. Similarly,
634 ``CFLAGS``/``CXXFLAGS`` can be used to pass compiler
635 options, but note that these will be appended to those set by
636 |Gromacs| for your build platform and build type. You can customize
637 some of this with advanced CMake options such as ``CMAKE_C_FLAGS``
638 and its relatives.
640 See also the page on `CMake environment variables`_.
642 .. _CUDA GPU acceleration:
644 CUDA GPU acceleration
645 ~~~~~~~~~~~~~~~~~~~~~
647 If you have the CUDA_ Toolkit installed, you can use ``cmake`` with:
651     cmake .. -DGMX_GPU=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
653 (or whichever path has your installation). In some cases, you might
654 need to specify manually which of your C++ compilers should be used,
655 e.g. with the advanced option ``CUDA_HOST_COMPILER``.
657 By default, code will be generated for the most common CUDA architectures.
658 However, to reduce build time and binary size we do not generate code for
659 every single possible architecture, which in rare cases (say, Tegra systems)
660 can result in the default build not being able to use some GPUs.
661 If this happens, or if you want to remove some architectures to reduce
662 binary size and build time, you can alter the target CUDA architectures.
663 This can be done either with the ``GMX_CUDA_TARGET_SM`` or
664 ``GMX_CUDA_TARGET_COMPUTE`` CMake variables, which take a semicolon delimited
665 string with the two digit suffixes of CUDA (virtual) architectures names, for
666 instance "35;50;51;52;53;60". For details, see the "Options for steering GPU
667 code generation" section of the nvcc man / help or Chapter 6. of the nvcc
668 manual.
670 The GPU acceleration has been tested on AMD64/x86-64 platforms with
671 Linux, Mac OS X and Windows operating systems, but Linux is the
672 best-tested and supported of these. Linux running on POWER 8, ARM v7 and v8
673 CPUs also works well.
675 Experimental support is available for compiling CUDA code, both for host and
676 device, using clang (version 6.0 or later).
677 A CUDA toolkit is still required but it is used only for GPU device code
678 generation and to link against the CUDA runtime library.
679 The clang CUDA support simplifies compilation and provides benefits for development
680 (e.g. allows the use code sanitizers in CUDA host-code).
681 Additionally, using clang for both CPU and GPU compilation can be beneficial
682 to avoid compatibility issues between the GNU toolchain and the CUDA toolkit.
683 clang for CUDA can be triggered using the ``GMX_CLANG_CUDA=ON`` CMake option.
684 Target architectures can be selected with  ``GMX_CUDA_TARGET_SM``,
685 virtual architecture code is always embedded for all requested architectures
686 (hence GMX_CUDA_TARGET_COMPUTE is ignored).
687 Note that this is mainly a developer-oriented feature and it is not recommended
688 for production use as the performance can be significantly lower than that
689 of code compiled with nvcc (and it has also received less testing).
690 However, note that since clang 5.0 the performance gap is only moderate
691 (at the time of writing, about 20% slower GPU kernels), so this version
692 could be considered in non performance-critical use-cases.
695 OpenCL GPU acceleration
696 ~~~~~~~~~~~~~~~~~~~~~~~
698 The primary targets of the |Gromacs| OpenCL support is accelerating
699 simulations on AMD and Intel hardware. For AMD, we target both
700 discrete GPUs and APUs (integrated CPU+GPU chips), and for Intel we
701 target the integrated GPUs found on modern workstation and mobile
702 hardware. The |Gromacs| OpenCL on NVIDIA GPUs works, but performance
703 and other limitations make it less practical (for details see the user guide).
705 To build |Gromacs| with OpenCL_ support enabled, two components are
706 required: the OpenCL_ headers and the wrapper library that acts
707 as a client driver loader (so-called ICD loader).
708 The additional, runtime-only dependency is the vendor-specific GPU driver
709 for the device targeted. This also contains the OpenCL_ compiler.
710 As the GPU compute kernels are compiled  on-demand at run time,
711 this vendor-specific compiler and driver is not needed for building |Gromacs|.
712 The former, compile-time dependencies are standard components,
713 hence stock versions can be obtained from most Linux distribution
714 repositories (e.g. ``opencl-headers`` and ``ocl-icd-libopencl1`` on Debian/Ubuntu).
715 Only the compatibility with the required OpenCL_ version |REQUIRED_OPENCL_MIN_VERSION|
716 needs to be ensured.
717 Alternatively, the headers and library can also be obtained from vendor SDKs
718 (e.g. `from AMD <http://developer.amd.com/appsdk>`_),
719 which must be installed in a path found in ``CMAKE_PREFIX_PATH`` (or via the environment
720 variables ``AMDAPPSDKROOT`` or ``CUDA_PATH``).
722 To trigger an OpenCL_ build the following CMake flags must be set
726     cmake .. -DGMX_GPU=ON -DGMX_USE_OPENCL=ON
728 To build with support for Intel integrated GPUs, it is required
729 to add ``-DGMX_OPENCL_NB_CLUSTER_SIZE=4`` to the cmake command line,
730 so that the GPU kernels match the characteristics of the hardware.
731 The `Neo driver <https://github.com/intel/compute-runtime/releases>`_
732 is recommended.
734 On Mac OS, an AMD GPU can be used only with OS version 10.10.4 and
735 higher; earlier OS versions are known to run incorrectly.
737 By default, any clFFT library on the system will be used with
738 |Gromacs|, but if none is found then the code will fall back on a
739 version bundled with |Gromacs|. To require |Gromacs| to link with an
740 external library, use
744     cmake .. -DGMX_GPU=ON -DGMX_USE_OPENCL=ON -DclFFT_ROOT_DIR=/path/to/your/clFFT -DGMX_EXTERNAL_CLFFT=TRUE
746 Static linking
747 ~~~~~~~~~~~~~~
749 Dynamic linking of the |Gromacs| executables will lead to a
750 smaller disk footprint when installed, and so is the default on
751 platforms where we believe it has been tested repeatedly and found to work.
752 In general, this includes Linux, Windows, Mac OS X and BSD systems.
753 Static binaries take more space, but on some hardware and/or under
754 some conditions they are necessary, most commonly when you are running a parallel
755 simulation using MPI libraries (e.g. Cray).
757 * To link |Gromacs| binaries statically against the internal |Gromacs|
758   libraries, set ``-DBUILD_SHARED_LIBS=OFF``.
759 * To link statically against external (non-system) libraries as well,
760   set ``-DGMX_PREFER_STATIC_LIBS=ON``. Note, that in
761   general ``cmake`` picks up whatever is available, so this option only
762   instructs ``cmake`` to prefer static libraries when both static and
763   shared are available. If no static version of an external library is
764   available, even when the aforementioned option is ``ON``, the shared
765   library will be used. Also note that the resulting binaries will
766   still be dynamically linked against system libraries on platforms
767   where that is the default. To use static system libraries,
768   additional compiler/linker flags are necessary, e.g. ``-static-libgcc
769   -static-libstdc++``.
770 * To attempt to link a fully static binary set
771   ``-DGMX_BUILD_SHARED_EXE=OFF``. This will prevent CMake from explicitly
772   setting any dynamic linking flags. This option also sets
773   ``-DBUILD_SHARED_LIBS=OFF`` and ``-DGMX_PREFER_STATIC_LIBS=ON`` by
774   default, but the above caveats apply. For compilers which don't
775   default to static linking, the required flags have to be specified. On
776   Linux, this is usually ``CFLAGS=-static CXXFLAGS=-static``.
778 gmxapi C++ API
779 ~~~~~~~~~~~~~~
781 For dynamic linking builds and on non-Windows platforms, an extra library and
782 headers are installed by setting ``-DGMXAPI=ON`` (default).
783 Build targets ``gmxapi-cppdocs`` and ``gmxapi-cppdocs-dev`` produce documentation in
784 ``docs/api-user`` and ``docs/api-dev``, respectively.
785 For more project information and use cases,
786 refer to the tracked :issue:`2585`,
787 associated GitHub `gmxapi <https://github.com/kassonlab/gmxapi>`_ projects,
788 or DOI `10.1093/bioinformatics/bty484 <https://doi.org/10.1093/bioinformatics/bty484>`_.
790 gmxapi is not yet tested on Windows or with static linking, but these use cases
791 are targeted for future versions.
793 Portability aspects
794 ~~~~~~~~~~~~~~~~~~~
796 A |Gromacs| build will normally not be portable, not even across
797 hardware with the same base instruction set, like x86. Non-portable
798 hardware-specific optimizations are selected at configure-time, such
799 as the SIMD instruction set used in the compute kernels. This
800 selection will be done by the build system based on the capabilities
801 of the build host machine or otherwise specified to ``cmake`` during
802 configuration.
804 Often it is possible to ensure portability by choosing the least
805 common denominator of SIMD support, e.g. SSE2 for x86, and ensuring
806 the you use ``cmake -DGMX_USE_RDTSCP=off`` if any of the target CPU
807 architectures does not support the ``RDTSCP`` instruction.  However, we
808 discourage attempts to use a single |Gromacs| installation when the
809 execution environment is heterogeneous, such as a mix of AVX and
810 earlier hardware, because this will lead to programs (especially
811 mdrun) that run slowly on the new hardware. Building two full
812 installations and locally managing how to call the correct one
813 (e.g. using a module system) is the recommended
814 approach. Alternatively, as at the moment the |Gromacs| tools do not
815 make strong use of SIMD acceleration, it can be convenient to create
816 an installation with tools portable across different x86 machines, but
817 with separate mdrun binaries for each architecture. To achieve this,
818 one can first build a full installation with the
819 least-common-denominator SIMD instruction set, e.g. ``-DGMX_SIMD=SSE2``,
820 then build separate mdrun binaries for each architecture present in
821 the heterogeneous environment. By using custom binary and library
822 suffixes for the mdrun-only builds, these can be installed to the
823 same location as the "generic" tools installation.
824 `Building just the mdrun binary`_ is possible by setting the
825 ``-DGMX_BUILD_MDRUN_ONLY=ON`` option.
827 Linear algebra libraries
828 ~~~~~~~~~~~~~~~~~~~~~~~~
830 As mentioned above, sometimes vendor BLAS and LAPACK libraries
831 can provide performance enhancements for |Gromacs| when doing
832 normal-mode analysis or covariance analysis. For simplicity, the text
833 below will refer only to BLAS, but the same options are available
834 for LAPACK. By default, CMake will search for BLAS, use it if it
835 is found, and otherwise fall back on a version of BLAS internal to
836 |Gromacs|. The ``cmake`` option ``-DGMX_EXTERNAL_BLAS=on`` will be set
837 accordingly. The internal versions are fine for normal use. If you
838 need to specify a non-standard path to search, use
839 ``-DCMAKE_PREFIX_PATH=/path/to/search``. If you need to specify a
840 library with a non-standard name (e.g. ESSL on Power machines
841 or ARMPL on ARM machines), then
842 set ``-DGMX_BLAS_USER=/path/to/reach/lib/libwhatever.a``.
844 If you are using Intel MKL_ for FFT, then the BLAS and
845 LAPACK it provides are used automatically. This could be
846 over-ridden with ``GMX_BLAS_USER``, etc.
848 On Apple platforms where the Accelerate Framework is available, these
849 will be automatically used for BLAS and LAPACK. This could be
850 over-ridden with ``GMX_BLAS_USER``, etc.
852 .. _installing with MiMiC:
854 Building with MiMiC QM/MM support
855 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
857 MiMiC QM/MM interface integration will require linking against MiMiC
858 communication library, that establishes the communication channel
859 between |Gromacs| and CPMD. The MiMiC Communication library can be
860 downloaded `here <https://gitlab.com/MiMiC-projects/CommLib>`__.
861 Compile and install it. Check that the installation folder of the
862 MiMiC library is added to CMAKE_PREFIX_PATH if it is installed in
863 non-standard location. Building QM/MM-capable version requires
864 double-precision version of |Gromacs| compiled with MPI support:
866 * ``-DGMX_DOUBLE=ON -DGMX_MPI -DGMX_MIMIC=ON``
868 .. _suffixes:
870 Changing the names of |Gromacs| binaries and libraries
871 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
873 It is sometimes convenient to have different versions of the same
874 |Gromacs| programs installed. The most common use cases have been single
875 and double precision, and with and without MPI. This mechanism can
876 also be used to install side-by-side multiple versions of mdrun
877 optimized for different CPU architectures, as mentioned previously.
879 By default, |Gromacs| will suffix programs and libraries for such builds
880 with ``_d`` for double precision and/or ``_mpi`` for MPI (and nothing
881 otherwise). This can be controlled manually with ``GMX_DEFAULT_SUFFIX
882 (ON/OFF)``, ``GMX_BINARY_SUFFIX`` (takes a string) and ``GMX_LIBS_SUFFIX``
883 (also takes a string). For instance, to set a custom suffix for
884 programs and libraries, one might specify:
888     cmake .. -DGMX_DEFAULT_SUFFIX=OFF -DGMX_BINARY_SUFFIX=_mod -DGMX_LIBS_SUFFIX=_mod
890 Thus the names of all programs and libraries will be appended with
891 ``_mod``.
893 Changing installation tree structure
894 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
896 By default, a few different directories under ``CMAKE_INSTALL_PREFIX`` are used
897 when when |Gromacs| is installed. Some of these can be changed, which is mainly
898 useful for packaging |Gromacs| for various distributions. The directories are
899 listed below, with additional notes about some of them. Unless otherwise noted,
900 the directories can be renamed by editing the installation paths in the main
901 CMakeLists.txt.
903 ``bin/``
904     The standard location for executables and some scripts.
905     Some of the scripts hardcode the absolute installation prefix, which needs
906     to be changed if the scripts are relocated.
907     The name of the directory can be changed using ``CMAKE_INSTALL_BINDIR`` CMake
908     variable.
909 ``include/gromacs/``
910     The standard location for installed headers.
911 ``lib/``
912     The standard location for libraries. The default depends on the system, and
913     is determined by CMake.
914     The name of the directory can be changed using ``CMAKE_INSTALL_LIBDIR`` CMake
915     variable.
916 ``lib/pkgconfig/``
917     Information about the installed ``libgromacs`` library for ``pkg-config`` is
918     installed here.  The ``lib/`` part adapts to the installation location of the
919     libraries.  The installed files contain the installation prefix as absolute
920     paths.
921 ``share/cmake/``
922     CMake package configuration files are installed here.
923 ``share/gromacs/``
924     Various data files and some documentation go here. The first part can
925     be changed using ``CMAKE_INSTALL_DATADIR``, and the second by using
926     ``GMX_INSTALL_DATASUBDIR`` Using these CMake variables is the preferred
927     way of changing the installation path for
928     ``share/gromacs/top/``, since the path to this directory is built into
929     ``libgromacs`` as well as some scripts, both as a relative and as an absolute
930     path (the latter as a fallback if everything else fails).
931 ``share/man/``
932     Installed man pages go here.
934 Compiling and linking
935 ^^^^^^^^^^^^^^^^^^^^^
937 Once you have configured with ``cmake``, you can build |Gromacs| with ``make``.
938 It is expected that this will always complete successfully, and
939 give few or no warnings. The CMake-time tests |Gromacs| makes on the settings
940 you choose are pretty extensive, but there are probably a few cases we
941 have not thought of yet. Search the web first for solutions to
942 problems, but if you need help, ask on gmx-users, being sure to
943 provide as much information as possible about what you did, the system
944 you are building on, and what went wrong. This may mean scrolling back
945 a long way through the output of ``make`` to find the first error
946 message!
948 If you have a multi-core or multi-CPU machine with ``N``
949 processors, then using
953     make -j N
955 will generally speed things up by quite a bit. Other build generator systems
956 supported by ``cmake`` (e.g. ``ninja``) also work well.
958 .. _building just the mdrun binary:
960 Building only mdrun
961 ~~~~~~~~~~~~~~~~~~~
963 This is now supported with the ``cmake`` option
964 ``-DGMX_BUILD_MDRUN_ONLY=ON``, which will build a different version of
965 ``libgromacs`` and the ``mdrun`` program.
966 Naturally, now ``make install`` installs only those
967 products. By default, mdrun-only builds will default to static linking
968 against |Gromacs| libraries, because this is generally a good idea for
969 the targets for which an mdrun-only build is desirable.
971 Installing |Gromacs|
972 ^^^^^^^^^^^^^^^^^^^^
974 Finally, ``make install`` will install |Gromacs| in the
975 directory given in ``CMAKE_INSTALL_PREFIX``. If this is a system
976 directory, then you will need permission to write there, and you
977 should use super-user privileges only for ``make install`` and
978 not the whole procedure.
980 .. _getting access to |Gromacs|:
982 Getting access to |Gromacs| after installation
983 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
985 |Gromacs| installs the script ``GMXRC`` in the ``bin``
986 subdirectory of the installation directory
987 (e.g. ``/usr/local/gromacs/bin/GMXRC``), which you should source
988 from your shell:
992     source /your/installation/prefix/here/bin/GMXRC
994 It will detect what kind of shell you are running and set up your
995 environment for using |Gromacs|. You may wish to arrange for your
996 login scripts to do this automatically; please search the web for
997 instructions on how to do this for your shell.
999 Many of the |Gromacs| programs rely on data installed in the
1000 ``share/gromacs`` subdirectory of the installation directory. By
1001 default, the programs will use the environment variables set in the
1002 ``GMXRC`` script, and if this is not available they will try to guess the
1003 path based on their own location.  This usually works well unless you
1004 change the names of directories inside the install tree. If you still
1005 need to do that, you might want to recompile with the new install
1006 location properly set, or edit the ``GMXRC`` script.
1008 |Gromacs| also installs a CMake toolchains file to help with building client
1009 software. For an installation at ``/your/installation/prefix/here``, toolchain
1010 files will be installed at
1011 ``/your/installation/prefix/here/share/cmake/gromacs${GMX_LIBS_SUFFIX}/gromacs-toolchain${GMX_LIBS_SUFFIX}.cmake``
1012 where ``${GMX_LIBS_SUFFIX}`` is :ref:`as documented above <suffixes>`.
1014 Testing |Gromacs| for correctness
1015 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1017 Since 2011, the |Gromacs| development uses an automated system where
1018 every new code change is subject to regression testing on a number of
1019 platforms and software combinations. While this improves
1020 reliability quite a lot, not everything is tested, and since we
1021 increasingly rely on cutting edge compiler features there is
1022 non-negligible risk that the default compiler on your system could
1023 have bugs. We have tried our best to test and refuse to use known bad
1024 versions in ``cmake``, but we strongly recommend that you run through
1025 the tests yourself. It only takes a few minutes, after which you can
1026 trust your build.
1028 The simplest way to run the checks is to build |Gromacs| with
1029 ``-DREGRESSIONTEST_DOWNLOAD``, and run ``make check``.
1030 |Gromacs| will automatically download and run the tests for you.
1031 Alternatively, you can download and unpack the |Gromacs|
1032 regression test suite |gmx-regressiontests-package| tarball yourself
1033 and use the advanced ``cmake`` option ``REGRESSIONTEST_PATH`` to
1034 specify the path to the unpacked tarball, which will then be used for
1035 testing. If the above does not work, then please read on.
1037 The regression tests are also available from the download_ section.
1038 Once you have downloaded them, unpack the tarball, source
1039 ``GMXRC`` as described above, and run ``./gmxtest.pl all``
1040 inside the regression tests folder. You can find more options
1041 (e.g. adding ``double`` when using double precision, or
1042 ``-only expanded`` to run just the tests whose names match
1043 "expanded") if you just execute the script without options.
1045 Hopefully, you will get a report that all tests have passed. If there
1046 are individual failed tests it could be a sign of a compiler bug, or
1047 that a tolerance is just a tiny bit too tight. Check the output files
1048 the script directs you too, and try a different or newer compiler if
1049 the errors appear to be real. If you cannot get it to pass the
1050 regression tests, you might try dropping a line to the gmx-users
1051 mailing list, but then you should include a detailed description of
1052 your hardware, and the output of ``gmx mdrun -version`` (which contains
1053 valuable diagnostic information in the header).
1055 A build with ``-DGMX_BUILD_MDRUN_ONLY`` cannot be tested with
1056 ``make check`` from the build tree, because most of the tests
1057 require a full build to run things like ``grompp``. To test such an
1058 mdrun fully requires installing it to the same location as a normal
1059 build of |Gromacs|, downloading the regression tests tarball manually
1060 as described above, sourcing the correct ``GMXRC`` and running the
1061 perl script manually. For example, from your |Gromacs| source
1062 directory:
1066     mkdir build-normal
1067     cd build-normal
1068     cmake .. -DCMAKE_INSTALL_PREFIX=/your/installation/prefix/here
1069     make -j 4
1070     make install
1071     cd ..
1072     mkdir build-mdrun-only
1073     cd build-mdrun-only
1074     cmake .. -DGMX_MPI=ON -DGMX_GPU=ON -DGMX_BUILD_MDRUN_ONLY=ON -DCMAKE_INSTALL_PREFIX=/your/installation/prefix/here
1075     make -j 4
1076     make install
1077     cd /to/your/unpacked/regressiontests
1078     source /your/installation/prefix/here/bin/GMXRC
1079     ./gmxtest.pl all -np 2
1081 If your mdrun program has been suffixed in a non-standard way, then
1082 the ``./gmxtest.pl -mdrun`` option will let you specify that name to the
1083 test machinery. You can use ``./gmxtest.pl -double`` to test the
1084 double-precision version. You can use ``./gmxtest.pl -crosscompiling``
1085 to stop the test harness attempting to check that the programs can
1086 be run. You can use ``./gmxtest.pl -mpirun srun`` if your command to
1087 run an MPI program is called ``srun``.
1089 The ``make check`` target also runs integration-style tests that may run
1090 with MPI if ``GMX_MPI=ON`` was set. To make these work with various possible
1091 MPI libraries, you may need to
1092 set the CMake variables ``MPIEXEC``, ``MPIEXEC_NUMPROC_FLAG``,
1093 ``MPIEXEC_PREFLAGS`` and ``MPIEXEC_POSTFLAGS`` so that
1094 ``mdrun-mpi-test_mpi`` would run on multiple ranks via the shell command
1098     ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NUMPROC} ${MPIEXEC_PREFLAGS} \
1099           mdrun-mpi-test_mpi ${MPIEXEC_POSTFLAGS} -otherflags
1101 A typical example for SLURM is
1105      cmake .. -DGMX_MPI=on -DMPIEXEC=srun -DMPIEXEC_NUMPROC_FLAG=-n -DMPIEXEC_PREFLAGS= -DMPIEXEC_POSTFLAGS=
1108 Testing |Gromacs| for performance
1109 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1111 We are still working on a set of benchmark systems for testing
1112 the performance of |Gromacs|. Until that is ready, we recommend that
1113 you try a few different parallelization options, and experiment with
1114 tools such as ``gmx tune_pme``.
1116 Validating |Gromacs| for source code modifications
1117 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1119 When building |Gromacs| from a release tarball, the build process automatically
1120 checks if any file contributing to the build process have been modified since they have
1121 been packed in the archive. This results in the marking of the version as either ``MODIFIED``
1122 (if the source files have been modified) or ``UNCHECKED`` (if no validation was possible, e.g.
1123 if no Python installation was found). The actual checking is performed by comparing a checksum
1124 stored in the release tarball against one generated by the ``createFileHash.py`` Python script
1125 during the build configuration. When running a |Gromacs| binary, the checksum is also printed
1126 in the log file, together with a message if there is a mismatch or no validation has been possible.
1128 This allows users to check whether the binary they are using was built from source code that is
1129 identical to the source code released by the |Gromacs| team. Thus unintentional modifications
1130 to the source code for building binaries that are used for running production simulations
1131 are easily detectable. Additionally, by manually setting a version tag using the
1132 GMX_VERSION_STRING_OF_FORK cmake option, users can mark a modified |Gromacs| release
1133 code with their custom version string suffix.
1135 Having difficulty?
1136 ^^^^^^^^^^^^^^^^^^
1138 You are not alone - this can be a complex task! If you encounter a
1139 problem with installing |Gromacs|, then there are a number of
1140 locations where you can find assistance. It is recommended that you
1141 follow these steps to find the solution:
1143 1. Read the installation instructions again, taking note that you
1144    have followed each and every step correctly.
1146 2. Search the |Gromacs| webpage_ and users emailing list for information
1147    on the error. Adding
1148    ``site:https://mailman-1.sys.kth.se/pipermail/gromacs.org_gmx-users``
1149    to a Google search may help filter better results.
1151 3. Search the internet using a search engine such as Google.
1153 4. Post to the |Gromacs| users emailing list gmx-users for
1154    assistance. Be sure to give a full description of what you have
1155    done and why you think it did not work. Give details about the
1156    system on which you are installing.  Copy and paste your command
1157    line and as much of the output as you think might be relevant -
1158    certainly from the first indication of a problem. In particular,
1159    please try to include at least the header from the mdrun logfile,
1160    and preferably the entire file.  People who might volunteer to help
1161    you do not have time to ask you interactive detailed follow-up
1162    questions, so you will get an answer faster if you provide as much
1163    information as you think could possibly help. High quality bug
1164    reports tend to receive rapid high quality answers.
1166 .. _gmx-special-build:
1168 Special instructions for some platforms
1169 ---------------------------------------
1171 Building on Windows
1172 ^^^^^^^^^^^^^^^^^^^
1174 Building on Windows using native compilers is rather similar to
1175 building on Unix, so please start by reading the above. Then, download
1176 and unpack the |Gromacs| source archive. Make a folder in which to do
1177 the out-of-source build of |Gromacs|. For example, make it within the
1178 folder unpacked from the source archive, and call it ``build-gromacs``.
1180 For CMake, you can either use the graphical user interface provided on
1181 Windows, or you can use a command line shell with instructions similar
1182 to the UNIX ones above. If you open a shell from within your IDE
1183 (e.g. Microsoft Visual Studio), it will configure the environment for
1184 you, but you might need to tweak this in order to get either a 32-bit
1185 or 64-bit build environment. The latter provides the fastest
1186 executable. If you use a normal Windows command shell, then you will
1187 need to either set up the environment to find your compilers and
1188 libraries yourself, or run the ``vcvarsall.bat`` batch script provided
1189 by MSVC (just like sourcing a bash script under Unix).
1191 With the graphical user interface, you will be asked about what
1192 compilers to use at the initial configuration stage, and if you use
1193 the command line they can be set in a similar way as under UNIX.
1195 Unfortunately ``-DGMX_BUILD_OWN_FFTW=ON`` (see `Using FFTW`_) does not
1196 work on Windows, because there is no supported way to build FFTW on
1197 Windows. You can either build FFTW some other way (e.g. MinGW), or
1198 use the built-in fftpack (which may be slow), or `using MKL`_.
1200 For the build, you can either load the generated solutions file into
1201 e.g. Visual Studio, or use the command line with ``cmake --build`` so
1202 the right tools get used.
1204 Building on Cray
1205 ^^^^^^^^^^^^^^^^
1207 |Gromacs| builds mostly out of the box on modern Cray machines, but
1208 you may need to specify the use of static binaries with
1209 ``-DGMX_BUILD_SHARED_EXE=off``, and you may need to set the F77
1210 environmental variable to ``ftn`` when compiling FFTW.
1211 The ARM ThunderX2 Cray XC50 machines differ only in that the recommended
1212 compiler is the ARM HPC Compiler (``armclang``).
1215 Building on Solaris
1216 ^^^^^^^^^^^^^^^^^^^
1218 The built-in |Gromacs| processor detection does not work on Solaris,
1219 so it is strongly recommended that you build |Gromacs| with
1220 ``-DGMX_HWLOC=on`` and ensure that the ``CMAKE_PREFIX_PATH`` includes
1221 the path where the hwloc headers and libraries can be found. At least
1222 version 1.11.8 of hwloc is recommended.
1224 Oracle Developer Studio is not a currently supported compiler (and
1225 does not currently compile |Gromacs| correctly, perhaps because the
1226 thread-MPI atomics are incorrectly implemented in |Gromacs|).
1228 Fujitsu PRIMEHPC
1229 ^^^^^^^^^^^^^^^^
1231 This is the architecture of the K computer, which uses Fujitsu
1232 Sparc64VIIIfx chips. On this platform, |Gromacs| has
1233 accelerated group kernels using the HPC-ACE instructions, no
1234 accelerated Verlet kernels, and a custom build toolchain. Since this
1235 particular chip only does double precision SIMD, the default setup
1236 is to build |Gromacs| in double. Since most users only need single, we have added
1237 an option GMX_RELAXED_DOUBLE_PRECISION to accept single precision square root
1238 accuracy in the group kernels; unless you know that you really need 15 digits
1239 of accuracy in each individual force, we strongly recommend you use this. Note
1240 that all summation and other operations are still done in double.
1242 The recommended configuration is to use
1246     cmake .. -DCMAKE_TOOLCHAIN_FILE=Toolchain-Fujitsu-Sparc64-mpi.cmake \
1247              -DCMAKE_PREFIX_PATH=/your/fftw/installation/prefix \
1248              -DCMAKE_INSTALL_PREFIX=/where/gromacs/should/be/installed \
1249              -DGMX_MPI=ON \
1250              -DGMX_BUILD_MDRUN_ONLY=ON \
1251              -DGMX_RELAXED_DOUBLE_PRECISION=ON
1252     make
1253     make install
1255 Intel Xeon Phi
1256 ^^^^^^^^^^^^^^
1258 Xeon Phi processors, hosted or self-hosted, are supported.
1259 Only symmetric (aka native) mode is supported on Knights Corner. The
1260 performance depends among other factors on the system size, and for
1261 now the performance might not be faster than CPUs. When building for it,
1262 the recommended configuration is
1266     cmake .. -DCMAKE_TOOLCHAIN_FILE=Platform/XeonPhi
1267     make
1268     make install
1271 The Knights Landing-based Xeon Phi processors behave like standard x86 nodes,
1272 but support a special SIMD instruction set. When cross-compiling for such nodes,
1273 use the ``AVX_512_KNL`` SIMD flavor.
1274 Knights Landing processors support so-called "clustering modes" which
1275 allow reconfiguring the memory subsystem for lower latency. |Gromacs| can
1276 benefit from the quadrant or SNC clustering modes.
1277 Care needs to be taken to correctly pin threads. In particular, threads of
1278 an MPI rank should not cross cluster and NUMA boundaries.
1279 In addition to the main DRAM memory, Knights Landing has a high-bandwidth
1280 stacked memory called MCDRAM. Using it offers performance benefits if
1281 it is ensured that ``mdrun`` runs entirely from this memory; to do so
1282 it is recommended that MCDRAM is configured in "Flat mode" and ``mdrun`` is
1283 bound to the appropriate NUMA node (use e.g. ``numactl --membind 1`` with
1284 quadrant clustering mode).
1287 Tested platforms
1288 ----------------
1290 While it is our best belief that |Gromacs| will build and run pretty
1291 much everywhere, it is important that we tell you where we really know
1292 it works because we have tested it.
1293 Every commit in our git source code repository
1294 is currently tested with a range of configuration options on x86 with
1295 gcc versions 6 and 7,
1296 clang versions 3.6 and 8,
1298 For this testing, we use Ubuntu 16.04 or 18.04 operating system.
1299 Other compiler, library, and OS versions are tested less frequently.
1300 For details, you can
1301 have a look at the `continuous integration server used by GROMACS`_,
1302 which uses GitLab runner on a local k8s x86 cluster with NVIDIA and
1303 AMD GPU support.
1305 We test irregularly on ARM v7, ARM v8, Cray, Fujitsu
1306 PRIMEHPC, Power8, Power9,
1307 Google Native Client and other environments, and
1308 with other compilers and compiler versions, too.