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