GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.lammps.org — 3.5. Basic build options — LAMMPS documentation 3.5. Basic build optionsThe following topics are covered on this page, for building with both CMake and make: 3.5.1. Serial vs parallel buildLAMMPS is written to use the ubiquitous MPI (Message Passing Interface) library API for distributed memory parallel computation. You need to have such a library installed for building and running LAMMPS in parallel using a domain decomposition parallelization. It is compatible with the MPI standard version 2.x and later. LAMMPS can also be built into a “serial” executable for use with a single processor using the bundled MPI STUBS library. Independent of the distributed memory MPI parallelization, parts of LAMMPS are also written with support for shared memory parallelization using the OpenMP threading standard. A more detailed discussion of that is below. -D BUILD_MPI=value # on or off, default is on if CMake finds MPI -D BUILD_OMP=value # on or off, default is on if a compatible # compiler is detected -D LAMMPS_MACHINE=name # name = mpi, serial, mybox, titan, laptop, etc # no default value The executable created by CMake (after compilation) is named
The build with traditional makefiles has to be done inside the source folder make mpi # parallel build, produces lmp_mpi using Makefile.mpi make serial # serial build, produces lmp_serial using Makefile/serial make mybox # uses Makefile.mybox to produce lmp_mybox Any For the serial build the following make variables are set (see CC = g++ LINK = g++ MPI_INC = -I../STUBS MPI_PATH = -L../STUBS MPI_LIB = -lmpi_stubs You also need to build the STUBS library for your platform before
making LAMMPS itself. A Note The file MPI and OpenMP support in LAMMPSIf you are installing MPI yourself to build a parallel LAMMPS executable, we recommend either MPICH or OpenMPI, which are regularly used and tested with LAMMPS by the LAMMPS developers. MPICH can be downloaded from the MPICH home page, and OpenMPI can be downloaded correspondingly from the OpenMPI home page. Other MPI packages should also work. No specific vendor provided and standard compliant MPI library is currently known to be incompatible with LAMMPS. If you are running on a large parallel machine, your system admins or the vendor should have already installed a version of MPI, which is likely to be faster than a self-installed MPICH or OpenMPI, so you should study the provided documentation to find out how to build and link with it. Note Some Linux distributions (for example Ubuntu) build their MPI
packages so that the MPI compiler wrappers add link-time
optimization flags ( The majority of OpenMP (threading) support in LAMMPS is provided by the
In addition, there are a few commands in LAMMPS that have native OpenMP
support included as well. These are commands in the For CMake, if you use When building LAMMPS with conventional make, the OpenMP Compiler compatibilitySome compilers do not fully support the 3.5.2. Choice of compiler and compile/link optionsThe choice of compiler and compiler flags can be important for maximum
performance. Vendor provided compilers for a specific hardware can
produce faster code than open-source compilers like the GNU compilers.
On the most common x86 hardware, the most popular C++ compilers are
quite similar in their ability to optimize regular C/C++ source code at
high optimization levels. When using the Note The Intel oneAPI compilers can be installed free of charge from
Intel’s package repositories, and we recommend using the latest
release. LAMMPS has been tested with the versions 2023.2.1,
2024.2.1, 2025.3.3, and 2026.2.0 of the Intel oneAPI C++ compiler.
The Intel compilers use the C++ library header files of the GCC
version installed on the system, and older versions of the Intel
compilers may not be able to process the header files of a newer GCC
version. For example, version 2023.2.1 cannot compile LAMMPS with
the header files of GCC 16. With CMake, a different GCC installation
can be selected with The With the Intel compilers, some of the unit tests
with the “unstable” label fail. Those tests should be skipped with
On parallel clusters or supercomputers which use “environment modules” for their compile/link environments, you can often access different compilers by simply loading the appropriate module before building LAMMPS. By default CMake will use the compiler it finds according to its internal preferences, and it will add optimization flags appropriate to that compiler and any accelerator packages you have included in the build. CMake will check if the detected or selected compiler is compatible with the C++ support requirements of LAMMPS and stop with an error, if this is not the case. A C++17 compatible compiler is required. You can tell CMake to look for a specific compiler with setting
CMake variables (listed below) during configuration. For a few
common choices, there are also presets in the -D CMAKE_CXX_COMPILER=name # name of C++ compiler -D CMAKE_C_COMPILER=name # name of C compiler -D CMAKE_Fortran_COMPILER=name # name of Fortran compiler -D CMAKE_CXX_STANDARD=17 # put compiler in C++17 mode -D CMAKE_CXX_FLAGS=string # flags to use with C++ compiler -D CMAKE_C_FLAGS=string # flags to use with C compiler -D CMAKE_Fortran_FLAGS=string # flags to use with Fortran compiler A few example command lines are: # Building with GNU Compilers: cmake -S cmake -B build -D CMAKE_C_COMPILER=gcc \ -D CMAKE_CXX_COMPILER=g++ -D CMAKE_Fortran_COMPILER=gfortran # Building with Intel oneAPI Compilers: cmake -S cmake -B build -D CMAKE_C_COMPILER=icx \ -D CMAKE_CXX_COMPILER=icpx -D CMAKE_Fortran_COMPILER=ifx # Building with LLVM/Clang Compilers: cmake -S cmake -B build -D CMAKE_C_COMPILER=clang \ -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_Fortran_COMPILER=flang # Building with PGI/Nvidia Compilers: cmake -S cmake -B build -D CMAKE_C_COMPILER=pgcc \ -D CMAKE_CXX_COMPILER=pgc++ -D CMAKE_Fortran_COMPILER=pgfortran # Building with the NVHPC Compilers: cmake -S cmake -B build -D CMAKE_C_COMPILER=nvc \ -D CMAKE_CXX_COMPILER=nvc++ -D CMAKE_Fortran_COMPILER=nvfortran For compiling with the Clang/LLVM compilers a CMake preset is
provided that can be loaded with
Note When the cmake command completes, it prints a summary to the
screen which compilers it is using and what flags and settings
will be used for the compilation. Note that if the top-level
compiler is The “compiler/linker settings” section of a Makefile.machine lists
compiler and linker settings for your C++ compiler, including
optimization flags. For a parallel build it is recommended to use
Parallel build (see CC = mpicxx CCFLAGS = -g -O3 LINK = mpicxx LINKFLAGS = -g -O Serial build with GNU gcc (see CC = g++ CCFLAGS = -g -O3 LINK = g++ LINKFLAGS = -g -O Note If compilation stops with a message like the following: g++ -g -O3 -DLAMMPS_MEMALIGN=64 -I../STUBS -c ../main.cpp In file included from ../pointers.h:24:0, from ../input.h:17, from ../main.cpp:16: ../lmptype.h:34:2: error: #error LAMMPS requires a C++17 (or later) compliant compiler. Enable C++17 compatibility or upgrade the compiler. then you have either an unsupported (old) compiler or you have
to turn on C++17 mode. For those compilers, you need to add
the If you build LAMMPS with any Accelerator packages included,
there may be specific compiler or linker flags that are either
required or recommended to enable required features and to
achieve optimal performance. You need to include these in the
3.5.3. Build the LAMMPS executable and libraryLAMMPS is always built as a library of C++ classes plus an executable.
The executable is a simple For CMake builds, you can select through setting CMake variables between building a shared or a static LAMMPS library and what kind of suffix is added to them (in case you want to concurrently install multiple variants of binaries with different settings). If none are set, defaults are applied. -D BUILD_SHARED_LIBS=value # on or off (default) -D LAMMPS_MACHINE=name # name = mpi, serial, mybox, titan, laptop, etc # no default value The compilation will always produce a LAMMPS library and an
executable linked to it. By default, this will be a static
library named With the traditional makefile based build process, the choice of
the generated executable or library depends on the “mode” setting.
Several options are available and make machine # build LAMMPS executable lmp_machine make mode=static machine # same as "make machine" make mode=shared machine # build LAMMPS shared lib liblammps_machine.so # instead The “static” build will generate a static library called
Additional informationNote that for creating a shared library, all the libraries it depends on
must be compiled to be compatible with shared libraries. This should be
the case for libraries included with LAMMPS, such as the dummy MPI
library in As an example, here is how to build and install the MPICH library, a popular open-source version of MPI, as a shared library in the default /usr/local/lib location: ./configure --enable-shared make make install You may need to use ./configure --enable-shared --prefix=${HOME}/.local Avoiding the use of “sudo” for custom software installation (i.e. from source and not through a package manager tool provided by the OS) is generally recommended to ensure the integrity of the system software installation. 3.5.4. Including or removing debug supportBy default the compilation settings will include the If this is a concern, you can change the compilation settings or remove the debug information from the LAMMPS executable:
3.5.5. Build LAMMPS toolsSome tools described in Auxiliary tools can be built directly using CMake or Make. -D BUILD_TOOLS=value # on or off (default). Build binary2txt, # chain.x, find-symmetry, micelle2d.x, # msi2lmp, phana, stl_bin2txt -D BUILD_LAMMPS_GUI=value # on or off (default). Build LAMMPS-GUI -D BUILD_WHAM=value # on (default). Download and build WHAM; # only available for BUILD_LAMMPS_GUI=on The generated binaries will also become part of the LAMMPS installation (see below). cd lammps/tools make all # build all binaries of tools make binary2txt # build only binary2txt tool make chain # build only chain tool make micelle2d # build only micelle2d tool Note Building LAMMPS-GUI requires building LAMMPS with CMake. 3.5.6. Install LAMMPS after a buildAfter building LAMMPS, you may wish to copy the LAMMPS executable or library, along with other LAMMPS files (library header, doc files), to a globally visible place on your system, for others to access. Note that you may need super-user privileges (e.g. sudo) if the directory you want to copy files to is protected. cmake -S cmake -B build -D CMAKE_INSTALL_PREFIX=path [options ...] cmake --build build # compile LAMMPS cmake --install build # perform the installation into prefix During the installation process CMake will by default remove any runtime
path settings for loading shared libraries. Because of this you may
have to set or modify the There is no “install” option in the |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |