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