Fix incorrect grid cell size in g_sas -nopbc
[alexxy/gromacs.git] / admin / installguide / installguide.tex
1 % Process from LaTeX via XML to XHTML with
2 % latexml --destination installguide.xml --xml installguide.tex
3 % latexmlpost --destination installguide.xhtml --format=xhtml installguide.xml
4 %
5 % Crude hack to remove ugly symbols:
6 % sed -e 's/[§]//g' -i installguide.xhtml
7 %
8 % Strip off header for pasting into the website at
9 % http://www.gromacs.org/Documentation/Installation_Instructions:
10 %
11 % grep -A 99999 "class=\"main\"" installguide.xhtml > installguide_web.xhtml
12
13 \documentclass{article}[12pt,a4paper,twoside]
14 \usepackage{hyperref}
15 % haven't made these work with LaTeXML yet...
16 %\usepackage[strings]{underscore}
17 %\usepackage[english]{babel}
18
19 \title{GROMACS installation guide}
20
21 % macros to keep style uniform
22 \newcommand{\gromacs}{GROMACS}
23 \newcommand{\nvidia}{NVIDIA}
24 \newcommand{\cuda}{CUDA}
25 \newcommand{\fftw}{FFTW}
26 \newcommand{\mkl}{MKL}
27 \newcommand{\mpi}{MPI}
28 \newcommand{\threadmpi}{ThreadMPI}
29 \newcommand{\openmpi}{OpenMPI}
30 \newcommand{\openmp}{OpenMP}
31 \newcommand{\openmm}{OpenMM}
32 \newcommand{\lammpi}{LAM/MPI}
33 \newcommand{\mpich}{MPICH}
34 \newcommand{\cmake}{CMake}
35 \newcommand{\sse}{SSE}
36 \newcommand{\ssetwo}{SSE2}
37 \newcommand{\avx}{AVX}
38 \newcommand{\fft}{FFT}
39 \newcommand{\blas}{BLAS}
40 \newcommand{\lapack}{LAPACK}
41 \newcommand{\vmd}{VMD}
42 \newcommand{\pymol}{PyMOL}
43 \newcommand{\grace}{Grace}
44 %\newcommand{\}{}
45 %\newcommand{\}{}
46
47 % later, make CMake keep this version current for us
48 \newcommand{\fftwversion}{3.3.2}
49 \newcommand{\cmakeversion}{2.8.0}
50 \newcommand{\cudaversion}{3.2}
51
52 \begin{document}
53 \section{Building GROMACS}
54
55 These instructions pertain to building \gromacs{} 4.6 and newer releases
56 using our new CMake-based build system. 
57 For installations instructions for old \gromacs{} versions,
58 see the documentation at
59 \url{http://www.gromacs.org/Documentation/Installation_Instructions_4.5}.
60
61 \section{Quick and dirty installation}
62
63 \begin{enumerate}
64 \item Get the latest version of your compiler.
65 \item Check you have \cmake{} version 2.8.x or later.
66 \item Unpack the \gromacs{} tarball.
67 \item Make a separate build directory and change to it. 
68 \item Run \cmake{} with the path to the source as an argument
69 \item Run make and make install
70 \end{enumerate}
71 Or, as a sequence of commands to execute:
72 \begin{verbatim}
73 tar xfz gromacs-4.6.5.tar.gz
74 cd gromacs-4.6.5
75 mkdir build
76 cd build
77 cmake .. -DGMX_BUILD_OWN_FFTW=ON
78 make
79 sudo make install
80 \end{verbatim}
81 This will download and build first the prerequisite FFT library followed by \gromacs{}. If you already have
82 FFTW installed, you can remove that argument to cmake. Overall, this build 
83 of \gromacs{} will be correct and reasonably fast on the
84 machine upon which \cmake{} ran. It will generally be 30-50\% faster
85 than \gromacs{} 4.5.x, but if you want to get the maximum value
86 for your hardware with \gromacs{}, you'll have to read further.
87 Sadly, the interactions of hardware, libraries, and compilers
88 are only going to continue to get more complex. 
89
90 \section{Prerequisites}
91 \subsection{Platform}
92 \gromacs{} can be compiled for any distribution of Linux, Mac OS X,
93 Windows (native, Cygwin or MinGW), BlueGene, Cray and many other architectures.
94 Technically, it can be compiled on any platform with an ANSI C
95 compiler and supporting libraries, such as the GNU C library. However, Gromacs
96 also comes with many hardware-specific extensions to provide very high performance
97 on those platforms, and to enable these we have slightly more specific requirements
98 since old compilers do not support new features, or they can be buggy.
99
100 \subsection{Compiler}
101
102 \gromacs{} requires an ANSI C compiler that complies with the C89
103 standard. For best performance, the \gromacs{} team strongly
104 recommends you get the most recent version of your preferred compiler
105 for your platform (e.g. GCC 4.7 or Intel 12.0 or newer on x86
106 hardware). There is a large amount of \gromacs{} code introduced in
107 version 4.6 that depends on effective compiler optimization to get
108 high performance - the old raw assembly-language kernel routines are all gone.
109 Unfortunately this makes \gromacs{} more sensitive to the compiler
110 used, and the binary will only work on the hardware for which it is compiled,
111 but the good news is that it has enabled us to significantly accelerate performance
112 compared to version 4.5. 
113
114 \begin{itemize}
115 \item On Intel-based x86 hardware, we recommend you to use
116 the GNU compilers version 4.7 or later or Intel compilers version 12 or later
117 for best performance. The Intel compiler has historically been better at
118 instruction scheduling, but recent gcc versions have proved to be as fast or
119 sometimes faster than Intel.
120 \item On AMD-based x86 hardware up through the ``K10'' microarchitecture (``Family 10h'')
121 Thuban/Magny-Cours architecture (e.g. Opteron 6100-series processors), it is worth using the Intel compiler for
122 better performance, but gcc version 4.7 and later are also reasonable.
123 \item On the AMD Bulldozer architecture (Opteron 6200), AMD introduced fused multiply-add
124 instructions and an "FMA4" instruction format not available on Intel x86 processors. Thus,
125 on the most recent AMD processors you want to use gcc version 4.7 or later for better performance!
126 The Intel compiler will only generate code for the subset also supported by Intel processors, and that
127 is significantly slower right now.
128 \item If you are running on Mac OS X, the best option is the Intel compiler.
129 Both clang and gcc will work, but they produce lower performance and each have some
130 shortcomings. Clang does not support OpenMP, and the current gcc ports (e.g. from MacPorts) do not
131 support AVX instructions. 
132 \item For all non-x86 platforms, your best option is typically to use the vendor's 
133 default compiler, and check for specialized information below.
134 \end{itemize}
135
136 \subsubsection{Running in parallel}
137
138 \gromacs{} can run in parallel on multiple cores of a single
139 workstation using its built-in \threadmpi. No user action is required
140 in order to enable this.
141
142 If you wish to use the excellent new native GPU support in \gromacs,
143 \nvidia{}'s \cuda{}
144 \url{http://www.nvidia.com/object/cuda_home_new.html} version
145 \cudaversion{} software development kit is required, and the latest
146 version is strongly encouraged. \nvidia{} GPUs with at least \nvidia{} compute
147 capability 2.0 are required, e.g. Fermi or Kepler cards.
148
149 The GPU support from \gromacs{} version 4.5 using \openmm{}
150 \url{https://simtk.org/home/openmm} is still contained in the code,
151 but in the ``user contributions'' section (\verb+src/contrib+). You
152 will need to set
153 \verb+-DGMX_OPENMM=on -DGMX_GPU=off -DGMX_MPI=off
154 -DGMX_THREAD_MPI=off\+ in order to build it. It also requires \cuda{},
155 and remains the only hardware-based acceleration available for
156 implicit solvent simulations in \gromacs{} at the moment. However, the
157 long-term plan is to enable this functionality in core Gromacs, and
158 not have the OpenMM interface supported by the \gromacs team.
159
160 If you wish to run in parallel on multiple machines across a network,
161 you will need to have
162 \begin{itemize}
163 \item an \mpi{} library installed that supports the \mpi{} 1.3
164   standard, and
165 \item wrapper compilers that will compile code using that library.
166 \end{itemize}
167 The \gromacs{} team recommends \openmpi{}
168 \url{http://www.open-mpi.org/} version 1.4.1 (or higher), \mpich{}
169 \url{http://www.mpich.org/} version 1.4.1 (or higher), or your
170 hardware vendor's \mpi{} installation. The most recent version of
171 either of this is likely to be the best. More specialized networks
172 might depend on accelerations only available in the vendor's library.
173  \lammpi{}
174 \url{http://www.lam-mpi.org/} might work, but since it has been
175 deprecated for years, it is not supported.
176
177 In some cases, \openmp{} parallelism is an advantage for \gromacs{},
178 but support for this is generally built into your compiler and detected
179 automatically. The one common exception is Mac OS X, where the default
180 clang compiler currently does not fully support OpenMP. You can install
181 gcc version 4.7 instead, but the currently available binary distribution of gcc 
182 uses an old system assembler that does not support AVX acceleration
183 instructions. There are some examples on the Internet where people have
184 hacked this to work, but presently the only straightforward way to get
185 both OpenMP and AVX support on Mac OS X is to get the Intel compiler.
186
187 In summary, for maximum performance you will need to 
188 examine how you will use \gromacs{}, what hardware you plan to run
189 on, and whether you can afford a non-free compiler for slightly better
190 performance. The only way to find out is unfortunately to test different
191 options and parallelization schemes for the actual simulations you
192 want to run. You will still get {\em good}\, performance with the default
193 build and runtime options (better than in version 4.5), but if you truly
194 want to push your hardware to the performance limit the days of just blindly 
195 starting programs like '\verb+mdrun+' are gone. 
196
197 \subsection{CMake}
198
199 From version 4.6, \gromacs{} uses the build system
200 \cmake{}. The previous build system that used \verb+configure+ from
201 the GNU autotools package has been removed permanently. \cmake{}
202 permits the \gromacs{} team to support a very wide range of hardware,
203 compilers and build configurations while continuing to provide the
204 portability, robustness and performance for which \gromacs{} is known.
205
206 \gromacs{} requires \cmake{} version \cmakeversion{} or higher. Lower
207 versions will not work. You can check whether \cmake{} is installed,
208 and what version it is, with \verb+cmake --version+. If you need to
209 install \cmake{}, then first check whether your platform's package
210 management system provides a suitable version, or visit
211 \url{http://www.cmake.org/cmake/help/install.html} for pre-compiled
212 binaries, source code and installation instructions. The \gromacs{}
213 team recommends you install the most recent version of \cmake{} you
214 can. If you need to compile \cmake{} yourself and have a really old environment,
215 you might first have to compile a moderately recent version (say, 2.6) to
216 bootstrap version 2.8. This is a one-time job, and you can find lots of
217 documentation on the \cmake{} website if you run into problems.
218
219 \subsection{Fast Fourier Transform library}
220
221 Many simulations in \gromacs{} make extensive use of fast Fourier transforms,
222 and a software library to perform these is always required. We
223 recommend \fftw{} \url{http://www.fftw.org/} (version 3 or higher
224 only) or Intel's \mkl{} \url{http://software.intel.com/en-us/intel-mkl}. 
225
226 \subsubsection{\fftw{}}
227
228 \fftw{} is likely to be available for your platform via its package
229 management system, but there can be compatibility and significant
230 performance issues associated with these packages. In particular,
231 \gromacs{} simulations are normally run in single floating-point
232 precision whereas the default \fftw{} package is normally in double
233 precision, and good compiler options to use for \fftw{} when linked to
234 \gromacs{} may not have been used. Accordingly, the \gromacs{} team
235 recommends either
236 \begin{itemize}
237 \item that you permit the \gromacs{} installation to download and
238   build \fftw{} \fftwversion{} from source automatically for you (use
239   \verb+cmake -DGMX_BUILD_OWN_FFTW=ON+), or
240 \item that you build \fftw{} from the source code.
241 Note that the GROMACS-managed download of the FFTW tarball has a
242 slight chance of posing a security risk. If you use this option, you
243 will see a warning that advises how you can eliminate this risk.
244 \end{itemize}
245
246 If you build \fftw{} from source yourself, get the most recent version
247 and follow its installation guide available from \url{http://www.fftw.org}.
248 Choose the precision (i.e. single or float vs.\ double) to match what you will
249 later require for \gromacs{}. There is no need to compile with
250 threading or \mpi{} support, but it does no harm. On x86 hardware,
251 compile \emph{only} with \verb+--enable-sse2+ (regardless of
252 precision) even if your processors can take advantage of \avx{}
253 extensions. Since \gromacs{} uses fairly short transform lengths we
254 do not benefit from the \fftw{} \avx{} acceleration, and because of
255 memory system performance limitations, it can even degrade \gromacs{}
256 performance by around 20\%. There is no way for \gromacs{} to
257 limit the use to \ssetwo{} acceleration at run time if \avx{}
258 support has been compiled into \fftw{}, so you need to set this at compile time.
259
260 \subsubsection{\mkl{}}
261
262 Using \mkl{} with the Intel Compilers version 11 or higher is very simple. Set up your
263 compiler environment correctly, perhaps with a command like
264 \verb+source /path/to/compilervars.sh intel64+ (or consult your local
265 documentation). Then set \verb+-DGMX_FFT_LIBRARY=mkl+ when you run
266 \cmake{}. In this case, \gromacs{} will also use \mkl{} for \blas{}
267 and \lapack{} (see \hyperref{linear-algebra}{here}).
268
269 Otherwise, you can configure \mkl{} by setting
270 \verb+-DGMX_FFT_LIBRARY=mkl
271 -DMKL_LIBRARIES="/full/path/to/libone.so;/full/path/to/libtwo.so"
272 -DMKL_INCLUDE_DIR="/full/path/to/mkl/include"+,
273 where the full list (and order!) of libraries you require are found in
274 Intel's \mkl{} documentation for your system.
275
276 \subsection{Optional build components}
277
278 \begin{itemize}
279 \item Hardware-optimized \blas{} and \lapack{} libraries are useful
280   for a few of the \gromacs{} utilities focused on normal modes and
281   matrix manipulation, but they do not provide any benefits for normal
282   simulations. Configuring these are discussed
283   \hyperlink{linear-algebra}{here}.
284 \item The built-in \gromacs{} trajectory viewer \verb+ngmx+ requires
285   X11 and Motif/Lesstif libraries and header files. Generally, the
286   \gromacs{} team rather recommends you use third-party software for
287   visualization, such as \vmd{}
288   \url{http://www.ks.uiuc.edu/Research/vmd/} or \pymol{}
289   \url{http://www.pymol.org/}.
290 \item A few \gromacs{} tools get some extra functionality when linked with the
291 GNU scientific library GSL.
292 \end{itemize}
293
294 \section{Doing a build of \gromacs}
295
296 This section will cover a general build of \gromacs{} with \cmake{},
297 but it is not an exhaustive discussion of how to use \cmake{}. There
298 are many resources available on the web, which we suggest you search
299 for when you encounter problems not covered here. The material below
300 applies specifically to builds on Unix-like systems, including Linux,
301 Mac OS X, MinGW and Cygwin. For other platforms, see the specialist
302 instructions below.
303
304 \subsection{Configuring with \cmake{}}
305
306 \cmake{} will run many tests on your system and do its best to work
307 out how to build \gromacs{} for you. If you are building \gromacs{} on
308 hardware that is identical to that where you will run \verb+mdrun+,
309 then you can be sure that the defaults will be pretty good. The build
310 configuration will for instance attempt to detect the specific hardware
311 instructions available in your processor. However, if
312 you want to control aspects of the build, there are plenty of things you
313 can set manually.
314
315 The best way to use \cmake{} to configure \gromacs{} is to do an
316 ``out-of-source'' build, by making another directory from which you
317 will run \cmake{}. This can be a subdirectory or not, it doesn't
318 matter. It also means you can never corrupt your source code by trying
319 to build it! So, the only required argument on the \cmake{} command
320 line is the name of the directory containing the
321 \verb+CMakeLists.txt+ file of the code you want to build. For
322 example, download the source tarball and use
323 % TODO: keep up to date with new releases!
324 \begin{verbatim}
325 $ tar xfz gromacs-4.6.5.tgz
326 $ cd gromacs-4.6.5
327 $ mkdir build-cmake
328 $ cd build-cmake
329 $ cmake ..
330 \end{verbatim}
331
332 You will see \verb+cmake+ report the results of a large number of
333 tests on your system made by \cmake{} and by \gromacs{}. These are
334 written to the \cmake{} cache, kept in \verb+CMakeCache.txt+. You
335 can edit this file by hand, but this is not recommended because it is
336 easy to reach an inconsistent state. You should not attempt to move or
337 copy this file to do another build, because file paths are hard-coded
338 within it. If you mess things up, just delete this file and start
339 again with '\verb+cmake+'.
340
341 If there's a serious problem detected at this stage, then you will see
342 a fatal error and some suggestions for how to overcome it. If you're
343 not sure how to deal with that, please start by searching on the web
344 (most computer problems already have known solutions!) and then
345 consult the gmx-users mailing list. There are also informational
346 warnings that you might like to take on board or not. Piping the
347 output of \verb+cmake+ through \verb+less+ or \verb+tee+ can be
348 useful, too.
349
350 \cmake{} works in an iterative fashion, re-running each time a setting
351 is changed to try to make sure other things are consistent. Once
352 things seem consistent, the iterations stop. Once \verb+cmake+
353 returns, you can see all the settings that were chosen and information
354 about them by using e.g. the curses interface
355 \begin{verbatim}
356 $ ccmake ..
357 \end{verbatim}
358 You can actually use \verb+ccmake+ (available on most Unix platforms,
359 if the curses library is supported) directly in the first step, but then
360 most of the status messages will merely blink in the lower part
361 of the terminal rather than be written to standard out. Most platforms
362 including Linux, Windows, and Mac OS X even have native graphical user interfaces for
363 \cmake{}, and it can create project files for almost any build environment
364 you want (including Visual Studio or Xcode).
365 Check out \url{http://www.cmake.org/cmake/help/runningcmake.html} for
366 general advice on what you are seeing and how to navigate and change
367 things. The settings you might normally want to change are already
368 presented. If you make any changes, then \verb+ccmake+ will notice
369 that and require that you re-configure (using '\verb+c+'), so that it
370 gets a chance to make changes that depend on yours and perform more
371 checking. This might require several configuration stages when you are
372 using \verb+ccmake+ - when you are using \verb+cmake+ the
373 iteration is done behind the scenes.
374
375 A key thing to consider here is the setting of
376 \verb+CMAKE_INSTALL_PREFIX+. You will need to be able to write to
377 this directory in order to install \gromacs{} later, and if you change
378 your mind later, changing it in the cache triggers a full re-build,
379 unfortunately. So if you do not have super-user privileges on your
380 machine, then you will need to choose a sensible location within your
381 home directory for your \gromacs{} installation.
382
383 When \verb+cmake+ or \verb+ccmake+ have completed iterating, the
384 cache is stable and a build tree can be generated, with '\verb+g+' in
385 \verb+ccmake+ or automatically with \verb+cmake+.
386
387 You should not attempt to change compilers after the initial run of
388 \cmake{}. If you need to change, clean up and start again.
389
390 \subsection{Using CMake command-line options}
391 Once you become comfortable with setting and changing options, you
392 may know in advance how you will configure GROMACS. If so, you can
393 speed things up by invoking \verb+cmake+ with a command like:
394 \begin{verbatim}
395 $ cmake .. -DGMX_GPU=ON -DGMX_MPI=ON -DCMAKE_INSTALL_PREFIX=/home/marydoe/programs
396 \end{verbatim}
397 to build with GPUs, MPI and install in a custom location. You can even
398 save that in a shell script to make it even easier next time. You can
399 also do this kind of thing with \verb+ccmake+, but you should avoid
400 this, because the options set with '\verb+-D+' will not be able to be
401 changed interactively in that run of \verb+ccmake+.
402
403 \subsection{CMake advanced options}
404 The options that can be seen with \verb+ccmake+ are ones that we
405 think a reasonable number of users might want to consider
406 changing. There are a lot more options available, which you can see by
407 toggling the advanced mode in \verb+ccmake+ on and off with
408 '\verb+t+'. Even there, most of the variables that you might want to
409 change have a '\verb+CMAKE_+' or '\verb+GMX_+' prefix.
410
411 \subsubsection{Portability aspects}
412 Here, we consider portability aspects related to CPU instruction sets,
413 for details on other topics like binaries with statical vs dynamic linking
414 please consult the relevant parts of this documentation or other non-\gromacs{} specific
415 resources.
416
417 Most often a \gromacs{} build will by default not be portable,
418 not even across hardware with the same base instruction set like x86.
419 The reason for this is that hardware-specific optimizations are selected
420 at configure-time, like the SIMD instruction set used in the compute-kernels.
421 This selection will be done by the build system based on the capabilities
422 of the build host machine or based on cross-compilation information provided
423 to \cmake{} at configuration.
424
425 Often it is possible to ensure portability by choosing the
426 least common denominator of SIMD support, e.g. SSE2 for x86
427 and ensuring the \cmake{} option \verb+GMX_USE_RDTSCP+ is off if any of the
428 target CPU architectures does not support the \verb+RDTSCP+ instruction.
429 However, we discourage attempts to use a single \gromacs{}
430 installation when the execution environment is heterogeneous, such as
431 a mix of \avx{} and earlier hardware, because this will lead to slow
432 binaries (especially \verb+mdrun+), on the new hardware.
433 Building two full installations and locally managing how to
434 call the correct one (e.g. using the module system) is the recommended
435 approach.
436 Alternatively, as at the moment the \gromacs{} tools do not make
437 strong use of SIMD acceleration, it can be convenient to create an installation
438 with tools portable across different x86 machines, but with separate \verb+mdrun+
439 binaries for each architecture.
440 To achieve this, one can first build a full installation with the least common
441 denominator SIMD instruction set, e.g. SSE2, then build separate \verb+mdrun+
442 binaries for each architecture present in the heterogeneous environment.
443 By using custom binary and library suffixes for the \verb+mdrun+-only builds,
444 these can be installed to the same location as the ''generic`` tools installation.
445
446
447 \subsection{Helping CMake find the right libraries/headers/programs}
448
449 If libraries are installed in non-default locations their location can
450 be specified using the following environment variables:
451 \begin{itemize}
452 \item \verb+CMAKE_INCLUDE_PATH+ for header files
453 \item \verb+CMAKE_LIBRARY_PATH+ for libraries
454 \item \verb+CMAKE_PREFIX_PATH+ for header, libraries and binaries
455   (e.g. '\verb+/usr/local+').
456 \end{itemize}
457 The respective '\verb+include+', '\verb+lib+', or '\verb+bin+' is
458 appended to the path. For each of these variables, a list of paths can
459 be specified (on Unix separated with ":"). Note that these are
460 enviroment variables (and not \cmake{} command-line arguments) and in
461 a '\verb+bash+' shell are used like:
462 \begin{verbatim}
463 $ CMAKE_PREFIX_PATH=/opt/fftw:/opt/cuda cmake ..
464 \end{verbatim}
465
466 The \verb+CC+ and \verb+CXX+ environment variables are also useful
467 for indicating to \cmake{} which compilers to use, which can be very
468 important for maximising \gromacs{} performance. Similarly,
469 \verb+CFLAGS+/\verb+CXXFLAGS+ can be used to pass compiler
470 options, but note that these will be appended to those set by
471 \gromacs{} for your build platform and build type. You can customize
472 some of this with advanced options such as \verb+CMAKE_C_FLAGS+
473 and its relatives.
474
475 See also: \url{http://cmake.org/Wiki/CMake_Useful_Variables#Environment_Variables}
476
477 \subsection{Linear algebra libraries}\hypertarget{linear-algebra}
478 As mentioned above, sometimes vendor \blas{} and \lapack{} libraries
479 can provide performance enhancements for \gromacs{} when doing
480 normal-mode analysis or covariance analysis. For simplicity, the text
481 below will refer only to \blas{}, but the same options are available
482 for \lapack{}. By default, CMake will search for \blas{}, use it if it
483 is found, and otherwise fall back on a version of \blas{} internal to
484 \gromacs{}. The \cmake{} option \verb+GMX_EXTERNAL_BLAS+ will be set
485 accordingly. The internal versions are fine for normal use. If you
486 need to specify a non-standard path to search, use
487 \verb+-DCMAKE_PREFIX_PATH=/path/to/search+. If you need to specify a
488 library with a non-standard name (e.g. ESSL on AIX or BlueGene), then
489 set \verb+-DGMX_BLAS_USER=/path/to/reach/lib/libwhatever.a+.
490
491 If you are using Intel's \mkl{} for \fft{}, then the \blas{} and
492 \lapack{} it provides are used automatically. This could be
493 over-ridden with \verb+GMX_BLAS_USER+, etc.
494
495 On Apple platforms where the Accelerate Framework is available, these
496 will be automatically used for \blas{} and \lapack{}. This could be
497 over-ridden with \verb+GMX_BLAS_USER+, etc.
498
499 \subsection{Native GPU acceleration}
500 If you have the \cuda{} Software Development Kit installed, you can
501 use \cmake{} with:
502 \begin{verbatim}
503 cmake .. -DGMX_GPU=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
504 \end{verbatim}
505 (or whichever path has your installation). Note that this will require
506 a working C++ compiler, and in some cases you might need to handle
507 this manually, e.g. with the advanced option
508 \verb+CUDA_HOST_COMPILER+.
509
510 Historically, Linux GPU builds have received most testing, but we 
511 want to support GPU builds both under x86 Linux, Windows, Mac OS X and in the
512 future ARM. Any feedback on this build process (and fixes in particular) are very
513 welcome!
514
515 \subsection{Static linking}
516 Dynamic linking of the \gromacs{} executables will lead to a
517 smaller disk footprint when installed, and so is the default on
518 platforms where we believe it has been tested repeatedly and found to work.
519 In general, this includes Linux, Windows, Mac OS X and BSD systems.
520 Static binaries take much more space, but on some hardware and/or under
521 some conditions they are necessary, most commonly when you are running a parallel
522 simulation using MPI libraries. 
523
524 \begin{itemize}
525 \item To link \gromacs{} binaries
526 statically against the internal \gromacs{} libraries, set
527 \verb+BUILD_SHARED_LIBS=OFF+.
528 \item To link statically against external
529 libraries as well, the \verb+GMX_PREFER_STATIC_LIBS=ON+ option can be
530 used. Note, that in general \cmake{} picks up whatever is available,
531 so this option only instructs \cmake{} to prefer static libraries when
532 both static and shared are available. If no static version of an
533 external library is available, even when the aforementioned option is
534 ON, the shared library will be used. Also note, that the resulting
535 binaries will still be dynamically linked against system libraries if
536 that is all that is available (common on Mac OS X).
537 \end{itemize}
538
539 \subsection{Changing the names of GROMACS binaries and libraries}
540 It is sometimes convenient to have different versions of the same
541 \gromacs{} libraries installed. The most common use cases have been
542 single and double precision, and with and without \mpi{}. By default,
543 \gromacs{} will suffix binaries and libraries for such builds with
544 '\verb+_d+' for double precision and/or '\verb+_mpi+' for \mpi{} (and
545 nothing otherwise). This can be controlled manually with
546 \verb+GMX_DEFAULT_SUFFIX (ON/OFF)+, \verb+GMX_BINARY_SUFFIX+ (takes 
547 a string) and \verb+GMX_LIBS_SUFFIX+ (also takes a string). 
548 This can also be useful for resolving libary-naming conflicts with 
549 existing packges (\verb+GMX_PREFIX_LIBMD+ also can be useful).
550 For instance, to set a custom suffix for binaries and libraries, 
551 one might specify:
552
553 \begin{verbatim}
554 cmake .. -DGMX_DEFAULT_SUFFIX=OFF -DGMX_BINARY_SUFFIX=_mod -DGMX_LIBS_SUFFIX=_mod
555 \end{verbatim}
556
557 Thus the names of all binaries and libraries will be appended with
558 "\_mod."
559
560 \subsection{Building \gromacs{}}
561
562 Once you have a stable cache, you can build \gromacs{}. If you're not
563 sure the cache is stable, you can re-run \verb+cmake ..+ or
564 \verb+ccmake ..+' to see. Then you can run \verb+make+ to start the
565 compilation. Before actual compilation starts, \verb+make+ checks
566 that the cache is stable, so if it isn't you will see \cmake{} run
567 again.
568
569 So long as any changes you've made to the configuration are sensible,
570 it is expected that the \verb+make+ procedure will always complete
571 successfully. The tests \gromacs{} makes on the settings you choose
572 are pretty extensive, but there are probably a few cases we haven't
573 thought of yet. Search the web first for solutions to problems, but if
574 you need help, ask on gmx-users, being sure to provide as much
575 information as possible about what you did, the system you are
576 building on, and what went wrong.
577
578 If you have a multi-core or multi-CPU machine with \verb+N+
579 processors, then using
580 \begin{verbatim}
581 $ make -j N
582 \end{verbatim}
583 will generally speed things up by quite a bit.
584
585 \subsection{Installing \gromacs{}}
586
587 Finally, \verb+make install+ will install \gromacs{} in the
588 directory given in \verb+CMAKE_INSTALL_PREFIX+. If this is an system
589 directory, then you will need permission to write there, and you
590 should use super-user privileges only for \verb+make install+ and
591 not the whole procedure.
592
593 \subsection{Getting access to \gromacs{} after installation}
594
595 \gromacs{} installs the script \verb+GMXRC+ in the \verb+bin+
596 subdirectory of the installation directory
597 (e.g. \verb+/usr/local/gromacs/bin/GMXRC+), which you should source
598 from your shell:
599 \begin{verbatim}
600 $ source your-installation-prefix-here/bin/GMXRC
601 \end{verbatim}
602
603 It will detect what kind of shell you are running and set up your
604 environment for using \gromacs{}. You may wish to arrange for your
605 login scripts to do this automatically; please search the web for
606 instructions on how to do this for your shell. 
607
608 Many of the \gromacs{} programs rely on data installed in our
609 \verb+share/gromacs+ directory. By default, the programs will use
610 the environment variables set in the GMXRC script, and if this is not
611 available they will try to guess the path based on their own location.
612 This usually works well unless you change the names of directories
613 inside the install tree. If you still need to do that, you might want to recompile
614 with the new install location properly set, or edit the \verb+GMXRC+ script.
615
616 \subsection{Testing \gromacs{} for correctness}
617 Since 2011, the \gromacs{} development uses an automated system where
618 every new patch is subject to regression testing. While this improves
619 reliability quite a lot, not everything is tested, and since we
620 increasingly rely on cutting edge compiler features there is
621 non-negligible risk that the default compiler on your system could
622 have bugs. We have tried our best to test and refuse to use known bad
623 versions in \cmake{}, but we strongly recommend that you run through
624 the regression tests yourself. It only takes a few minutes, after
625 which you can trust your build.
626
627 The simplest way to run the checks is to build \gromacs{} with
628 \verb+-DREGRESSIONTEST_DOWNLOAD+, and run \verb+make check+.
629 \gromacs{} will automatically download and run the tests for you.
630 Alternatively, you can download and unpack the tarball yourself from
631 \url{http://gerrit.gromacs.org/download/regressiontests-4.6.5.tar.gz},
632 and use the advanced \cmake{} option \verb+REGRESSIONTEST_PATH+ to
633 specify the path to the unpacked tarball, which will then be used for
634 testing. If this doesn't work, then please read on.
635
636 The regression tests are available from the \gromacs{} website and ftp
637 site.  Once you have downloaded them, unpack the tarball, source
638 \verb+GMXRC+ as described above, and run \verb+./gmxtest.pl all+
639 inside the regression tests folder. You can find more options
640 (e.g. adding \verb+double+ when using double precision) if you just
641 execute the script without options.
642
643 Hopefully you will get a report that all tests have passed. If there
644 are individual failed tests it could be a sign of a compiler bug, or
645 that a tolerance is just a tiny bit too tight. Check the output files
646 the script directs you too, and try a different or newer compiler if
647 the errors appear to be real. If you cannot get it to pass the
648 regression tests, you might try dropping a line to the gmx-users
649 mailing list, but then you should include a detailed description of
650 your hardware and an example logfile from mdrun (which contains
651 valuable information in the header).
652
653 \subsection{Testing \gromacs{} for performance}
654 We are still working on a set of benchmark systems for testing
655 the performance of \gromacs{}. Until that is ready, we recommend that
656 you start by comparing the performance to release 4.5, and also try
657 a few different parallelization options.
658
659 \subsection{Having difficulty?}
660 You're not alone - this can be a complex task! If you encounter a
661 problem with installing \gromacs{}, then there are a number of
662 locations where you can find assistance. It is recommended that you
663 follow these steps to find the solution:
664
665 \begin{enumerate}
666 \item Read the installation instructions again, taking note that you
667   have followed each and every step correctly.
668 \item Search the \gromacs{} website and users emailing list for
669   information on the error.
670 \item Search the internet using a search engine such as Google.
671 \item Post to the \gromacs{} users emailing list gmx-users for
672   assistance. Be sure to give a full description of what you have done
673   and why you think it didn't work. Give details about the system on
674   which you are installing. 
675   Copy and paste your command line and as
676   much of the output as you think might be relevant - certainly from
677   the first indication of a problem. In particular, please try to include at
678   least the header from the mdrun logfile, and preferably the entire file.
679   People who might volunteer to
680   help you do not have time to ask you interactive detailed follow-up
681   questions, so you will get an answer faster if you provide as much
682   information as you think could possibly help. High quality bug reports 
683   tend to receive rapid high quality answers.
684 \end{enumerate}
685
686 \section{Special instructions for some platforms}
687
688 \subsection{Building on Windows}
689 Building on Cygwin/MinGW/etc. works just like Unix. Please see the
690 instructions above.
691
692 Building on Windows using native compilers is rather similar to
693 building on Unix, so please start by reading the above. Then, download
694 and unpack the GROMACS source archive. The UNIX-standard .tar.gz
695 format can be managed on Windows, but you may prefer to browse
696 \url{ftp://ftp.gromacs.org/pub/gromacs} to obtain a zip format file,
697 which doesn't need any external tools to unzip on recent Windows
698 systems. Make a folder in which to do the out-of-source build of
699 \gromacs{}. For example, make it within the folder unpacked from the
700 source archive, and call it ``build-cmake''. 
701
702 For \cmake{}, you can either use the graphical user interface provided
703 on Windows, or you can use a command line shell with instructions
704 similar to the UNIX ones above. If you open a shell from within
705 your IDE (e.g. Microsoft Visual Studio), it will configure the
706 environment for you, but you might need to tweak this in order to 
707 get either a 32-bit or 64-bit build environment. The latter provides the
708 fastest executable. If you use a normal Windows command shell, then
709 you will need to either set up the environment to find your compilers
710 and libraries yourself, or run the \verb+vcvarsall.bat+ batch script
711 provided by MSVC (just like sourcing a bash script under
712 Unix). 
713
714 With the graphical user interface you will be asked about what compilers
715 to use at the initial configuration stage, and if you use the command line
716 they can be set in a similar way as under UNIX.
717 You will probably make your life easier and faster by using the
718 new facility to download and install \fftw{} automatically. 
719
720 For the build, you can either load the generated solutions file into
721 e.g. Visual Studio, or use the command line with \verb+cmake --build .+ 
722 so the right tools get used.
723
724 \subsection{Building on Cray}
725
726 Gromacs builds mostly out of the box on modern Cray machines,
727 but you want to use static libraries due to the peculiarities with
728 parallel job execution.
729
730 \subsection{Building on BlueGene}
731
732 \subsubsection{BlueGene/P}
733
734 There is currently no native acceleration on this platform and no
735 plans to make one. The default plain C kernels will work.
736
737 \subsubsection{BlueGene/Q}
738
739 There is currently native acceleration on this platform for the Verlet
740 cut-off scheme. Accelerated kernels for the group cut-off scheme may
741 come in the future, but the default plain C kernels will work.
742
743 Only static linking with XL compilers is supported by \gromacs{}. Dynamic
744 linking would be supported by the architecture and \gromacs{}, but has no
745 advantages other than disk space, and is generally discouraged on
746 BlueGene for performance reasons.
747
748 Computation on BlueGene floating-point units is always done in
749 double-precision. However, single-precision builds of \gromacs{} are
750 still normal and encouraged since they use cache more efficiently. 
751 The BlueGene hardware automatically
752 converts values stored in single precision in memory to double
753 precision in registers for computation, converts the results back to
754 single precision correctly, and does so for no additional cost. As
755 with other platforms, doing the whole computation in double precision
756 normally shows no improvement in accuracy and costs twice as much time
757 moving memory around.
758
759 You need to arrange for FFTW to be installed correctly, following the
760 above instructions.
761
762 mpicc is used for compiling and linking. This can make it awkward to
763 attempt to use IBM's optimized BLAS/LAPACK called ESSL (see the
764 section on linear algebra). Since mdrun is the only part of \gromacs{}
765 that should normally run on the compute nodes, and there is nearly no
766 need for linear algebra support for mdrun, it is recommended to use
767 the \gromacs{} built-in linear algebra routines - it is rare for this
768 to be a bottleneck.
769
770 The recommended configuration is to use
771 \begin{verbatim}
772 cmake .. -DCMAKE_TOOLCHAIN_FILE=Platform/BlueGeneQ-static-XL-CXX \
773          -DCMAKE_PREFIX_PATH=/your/fftw/installation/prefix \
774          -DGMX_MPI=on
775 make mdrun
776 make install-mdrun
777 \end{verbatim}
778 which will build a statically-linked MPI-enabled mdrun for the back
779 end. Otherwise, GROMACS default configuration behaviour applies.
780
781 It is possible to configure and make the remaining \gromacs{} tools
782 with the compute-node toolchain, but as none of those tools are
783 \mpi{}-aware and could then only run on the compute nodes, this
784 would not normally be useful. Instead, these should be planned
785 to run on the login node, and a separate \gromacs{} installation
786 performed for that using the login node's toolchain - not the
787 above platform file, or any other compute-node toolchain.
788
789 Note that only the MPI build is available for the compute-node
790 toolchains. The GROMACS thread-MPI or serial builds are not useful at
791 all on BlueGene/Q.
792
793 \subsubsection{Fujitsu PRIMEHPC}
794
795 This is the architecture of the K computer, which uses Fujitsu Sparc64viiifx 
796 chips. Gromacs-4.6 will build with default C kernels on this architecture,
797 and Gromacs-4.6.2 added accelerated group kernels and a custom toolchain.
798
799 \section{Tested platforms}
800
801 While it is our best belief that \gromacs{} will build and run pretty
802 much everywhere, it's important that we tell you where we really know
803 it works because we've tested it. We do test on Linux, Windows, and
804 Mac with a range of compilers and libraries for a range of our
805 configuration options. Every commit in our git source code
806 repository is currently tested on x86 with gcc versions ranging
807 from 4.4 through 4.7, and versions 12 and 13 of the Intel compiler as 
808 well as Clang version 3.1 through 3.3. For this we use a variety of GNU/Linux
809 flavors and versions as well as recent version of Mac OS X.
810 Under Windows we test both MSVC and the Intel compiler. For details, you can
811 have a look at the continuous integration server at \url{http://jenkins.gromacs.org}.
812
813 We test irregularly on BlueGene/Q, Cray,
814 Fujitsu PRIMEHPC, Google Native Client and other environments. In
815 the future we expect ARM to be an important test target too, but this
816 is currently not included.
817
818 Contributions to this section are welcome.
819
820 Later we might set up the ability for users to contribute test results
821 to Jenkins.
822
823 \section{Other issues}
824
825 The \gromacs{} utility programs often write data files in formats
826 suitable for the \grace{} plotting tool, but it is straightforward to
827 use these files in other plotting programs, too.
828
829 \end{document}