Convert install guide to markdown
[alexxy/gromacs.git] / install-guide / install-guide.md
1 % Installation guide for GROMACS @PROJECT_VERSION@
2
3 # Building GROMACS #
4
5 These instructions pertain to building GROMACS
6 @PROJECT_VERSION@. Up-to-date installation instructions may be found
7 at <http://www.gromacs.org/Documentation/Installation_Instructions>.
8
9 # Quick and dirty installation #
10
11 1. Get the latest version of your C and C++ compilers.
12 2. Check that you have CMake version @GMX_CMAKE_MINIMUM_REQUIRED_VERSION@ or later.
13 3. Get and unpack the latest version of the GROMACS tarball.
14 4. Make a separate build directory and change to it. 
15 5. Run `cmake` with the path to the source as an argument
16 6. Run `make` and `make install`
17
18 Or, as a sequence of commands to execute:
19
20     tar xfz gromacs-@PROJECT_VERSION@.tar.gz
21     cd gromacs-@PROJECT_VERSION@
22     mkdir build
23     cd build
24     cmake .. -DGMX_BUILD_OWN_FFTW=ON
25     make
26     sudo make install
27     source /usr/local/gromacs/bin/GMXRC
28
29 This will download and build first the prerequisite FFT library
30 followed by GROMACS. If you already have FFTW installed, you can
31 remove that argument to `cmake`. Overall, this build of GROMACS will
32 be correct and reasonably fast on the machine upon which `cmake`
33 ran. If you want to get the maximum value for your hardware with
34 GROMACS, you will have to read further. Sadly, the interactions of
35 hardware, libraries, and compilers are only going to continue to get
36 more complex.
37
38 # Typical GROMACS installation #
39
40 As above, and with further details below, but you should consider
41 using the following [CMake options](#using-cmake-command-line-options) with the
42 appropriate value instead of `xxx` :
43
44 * `-DCMAKE_C_COMPILER=xxx` equal to the name of the C99 [compiler](#compiler) you wish to use (or the environment variable `CC`)
45 * `-DCMAKE_CXX_COMPILER=xxx` equal to the name of the C++98 [compiler](#compiler) you wish to use (or the environment variable `CXX`)
46 * `-DGMX_MPI=on` to build using an [MPI](#mpi-support) wrapper compiler
47 * `-DGMX_GPU=on` to build using nvcc to run with an NVIDIA [GPU](#native-gpu-acceleration)
48 * `-DGMX_SIMD=xxx` to specify the level of [SIMD support](#simd-support) of the node on which `mdrun` will run
49 * `-DGMX_BUILD_MDRUN_ONLY=on` to [build only the `mdrun` binary](#building-only-mdrun), e.g. for compute cluster back-end nodes
50 * `-DGMX_DOUBLE=on` to run GROMACS in double precision (slower, and not normally useful)
51 * `-DCMAKE_PREFIX_PATH=xxx` to add a non-standard location for CMake to [search for libraries](#helping-cmake-find-the-right-librariesheadersprograms)
52 * `-DCMAKE_INSTALL_PREFIX=xxx` to install GROMACS to a non-standard location (default `/usr/local/gromacs`)
53 * `-DBUILD_SHARED_LIBS=off` to turn off the building of [shared libraries](#static-linking)
54 * `-DGMX_FFT_LIBRARY=xxx` to select whether to use `fftw`, `mkl` or `fftpack` libraries for [FFT support](#fast-fourier-transform-library)
55 * `-DCMAKE_BUILD_TYPE=Debug` to build GROMACS in debug mode
56
57 # Building older GROMACS versions #
58
59 For installation instructions for old GROMACS versions, see the
60 documentation at
61 <http://www.gromacs.org/Documentation/Installation_Instructions_4.5>
62 and
63 <http://www.gromacs.org/Documentation/Installation_Instructions_4.6>
64
65 # Prerequisites #
66
67 ## Platform ##
68
69 GROMACS can be compiled for many operating systems and architectures.
70 These include any distribution of Linux, Mac OS X or Windows, and
71 architectures including x86, AMD64/x86-64, PPC, ARM v7 and SPARC VIII.
72
73 ## Compiler ##
74
75 Technically, GROMACS can be compiled on any platform with an ANSI C99
76 and C++98 compiler, and their respective standard C/C++ libraries.
77 Getting good performance on an OS and architecture requires choosing a
78 good compiler. In practice, many compilers struggle to do a good job
79 optimizing the GROMACS architecture-optimized SIMD kernels.
80
81 For best performance, the GROMACS team strongly recommends you get the
82 most recent version of your preferred compiler for your platform.
83 There is a large amount of GROMACS code that depends on effective
84 compiler optimization to get high performance. This makes GROMACS
85 performance sensitive to the compiler used, and the binary will often
86 only work on the hardware for which it is compiled.
87
88 * In particular, GROMACS includes a lot of explicit SIMD
89 (single instruction, multiple data) optimization that can use
90 assembly instructions available on most modern processors. This
91 can have a substantial effect on performance, but for recent
92 processors you also need a similarly recent compiler that includes
93 support for the corresponding SIMD instruction set to get this
94 benefit. The configuration does a good job at detecting this,
95 and you will usually get warnings if GROMACS and your hardware
96 support a more recent instruction set than your compiler.
97
98 * On Intel-based x86 hardware, we recommend you to use the GNU
99 compilers version 4.7 or later or Intel compilers version 12 or later
100 for best performance. The Intel compiler has historically been better
101 at instruction scheduling, but recent gcc versions have proved to be
102 as fast or sometimes faster than Intel.
103
104 * The Intel and GNU compilers produce much faster GROMACS executables
105 than the PGI and Cray compilers.
106
107 * On AMD-based x86 hardware up through the "K10" microarchitecture
108 ("Family 10h") Thuban/Magny-Cours architecture (e.g. Opteron
109 6100-series processors), it is worth using the Intel compiler for
110 better performance, but gcc version 4.7 and later are also reasonable.
111
112 * On the AMD Bulldozer architecture (Opteron 6200), AMD introduced
113 fused multiply-add instructions and an "FMA4" instruction format not
114 available on Intel x86 processors. Thus, on the most recent AMD
115 processors you want to use gcc version 4.7 or later for best
116 performance! The Intel compiler will only generate code for the subset
117 also supported by Intel processors, and that is significantly slower.
118
119 * If you are running on Mac OS X, the best option is the Intel
120 compiler. Both clang and gcc will work, but they produce lower
121 performance and each have some shortcomings. Current Clang does not
122 support OpenMP. This may change when clang 3.5 becomes available.
123
124 * For all non-x86 platforms, your best option is typically to use the
125 vendor's default or recommended compiler, and check for specialized
126 information below.
127
128 ## Compiling with parallelization options ##
129
130 GROMACS can run in parallel on multiple cores of a single
131 workstation using its built-in thread-MPI. No user action is required
132 in order to enable this.
133
134 ### GPU support ###
135
136 If you wish to use the excellent native GPU support in GROMACS,
137 NVIDIA's [CUDA](http://www.nvidia.com/object/cuda_home_new.html)
138 version @REQUIRED_CUDA_VERSION@ software development kit is required,
139 and the latest version is strongly encouraged. NVIDIA GPUs with at
140 least NVIDIA compute capability @REQUIRED_CUDA_COMPUTE_CAPABILITY@ are
141 required, e.g. Fermi or Kepler cards. You are strongly recommended to
142 get the latest CUDA version and driver supported by your hardware, but
143 beware of possible performance regressions in newer CUDA versions on
144 older hardware. Note that while some CUDA compilers (nvcc) might not
145 officially support recent versions of gcc as the back-end compiler, we
146 still recommend that you at least use a gcc version recent enough to
147 get the best SIMD support for your CPU, since GROMACS always runs some
148 code on the CPU. It is most reliable to use the same C++ compiler
149 version for GROMACS code as used as the back-end compiler for nvcc,
150 but it could be faster to mix compiler versions to suit particular
151 contexts.
152
153 ### MPI support ###
154
155 If you wish to run in parallel on multiple machines across a network,
156 you will need to have
157
158 * an MPI library installed that supports the MPI 1.3
159   standard, and
160 * wrapper compilers that will compile code using that library.
161
162 The GROMACS team recommends [OpenMPI](http://www.open-mpi.org) version
163 1.6 (or higher), [MPICH](http://www.mpich.org) version 1.4.1 (or
164 higher), or your hardware vendor's MPI installation. The most recent
165 version of either of these is likely to be the best. More specialized
166 networks might depend on accelerations only available in the vendor's
167 library. [LAMMPI](http://www.lam-mpi.org) might work, but since it has
168 been deprecated for years, it is not supported.
169
170 Often [OpenMP](http://en.wikipedia.org/wiki/OpenMP) parallelism is an
171 advantage for GROMACS, but support for this is generally built into
172 your compiler and detected automatically.
173
174 In summary, for maximum performance you will need to examine how you
175 will use GROMACS, what hardware you plan to run on, and whether you
176 can afford a non-free compiler for slightly better
177 performance. Unfortunately, the only way to find out is to test
178 different options and parallelization schemes for the actual
179 simulations you want to run. You will still get *good*,
180 performance with the default build and runtime options, but if you
181 truly want to push your hardware to the performance limit, the days of
182 just blindly starting programs with `mdrun` are gone.
183
184 ## CMake ##
185
186 GROMACS @PROJECT_VERSION@ uses the CMake build system, and requires
187 version @GMX_CMAKE_MINIMUM_REQUIRED_VERSION@ or higher. Lower versions
188 will not work. You can check whether CMake is installed, and what
189 version it is, with `cmake --version`. If you need to install CMake,
190 then first check whether your platform's package management system
191 provides a suitable version, or visit
192 <http://www.cmake.org/cmake/help/install.html> for pre-compiled
193 binaries, source code and installation instructions. The GROMACS team
194 recommends you install the most recent version of CMake you can.
195
196 ## Fast Fourier Transform library ##
197
198 Many simulations in GROMACS make extensive use of fast Fourier
199 transforms, and a software library to perform these is always
200 required. We recommend [FFTW](http://www.fftw.org) (version 3 or
201 higher only) or
202 [Intel MKL](http://software.intel.com/en-us/intel-mkl). The choice of
203 library can be set with `cmake -DGMX_FFT_LIBRARY=<name>`, where
204 `<name>` is one of `fftw`, `mkl`, or `fftpack`. FFTPACK is bundled
205 with GROMACS as a fallback, and is acceptable if mdrun performance is
206 not a priority.
207
208 ### FFTW ###
209
210 FFTW is likely to be available for your platform via its package
211 management system, but there can be compatibility and significant
212 performance issues associated with these packages. In particular,
213 GROMACS simulations are normally run in single floating-point
214 precision whereas the default FFTW package is normally in double
215 precision, and good compiler options to use for FFTW when linked to
216 GROMACS may not have been used. Accordingly, the GROMACS team
217 recommends either
218
219 * that you permit the GROMACS installation to download and
220   build FFTW from source automatically for you (use
221   `cmake -DGMX_BUILD_OWN_FFTW=ON`), or
222 * that you build FFTW from the source code.
223
224 Note that the GROMACS-managed download of the FFTW tarball has a
225 slight chance of posing a security risk. If you use this option, you
226 will see a warning that advises how you can eliminate this risk
227 (before the opportunity has arisen).
228
229 If you build FFTW from source yourself, get the most recent version
230 and follow its [installation
231 guide](http://www.fftw.org/doc/Installation-and-Customization.html#Installation-and-Customization).
232 Choose the precision (i.e. single or float vs. double) to match what
233 you will later require for GROMACS. There is no need to compile with
234 threading or MPI support, but it does no harm. On x86 hardware,
235 compile *only* with `--enable-sse2` (regardless of precision) even if
236 your processors can take advantage of AVX extensions. Since GROMACS
237 uses fairly short transform lengths we do not benefit from the FFTW
238 AVX acceleration, and because of memory system performance
239 limitations, it can even degrade GROMACS performance by around
240 20%. There is no way for GROMACS to limit the use to SSE2 SIMD at run
241 time if AVX support has been compiled into FFTW, so you need to set
242 this at compile time.
243
244 ### MKL ###
245
246 Using MKL with the Intel Compilers version 11 or higher is very
247 simple. Set up your compiler environment correctly, perhaps with a
248 command like `source /path/to/compilervars.sh intel64` (or consult
249 your local documentation). Then set `-DGMX_FFT_LIBRARY=mkl` when you
250 run cmake. In this case, GROMACS will also use MKL for BLAS and LAPACK
251 (see
252 [linear algebra libraries](#linear-algebra-libraries)). Generally,
253 there is no advantage in using MKL with GROMACS, and FFTW is often
254 faster.
255
256 Otherwise, you can get your hands dirty and configure MKL by setting
257
258     -DGMX_FFT_LIBRARY=mkl
259     -DMKL_LIBRARIES="/full/path/to/libone.so;/full/path/to/libtwo.so"
260     -DMKL_INCLUDE_DIR="/full/path/to/mkl/include"
261
262 where the full list (and order!) of libraries you require are found in
263 Intel's MKL documentation for your system.
264
265 ## Optional build components ##
266
267 * Compiling to run on NVIDIA GPUs requires CUDA
268 * An external Boost library can be used to provide better
269   implementation support for smart pointers and exception handling,
270   but the GROMACS source bundles a subset of Boost 1.55.0 as a fallback
271 * Hardware-optimized BLAS and LAPACK libraries are useful
272   for a few of the GROMACS utilities focused on normal modes and
273   matrix manipulation, but they do not provide any benefits for normal
274   simulations. Configuring these are discussed at
275   [linear algebra libraries](#linear-algebra-libraries).
276 * The built-in GROMACS trajectory viewer `gmx view` requires X11 and
277   Motif/Lesstif libraries and header files. You may prefer to use
278   third-party software for visualization, such as
279   [VMD](http://www.ks.uiuc.edu/Research/vmd) or
280   [PyMOL](http://www.pymol.org).
281 * An external TNG library for trajectory-file handling can be used,
282   but TNG 1.6 is bundled in the GROMACS source already
283 * zlib is used by TNG for compressing some kinds of trajectory data
284 * Running the GROMACS test suite requires libxml2
285 * Building the GROMACS documentation requires ImageMagick, pdflatex,
286   bibtex, doxygen and pandoc.
287 * The GROMACS utility programs often write data files in formats
288   suitable for the Grace plotting tool, but it is straightforward to
289   use these files in other plotting programs, too.
290
291 # Doing a build of GROMACS #
292
293 This section will cover a general build of GROMACS with CMake, but it
294 is not an exhaustive discussion of how to use CMake. There are many
295 resources available on the web, which we suggest you search for when
296 you encounter problems not covered here. The material below applies
297 specifically to builds on Unix-like systems, including Linux, and Mac
298 OS X. For other platforms, see the specialist instructions below.
299
300 ## Configuring with CMake ##
301
302 CMake will run many tests on your system and do its best to work out
303 how to build GROMACS for you. If your build machine is the same as
304 your target machine, then you can be sure that the defaults will be
305 pretty good. The build configuration will for instance attempt to
306 detect the specific hardware instructions available in your
307 processor. However, if you want to control aspects of the build, or
308 you are compiling on a cluster head node for back-end nodes with a
309 different architecture, there are plenty of things you can set
310 manually.
311
312 The best way to use CMake to configure GROMACS is to do an
313 "out-of-source" build, by making another directory from which you will
314 run CMake. This can be outside the source directory, or a subdirectory
315 of it. It also means you can never corrupt your source code by trying
316 to build it! So, the only required argument on the CMake command line
317 is the name of the directory containing the `CMakeLists.txt` file of
318 the code you want to build. For example, download the source tarball
319 and use
320
321     $ tar xfz gromacs-@PROJECT_VERSION@.tgz
322     $ cd gromacs-@PROJECT_VERSION@
323     $ mkdir build-gromacs
324     $ cd build-gromacs
325     $ cmake ..
326
327 You will see `cmake` report a sequence of results of tests and
328 detections done by the GROMACS build system. These are written to the
329 `cmake` cache, kept in `CMakeCache.txt`. You can edit this file by
330 hand, but this is not recommended because you could make a mistake.
331 You should not attempt to move or copy this file to do another build,
332 because file paths are hard-coded within it. If you mess things up,
333 just delete this file and start again with `cmake`.
334
335 If there is a serious problem detected at this stage, then you will see
336 a fatal error and some suggestions for how to overcome it. If you are
337 not sure how to deal with that, please start by searching on the web
338 (most computer problems already have known solutions!) and then
339 consult the gmx-users mailing list. There are also informational
340 warnings that you might like to take on board or not. Piping the
341 output of `cmake` through `less` or `tee` can be
342 useful, too.
343
344 Once `cmake` returns, you can see all the settings that were chosen
345 and information about them by using e.g. the curses interface
346
347     $ ccmake ..
348
349 You can actually use `ccmake` (available on most Unix platforms,
350 if the curses library is supported) directly in the first step, but then
351 most of the status messages will merely blink in the lower part
352 of the terminal rather than be written to standard out. Most platforms
353 including Linux, Windows, and Mac OS X even have native graphical user interfaces for
354 `cmake`, and it can create project files for almost any build environment
355 you want (including Visual Studio or Xcode).
356 Check out <http://www.cmake.org/cmake/help/runningcmake.html> for
357 general advice on what you are seeing and how to navigate and change
358 things. The settings you might normally want to change are already
359 presented. You may make changes, then re-configure (using `c`), so that it
360 gets a chance to make changes that depend on yours and perform more
361 checking. This might require several configuration stages when you are
362 using `ccmake` - when you are using `cmake` the
363 iteration is done behind the scenes.
364
365 A key thing to consider here is the setting of
366 `CMAKE_INSTALL_PREFIX`. You will need to be able to write to this
367 directory in order to install GROMACS later, and if you change your
368 mind later, changing it in the cache triggers a full re-build,
369 unfortunately. So if you do not have super-user privileges on your
370 machine, then you will need to choose a sensible location within your
371 home directory for your GROMACS installation. Even if you do have
372 super-user privileges, you should use them only for the installation
373 phase, and never for configuring, building, or running GROMACS!
374
375 When `cmake` or `ccmake` have completed iterating, the
376 cache is stable and a build tree can be generated, with `g` in
377 `ccmake` or automatically with `cmake`.
378
379 You cannot attempt to change compilers after the initial run of
380 `cmake`. If you need to change, clean up, and start again.
381
382 ### Using CMake command-line options ###
383
384 Once you become comfortable with setting and changing options, you may
385 know in advance how you will configure GROMACS. If so, you can speed
386 things up by invoking `cmake` and passing the various options at once
387 on the command line. This can be done by setting cache variable at the
388 cmake invocation using the `-DOPTION=VALUE`; note that some
389 environment variables are also taken into account, in particular
390 variables like CC, CXX, FCC (which may be familiar to autoconf users).
391
392 For example, the following command line
393
394     $ cmake .. -DGMX_GPU=ON -DGMX_MPI=ON -DCMAKE_INSTALL_PREFIX=/home/marydoe/programs
395
396 can be used to build with GPUs, MPI and install in a custom
397 location. You can even save that in a shell script to make it even
398 easier next time. You can also do this kind of thing with `ccmake`,
399 but you should avoid this, because the options set with `-D` will not
400 be able to be changed interactively in that run of `ccmake`.
401
402 ### SIMD support ###
403
404 GROMACS has extensive support for detecting and using the SIMD
405 capabilities of many modern HPC CPU architectures. If you are building
406 GROMACS on the same hardware you will run it on, then you don't need
407 to read more about this, unless you are getting configuration warnings
408 you do not understand. By default, the GROMACS build system will
409 detect the SIMD instruction set supported by the CPU architecture (on
410 which the configuring is done), and thus pick the best
411 available SIMD parallelization supported by GROMACS. The build system
412 will also check that the compiler and linker used also support the
413 selected SIMD instruction set and issue a fatal error if they
414 do not.
415
416 Valid values are listed below, and the
417 applicable value lowest on the list is generally the one you should
418 choose:
419
420 1. `None` For use only on an architecture either lacking SIMD,
421   or to which GROMACS has not yet been ported and none of the
422   options below are applicable.
423 2. `SSE2` This SIMD instruction set was introduced in Intel
424    processors in 2001, and AMD in 2003. Essentially all x86
425    machines in existence have this, so it might be a good choice if
426    you need to support dinosaur x86 computers too.
427 3. `SSE4.1` Present in all Intel core processors since 2007,
428    but notably not in AMD magny-cours. Still, almost all recent
429    processors support this, so this can also be considered a good
430    baseline if you are content with portability between reasonably
431    modern processors.
432 4. `AVX_128_FMA` AMD bulldozer processors (2011) have this.
433    Unfortunately Intel and AMD have diverged the last few years;
434    If you want good performance on modern AMD processors
435    you have to use this since it also allows the reset of the
436    code to use AMD 4-way fused multiply-add instructions. The drawback
437    is that your code will not run on Intel processors at all.
438 5. `AVX_256` This instruction set is present on Intel processors
439    since Sandy Bridge (2011), where it is the best choice unless
440    you have an even more recent CPU that supports AVX2. While this
441    code will work on recent AMD processors, it is significantly
442    less efficient than the AVX_128_FMA choice above - do not be
443    fooled to assume that 256 is better than 128 in this case.
444 6. `AVX2_256` Present on Intel Haswell processors released in 2013,
445    and it will also enable Intel 3-way fused multiply-add instructions.
446    This code will not work on AMD CPUs.
447 7. `IBM_QPX ` BlueGene/Q A2 cores have this.
448 8. `Sparc64_HPC_ACE` Fujitsu machines like the K computer have this.
449
450 The CMake configure system will check that the compiler you have
451 chosen can target the architecture you have chosen. `mdrun` will check
452 further at runtime, so if in doubt, choose the lowest setting you
453 think might work, and see what `mdrun` says. The configure system also
454 works around many known issues in many versions of common HPC
455 compilers. However, since the options also enable general compiler
456 flags for the platform in question, you can end up in situations
457 where e.g. an `AVX_128_FMA` binary will just crash on any
458 Intel machine, since the code will try to execute general illegal
459 instructions (inserted by the compiler) before `mdrun` gets to the
460 architecture detection routines.
461
462 A further `GMX_SIMD=Reference` option exists, which is a special
463 SIMD-like implementation written in plain C that developers can use
464 when developing support in GROMACS for new SIMD architectures. It is
465 not designed for use in production simulations, but if you are using
466 an architecture with SIMD support to which GROMACS has not yet been
467 ported, you may wish to try this option instead of the default
468 `GMX_SIMD=None`, as it can often out-perform this when the
469 auto-vectorization in your compiler does a good job. And post on the
470 GROMACS mailing lists, because GROMACS can probably be ported for new
471 SIMD architectures in a few days.
472
473 ### CMake advanced options ###
474
475 The options that are displayed in the default view of `ccmake` are
476 ones that we think a reasonable number of users might want to consider
477 changing. There are a lot more options available, which you can see by
478 toggling the advanced mode in `ccmake` on and off with `t`. Even
479 there, most of the variables that you might want to change have a
480 `CMAKE_` or `GMX_` prefix. There are also some options that will be
481 visible or not according to whether their preconditions are satisfied.
482
483 ### Helping CMake find the right libraries/headers/programs ###
484
485 If libraries are installed in non-default locations their location can
486 be specified using the following environment variables:
487
488 * `CMAKE_INCLUDE_PATH` for header files
489 * `CMAKE_LIBRARY_PATH` for libraries
490 * `CMAKE_PREFIX_PATH` for header, libraries and binaries
491   (e.g. `/usr/local`).
492
493 The respective `include`, `lib`, or `bin` is
494 appended to the path. For each of these variables, a list of paths can
495 be specified (on Unix, separated with ":"). Note that these are
496 enviroment variables (and not `cmake` command-line arguments) and in
497 a `bash` shell are used like:
498
499     $ CMAKE_PREFIX_PATH=/opt/fftw:/opt/cuda cmake ..
500
501 Alternatively, these variables are also `cmake` options, so they can
502 be set like `-DCMAKE_PREFIX_PATH=/opt/fftw:/opt/cuda`.
503
504 The `CC` and `CXX` environment variables are also useful
505 for indicating to `cmake` which compilers to use, which can be very
506 important for maximising GROMACS performance. Similarly,
507 `CFLAGS`/`CXXFLAGS` can be used to pass compiler
508 options, but note that these will be appended to those set by
509 GROMACS for your build platform and build type. You can customize
510 some of this with advanced options such as `CMAKE_C_FLAGS`
511 and its relatives.
512
513 See also: <http://cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables>
514
515 ### Native GPU acceleration ###
516 If you have the CUDA Toolkit installed, you can use `cmake` with:
517
518     $ cmake .. -DGMX_GPU=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
519
520 (or whichever path has your installation). In some cases, you might
521 need to specify manually which of your C++ compilers should be used,
522 e.g. with the advanced option `CUDA_HOST_COMPILER`.
523
524 The GPU acceleration has been tested on AMD64/x86-64 platforms with
525 Linux, Mac OS X and Windows operating systems, but Linux is the
526 best-tested and supported of these. Linux running on ARM v7 (32 bit)
527 CPUs also works.
528
529 ### Static linking ###
530 Dynamic linking of the GROMACS executables will lead to a
531 smaller disk footprint when installed, and so is the default on
532 platforms where we believe it has been tested repeatedly and found to work.
533 In general, this includes Linux, Windows, Mac OS X and BSD systems.
534 Static binaries take much more space, but on some hardware and/or under
535 some conditions they are necessary, most commonly when you are running a parallel
536 simulation using MPI libraries (e.g. BlueGene, Cray).
537
538 * To link GROMACS binaries
539 statically against the internal GROMACS libraries, set
540 `-DBUILD_SHARED_LIBS=OFF`.
541 * To link statically against external (non-system) libraries as well,
542 the `-DGMX_PREFER_STATIC_LIBS=ON` option can be used. Note, that in
543 general `cmake` picks up whatever is available, so this option only
544 instructs `cmake` to prefer static libraries when both static and
545 shared are available. If no static version of an external library is
546 available, even when the aforementioned option is `ON`, the shared
547 library will be used. Also note, that the resulting binaries will
548 still be dynamically linked against system libraries on platforms
549 where that is the default. To use static system libraries, additional
550 compiler/linker flags are necessary, e.g. `-static-libgcc
551 -static-libstdc++`.
552
553 ### Portability aspects ###
554
555 Here, we consider portability aspects related to CPU instruction sets,
556 for details on other topics like binaries with statical vs dynamic
557 linking please consult the relevant parts of this documentation or
558 other non-GROMACS specific resources.
559
560 A GROMACS build will normally not be portable, not even across
561 hardware with the same base instruction set like x86. Non-portable
562 hardware-specific optimizations are selected at configure-time, such
563 as the SIMD instruction set used in the compute-kernels. This
564 selection will be done by the build system based on the capabilities
565 of the build host machine or based on cross-compilation information
566 provided to `cmake` at configuration.
567
568 Often it is possible to ensure portability by choosing the least
569 common denominator of SIMD support, e.g. SSE2 for x86, and ensuring
570 the you use `cmake -DGMX_USE_RDTSCP=off` if any of the target CPU
571 architectures does not support the `RDTSCP` instruction.  However, we
572 discourage attempts to use a single GROMACS installation when the
573 execution environment is heterogeneous, such as a mix of AVX and
574 earlier hardware, because this will lead to programs (especially
575 `mdrun`) that run slowly on the new hardware. Building two full
576 installations and locally managing how to call the correct one
577 (e.g. using the module system) is the recommended
578 approach. Alternatively, as at the moment the GROMACS tools do not
579 make strong use of SIMD acceleration, it can be convenient to create
580 an installation with tools portable across different x86 machines, but
581 with separate `mdrun` binaries for each architecture. To achieve this,
582 one can first build a full installation with the
583 least-common-denominator SIMD instruction set, e.g. `-DGMX_SIMD=SSE2`,
584 then build separate `mdrun` binaries for each architecture present in
585 the heterogeneous environment. By using custom binary and library
586 suffixes for the `mdrun`-only builds, these can be installed to the
587 same location as the "generic" tools installation. Building [only the
588 `mdrun` binary](#building-only-mdrun) is possible by setting the `-DGMX_BUILD_MDRUN_ONLY=ON`
589 option.
590
591 ### Linear algebra libraries ###
592
593 As mentioned above, sometimes vendor BLAS and LAPACK libraries
594 can provide performance enhancements for GROMACS when doing
595 normal-mode analysis or covariance analysis. For simplicity, the text
596 below will refer only to BLAS, but the same options are available
597 for LAPACK. By default, CMake will search for BLAS, use it if it
598 is found, and otherwise fall back on a version of BLAS internal to
599 GROMACS. The `cmake` option `-DGMX_EXTERNAL_BLAS=on` will be set
600 accordingly. The internal versions are fine for normal use. If you
601 need to specify a non-standard path to search, use
602 `-DCMAKE_PREFIX_PATH=/path/to/search`. If you need to specify a
603 library with a non-standard name (e.g. ESSL on AIX or BlueGene), then
604 set `-DGMX_BLAS_USER=/path/to/reach/lib/libwhatever.a`.
605
606 If you are using Intel MKL for FFT, then the BLAS and
607 LAPACK it provides are used automatically. This could be
608 over-ridden with `GMX_BLAS_USER`, etc.
609
610 On Apple platforms where the Accelerate Framework is available, these
611 will be automatically used for BLAS and LAPACK. This could be
612 over-ridden with `GMX_BLAS_USER`, etc.
613
614 ### Changing the names of GROMACS binaries and libraries ###
615
616 It is sometimes convenient to have different versions of the same
617 GROMACS programs installed. The most common use cases have been single
618 and double precision, and with and without MPI. This mechanism can
619 also be used to install side-by-side multiple versions of `mdrun`
620 optimized for different CPU architectures, as mentioned previously.
621
622 By default, GROMACS will suffix programs and libraries for such builds
623 with `_d` for double precision and/or `_mpi` for MPI (and nothing
624 otherwise). This can be controlled manually with `GMX_DEFAULT_SUFFIX
625 (ON/OFF)`, `GMX_BINARY_SUFFIX` (takes a string) and `GMX_LIBS_SUFFIX`
626 (also takes a string). For instance, to set a custom suffix for
627 programs and libraries, one might specify:
628
629     cmake .. -DGMX_DEFAULT_SUFFIX=OFF -DGMX_BINARY_SUFFIX=_mod -DGMX_LIBS_SUFFIX=_mod
630
631 Thus the names of all programs and libraries will be appended with
632 `_mod`.
633
634 ## Building GROMACS ##
635
636 Once you have configured with `cmake`, you can build GROMACS. It is
637 expected that the `make` procedure will always complete successfully,
638 and give few or no warnings. The tests GROMACS makes on the settings
639 you choose are pretty extensive, but there are probably a few cases we
640 have not thought of yet. Search the web first for solutions to
641 problems, but if you need help, ask on gmx-users, being sure to
642 provide as much information as possible about what you did, the system
643 you are building on, and what went wrong. This may mean scrolling back
644 a long way through the output of `make` to find the first error
645 message!
646
647 If you have a multi-core or multi-CPU machine with `N`
648 processors, then using
649     $ make -j N
650 will generally speed things up by quite a bit. Other build generator systems
651 supported by `cmake` (e.g. `ninja`) also work well.
652
653 ### Building only mdrun ###
654
655 Past versions of the build system offered "mdrun" and "install-mdrun"
656 targets (similarly for other programs too) to build and install only
657 the mdrun program, respectively. Such a build is useful when the
658 configuration is only relevant for `mdrun` (such as with
659 parallelization options for MPI, SIMD, GPUs, or on BlueGene or Cray),
660 or the length of time for the compile-link-install cycle is relevant
661 when developing.
662
663 This is now supported with the `cmake` option
664 `-DGMX_BUILD_MDRUN_ONLY=ON`, which will build a cut-down version of
665 `libgromacs` and/or the `mdrun` program (according to whether shared
666 or static). Naturally, now `make install` installs only those
667 products. By default, mdrun-only builds will default to static linking
668 against GROMACS libraries, because this is generally a good idea for
669 the targets for which an mdrun-only build is desirable. If you re-use
670 a build tree and change to the mdrun-only build, then you will inherit
671 the setting for `BUILD_SHARED_LIBS` from the old build, and will be
672 warned that you may wish to manage `BUILD_SHARED_LIBS` yourself.
673
674 ## Installing GROMACS ##
675
676 Finally, `make install` will install GROMACS in the
677 directory given in `CMAKE_INSTALL_PREFIX`. If this is a system
678 directory, then you will need permission to write there, and you
679 should use super-user privileges only for `make install` and
680 not the whole procedure.
681
682 ## Getting access to GROMACS after installation ##
683
684 GROMACS installs the script `GMXRC` in the `bin`
685 subdirectory of the installation directory
686 (e.g. `/usr/local/gromacs/bin/GMXRC`), which you should source
687 from your shell:
688
689     $ source /your/installation/prefix/here/bin/GMXRC
690
691 It will detect what kind of shell you are running and set up your
692 environment for using GROMACS. You may wish to arrange for your
693 login scripts to do this automatically; please search the web for
694 instructions on how to do this for your shell. 
695
696 Many of the GROMACS programs rely on data installed in the
697 `share/gromacs` subdirectory of the installation directory. By
698 default, the programs will use the environment variables set in the
699 `GMXRC` script, and if this is not available they will try to guess the
700 path based on their own location.  This usually works well unless you
701 change the names of directories inside the install tree. If you still
702 need to do that, you might want to recompile with the new install
703 location properly set, or edit the `GMXRC` script.
704
705 ## Testing GROMACS for correctness ##
706
707 Since 2011, the GROMACS development uses an automated system where
708 every new code change is subject to regression testing on a number of
709 platforms and software combinations. While this improves
710 reliability quite a lot, not everything is tested, and since we
711 increasingly rely on cutting edge compiler features there is
712 non-negligible risk that the default compiler on your system could
713 have bugs. We have tried our best to test and refuse to use known bad
714 versions in `cmake`, but we strongly recommend that you run through
715 the tests yourself. It only takes a few minutes, after which you can
716 trust your build.
717
718 The simplest way to run the checks is to build GROMACS with
719 `-DREGRESSIONTEST_DOWNLOAD`, and run `make check`.
720 GROMACS will automatically download and run the tests for you.
721 Alternatively, you can download and unpack the tarball yourself from
722 <http://gerrit.gromacs.org/download/regressiontests-@REGRESSIONTEST_VERSION@.tar.gz>,
723 and use the advanced `cmake` option `REGRESSIONTEST_PATH` to
724 specify the path to the unpacked tarball, which will then be used for
725 testing. If the above does not work, then please read on.
726
727 The regression tests are available from the GROMACS website and ftp
728 site.  Once you have downloaded them, unpack the tarball, source
729 `GMXRC` as described above, and run `./gmxtest.pl all`
730 inside the regression tests folder. You can find more options
731 (e.g. adding `double` when using double precision, or
732 `-only expanded` to run just the tests whose names match
733 "expanded") if you just execute the script without options.
734
735 Hopefully, you will get a report that all tests have passed. If there
736 are individual failed tests it could be a sign of a compiler bug, or
737 that a tolerance is just a tiny bit too tight. Check the output files
738 the script directs you too, and try a different or newer compiler if
739 the errors appear to be real. If you cannot get it to pass the
740 regression tests, you might try dropping a line to the gmx-users
741 mailing list, but then you should include a detailed description of
742 your hardware, and the output of `mdrun -version` (which contains
743 valuable diagnostic information in the header).
744
745 A build with `-DGMX_BUILD_MDRUN_ONLY` cannot be tested with
746 `make check` from the build tree, because most of the tests
747 require a full build to run things like `grompp`. To test such an
748 mdrun fully requires installing it to the same location as a normal
749 build of GROMACS, downloading the regression tests tarball manually
750 as described above, sourcing the correct `GMXRC` and running the
751 perl script manually. For example, from your GROMACS source
752 directory:
753
754     $ mkdir build-normal
755     $ cd build-normal
756     $ cmake .. -DCMAKE_INSTALL_PREFIX=/your/installation/prefix/here
757     $ make -j 4
758     $ make install
759     $ cd ..
760     $ mkdir build-mdrun-only
761     $ cd build-mdrun-only
762     $ cmake .. -DGMX_MPI=ON -DGMX_GPU=ON -DGMX_BUILD_MDRUN_ONLY=ON -DCMAKE_INSTALL_PREFIX=/your/installation/prefix/here
763     $ make -j 4
764     $ make install
765     $ cd /to/your/unpacked/regressiontests
766     $ source /your/installation/prefix/here/bin/GMXRC
767     $ ./gmxtest.pl all -np 2
768
769 If your `mdrun` program has been suffixed in a non-standard way, then
770 the `./gmxtest.pl -mdrun` option will let you specify that name to the
771 test machinery. You can use `./gmxtest.pl -double` to test the
772 double-precision version. You can use `./gmxtest.pl -crosscompiling`
773 to stop the test harness attempting to check that the programs can
774 be run.
775
776
777 ## Testing GROMACS for performance ##
778 We are still working on a set of benchmark systems for testing
779 the performance of GROMACS. Until that is ready, we recommend that
780 you try a few different parallelization options, and experiment with
781 tools such as `gmx tune_pme`.
782
783 ## Having difficulty? ##
784 You are not alone - this can be a complex task! If you encounter a
785 problem with installing GROMACS, then there are a number of
786 locations where you can find assistance. It is recommended that you
787 follow these steps to find the solution:
788
789 1. Read the installation instructions again, taking note that you
790    have followed each and every step correctly.
791
792 2. Search the GROMACS website and users emailing list for information
793    on the error. Adding
794    "site:https://mailman-1.sys.kth.se/pipermail/gromacs.org_gmx-users"
795    to a Google search may help filter better results.
796
797 3. Search the internet using a search engine such as Google.
798
799 4. Post to the GROMACS users emailing list gmx-users for
800    assistance. Be sure to give a full description of what you have
801    done and why you think it did not work. Give details about the
802    system on which you are installing.  Copy and paste your command
803    line and as much of the output as you think might be relevant -
804    certainly from the first indication of a problem. In particular,
805    please try to include at least the header from the mdrun logfile,
806    and preferably the entire file.  People who might volunteer to help
807    you do not have time to ask you interactive detailed follow-up
808    questions, so you will get an answer faster if you provide as much
809    information as you think could possibly help. High quality bug
810    reports tend to receive rapid high quality answers.
811
812 # Special instructions for some platforms #
813
814 ## Building on Windows ##
815
816 Building on Windows using native compilers is rather similar to
817 building on Unix, so please start by reading the above. Then, download
818 and unpack the GROMACS source archive. Make a folder in which to do
819 the out-of-source build of GROMACS. For example, make it within the
820 folder unpacked from the source archive, and call it `build-gromacs`.
821
822 For CMake, you can either use the graphical user interface provided on
823 Windows, or you can use a command line shell with instructions similar
824 to the UNIX ones above. If you open a shell from within your IDE
825 (e.g. Microsoft Visual Studio), it will configure the environment for
826 you, but you might need to tweak this in order to get either a 32-bit
827 or 64-bit build environment. The latter provides the fastest
828 executable. If you use a normal Windows command shell, then you will
829 need to either set up the environment to find your compilers and
830 libraries yourself, or run the `vcvarsall.bat` batch script provided
831 by MSVC (just like sourcing a bash script under Unix).
832
833 With the graphical user interface, you will be asked about what
834 compilers to use at the initial configuration stage, and if you use
835 the command line they can be set in a similar way as under UNIX. You
836 will probably make your life easier and faster by using the new
837 facility to download and install FFTW automatically.
838
839 For the build, you can either load the generated solutions file into
840 e.g. Visual Studio, or use the command line with `cmake --build` so
841 the right tools get used.
842
843 ## Building on Cray ##
844
845 GROMACS builds mostly out of the box on modern Cray machines, but
846 * you may need to specify the use of static or dynamic libraries
847   (depending on the machine) with `-DBUILD_SHARED_LIBS=off`,
848 * you may need to set the F77 environmental variable to `ftn` when
849   compiling FFTW,
850 * you may need to use `-DCMAKE_SKIP_RPATH=YES`, and
851 * you may need to modify the CMakeLists.txt files to specify the
852   `BUILD_SEARCH_END_STATIC` target property.
853
854 ## Building on BlueGene ##
855
856 ### BlueGene/Q ###
857
858 There is currently native acceleration on this platform for the Verlet
859 cut-off scheme. There are no plans to provide accelerated kernels for
860 the group cut-off scheme, but the default plain C kernels will work
861 (slowly).
862
863 Only static linking with XL compilers is supported by GROMACS. Dynamic
864 linking would be supported by the architecture and GROMACS, but has no
865 advantages other than disk space, and is generally discouraged on
866 BlueGene for performance reasons.
867
868 Computation on BlueGene floating-point units is always done in
869 double-precision. However, mixed-precision builds of GROMACS are still
870 normal and encouraged since they use cache more efficiently. The
871 BlueGene hardware automatically converts values stored in single
872 precision in memory to double precision in registers for computation,
873 converts the results back to single precision correctly, and does so
874 for no additional cost. As with other platforms, doing the whole
875 computation in double precision normally shows no improvement in
876 accuracy and costs twice as much time moving memory around.
877
878 You need to arrange for FFTW to be installed correctly, following the
879 above instructions.
880
881 `mpicc` is used for compiling and linking. This can make it awkward to
882 attempt to use IBM's optimized BLAS/LAPACK called ESSL (see the
883 section on
884 [linear algebra libraries](#linear-algebra-libraries)). Since mdrun is
885 the only part of GROMACS that should normally run on the compute
886 nodes, and there is nearly no need for linear algebra support for
887 mdrun, it is recommended to use the GROMACS built-in linear algebra
888 routines - it is rare for this to run slowly.
889
890 The recommended configuration is to use
891
892     cmake .. -DCMAKE_TOOLCHAIN_FILE=Platform/BlueGeneQ-static-XL-CXX \
893              -DCMAKE_PREFIX_PATH=/your/fftw/installation/prefix \
894              -DGMX_MPI=ON \
895              -DGMX_BUILD_MDRUN_ONLY=ON
896     make
897     make install
898
899 which will build a statically-linked MPI-enabled mdrun for the compute
900 nodes. Otherwise, GROMACS default configuration behaviour applies.
901
902 It is possible to configure and make the remaining GROMACS tools with
903 the compute-node toolchain, but as none of those tools are MPI-aware
904 and could then only run on the compute nodes, this would not normally
905 be useful. Instead, these should be planned to run on the login node,
906 and a separate GROMACS installation performed for that using the login
907 node's toolchain - not the above platform file, or any other
908 compute-node toolchain.
909
910 Note that only the MPI build is available for the compute-node
911 toolchains. The GROMACS thread-MPI or no-MPI builds are not useful at
912 all on BlueGene/Q.
913
914 ### BlueGene/P ###
915
916 There is currently no SIMD support on this platform and no plans to
917 add it. The default plain C kernels will work.
918
919 ### Fujitsu PRIMEHPC ###
920
921 This is the architecture of the K computer, which uses Fujitsu
922 `Sparc64VIIIfx` chips. On this platform, GROMACS @PROJECT_VERSION@ has
923 accelerated group kernels, no accelerated Verlet kernels, and a custom
924 build toolchain.
925
926 ### Intel Xeon Phi ###
927
928 GROMACS @PROJECT_VERSION@ has preliminary support for Intel Xeon Phi. Only symmetric
929 (aka native) mode is supported. GROMACS is functional on Xeon Phi, but
930 it has so far not been optimized to the same level as other
931 architectures have. The performance depends among other factors on the
932 system size, and for
933 now the performance might not be faster than CPUs. Building for Xeon
934 Phi works almost as any other Unix. See the instructions above for
935 details. The recommended configuration is
936
937     cmake .. -DCMAKE_TOOLCHAIN_FILE=Platform/XeonPhi
938     make
939     make install
940
941 # Tested platforms #
942
943 While it is our best belief that GROMACS will build and run pretty
944 much everywhere, it is important that we tell you where we really know
945 it works because we have tested it. We do test on Linux, Windows, and
946 Mac with a range of compilers and libraries for a range of our
947 configuration options. Every commit in our git source code repository
948 is currently tested on x86 with gcc versions ranging from 4.4 through
949 4.7, and versions 12 and 13 of the Intel compiler as well as Clang
950 version 3.1 through 3.4. For this, we use a variety of GNU/Linux
951 flavors and versions as well as recent version of Mac OS X.  Under
952 Windows we test both MSVC and the Intel compiler. For details, you can
953 have a look at the continuous integration server at
954 <http://jenkins.gromacs.org>.
955
956 We test irregularly on ARM v7, BlueGene/Q, Cray, Fujitsu PRIMEHPC, Google
957 Native Client and other environments, and with other compilers and
958 compiler versions, too.