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.13. Development build options — LAMMPS documentation 3.13. Development build optionsThe build procedures in LAMMPS offers a few extra options which are useful during development, testing or debugging. 3.13.1. Faster compilation with Ninja and ccache (CMake only)LAMMPS is a large software package, and compiling it with many packages enabled can take a long time. During development, LAMMPS is typically re-compiled many times: after small changes, after switching between branches, or in multiple build folders with different settings. Two tools can reduce the time spent waiting for the compilation considerably: the Ninja build tool and the ccache compiler cache. Both are available as packages for all common Linux distributions and for macOS, e.g.: sudo dnf install ninja-build ccache # Fedora (RHEL and compatible: with EPEL) sudo apt install ninja-build ccache # Debian, Ubuntu, and compatible brew install ninja ccache # macOS with Homebrew Ninja is also available for Windows. It is included with Visual Studio, and building LAMMPS with CMake inside Visual Studio uses it (see Notes for building LAMMPS on Windows). The Ninja build toolBy default, CMake on Linux and macOS generates build files for the
cmake -S cmake -B build -G Ninja -C cmake/presets/most.cmake cmake --build build Ninja is designed for speed: it determines much faster than The generator is selected when a build folder is configured for the
first time and cannot be changed afterwards. To switch an existing
build folder to Ninja, either use a new folder or add the cmake --fresh -S cmake -B build -G Ninja -C cmake/presets/most.cmake The ccache compiler cacheThe ccache program stores the result of each compilation in a cache.
When the same source file is compiled again with the same compiler and
the same settings, the stored result is used instead of running the
compiler again, which takes only a small fraction of the time. This
happens frequently during development, e.g. after switching to a
different branch and back, during a There are several ways to make CMake use ccache:
The command The default settings of ccache can be adjusted for a project of the size
of LAMMPS (all settings are remembered in the ccache configuration file,
Please see the ccache documentation for more details. 3.13.2. Monitor compilation flags (CMake only)Sometimes it is necessary to verify the complete sequence of compilation flags generated by the CMake build. To enable a more verbose output during compilation you can use the following option. -D CMAKE_VERBOSE_MAKEFILE=value # value = off (default) or on Another way of doing this without reconfiguration is adding the
cmake --build build --verbose 3.13.3. Report missing and unneeded ‘#include’ statements (CMake only)The conventions for how and when to use and order include statements in LAMMPS are documented in LAMMPS programming style. To assist with following these conventions one can use the Include What You Use tool. This tool is still under development and for large and complex projects like LAMMPS there are some false positives, so suggested changes need to be verified manually. It is recommended to use at least version 0.16, which has much fewer incorrect reports than earlier versions. To install the IWYU toolkit, you need to have the clang compiler and its development package installed. Download the IWYU version that matches the version of the clang compiler, configure, build, and install it. The necessary steps to generate the report can be enabled via a CMake variable during CMake configuration. -D ENABLE_IWYU=value # value = off (default) or on This will check if the required binary (include-what-you-use or iwyu) and python script (iwyu-tool or iwyu_tool or iwyu_tool.py) can be found in the path. The analysis can then be started with: cmake --build build --target iwyu This may first run some compilation, as the analysis is dependent on recording all commands required to do the compilation. 3.13.4. Address, Leak, Undefined Behavior, and Thread Sanitizer Support (CMake only)Compilers such as GCC and Clang support generating instrumented binaries which use different sanitizer libraries to detect problems in the code during run-time. They can detect issues like: Please note that this kind of instrumentation usually comes with a
performance hit (but much less than using tools like Valgrind with a more low level approach). To enable
these features, additional compiler flags need to be added to the
compilation and linking stages. This is done through setting the
-D ENABLE_SANITIZER=none # no sanitizer active (default) -D ENABLE_SANITIZER=address # enable address sanitizer / memory leak checker -D ENABLE_SANITIZER=hwaddress # enable hardware assisted address sanitizer / memory leak checker -D ENABLE_SANITIZER=leak # enable memory leak checker (only) -D ENABLE_SANITIZER=undefined # enable undefined behavior sanitizer -D ENABLE_SANITIZER=thread # enable thread sanitizer 3.13.5. Code Coverage and Unit Testing (CMake only)The LAMMPS code is subject to multiple levels of automated testing when pull requests are submitted to the LAMMPS repository on GitHub:
A few of the tests are currently run as GitHub Actions and their
configuration files are in the In addition, there is a nightly test run using the Regression tests can also be performed locally with the regression tester tool. The tool checks if a given LAMMPS binary, when run with selected input examples produces, thermo output that is consistent with the provided log files. The script can be run in one pass over all available input files, but it can also first create multiple lists of inputs or folders that can then be run with multiple workers concurrently to speed things up. Another mode allows to do a quick check of inputs that contain commands that have changes in the current checkout branch relative to a git branch. This works similar to the two pass mode, but will select only shorter runs and no more than 100 inputs that are chosen randomly. This ensures that the quick test runs significantly faster compared to the full test run. These test runs can also be performed with instrumented LAMMPS binaries (see previous section). A summary of all collected testing results and their trends, as well as code and development status related information is collected in the LAMMPS Testing Dashboard website. The unit testing facility is integrated into the CMake build process of
the LAMMPS source code distribution itself. It can be enabled by
setting Note When testing is enabled, LAMMPS should also be built as a shared
library with After compilation is complete, the unit testing is started in the build
folder using the The output of the plain $ ctest Test project /home/akohlmey/compile/lammps/build-testing Start 1: RunLammps 1/563 Test #1: RunLammps .................................. Passed 0.28 sec Start 2: HelpMessage 2/563 Test #2: HelpMessage ................................ Passed 0.06 sec Start 3: InvalidFlag 3/563 Test #3: InvalidFlag ................................ Passed 0.06 sec Start 4: Tokenizer 4/563 Test #4: Tokenizer .................................. Passed 0.05 sec Start 5: MemPool 5/563 Test #5: MemPool .................................... Passed 0.05 sec Start 6: ArgUtils 6/563 Test #6: ArgUtils ................................... Passed 0.05 sec [...] Start 561: ImproperStyle:zero 561/563 Test #561: ImproperStyle:zero ......................... Passed 0.07 sec Start 562: TestMliapPyUnified 562/563 Test #562: TestMliapPyUnified ......................... Passed 0.16 sec Start 563: TestPairList 563/563 Test #563: TestPairList ............................... Passed 0.06 sec 100% tests passed, 0 tests failed out of 563 Label Time Summary: generated = 0.85 sec*proc (3 tests) noWindows = 4.16 sec*proc (2 tests) slow = 78.33 sec*proc (67 tests) unstable = 28.23 sec*proc (34 tests) Total Test time (real) = 132.34 sec The
In its full implementation, the unit test framework will consist of multiple kinds of tests implemented in different programming languages (C++, C, Python, Fortran) and testing different aspects of the LAMMPS software and its features. The tests will adapt to the compilation settings of LAMMPS, so that tests will be skipped if prerequisite features are not available in LAMMPS. Work in Progress The unit test framework was added in spring 2020 and is under active development. The coverage is not complete and will be expanded over time. Preference was given to test parts of the code base that are easy to test or commonly used. Tests as shown by the Tests for force computing or modifying styles (e.g. styles for non-bonded and bonded interactions and selected fixes) are run by using a more generic test program that reads its input from files in YAML format. The YAML file provides the information on how to customized the test program to test a specific style and - if needed - with specific settings. To add a test for another, similar style (e.g. a new pair style) it is usually sufficient to add a suitable YAML file. Detailed instructions for adding tests are provided in the Programmer Guide part of the manual. A description of what happens during these tests is given below. Unit tests for force stylesA large part of LAMMPS are different “styles” for computing non-bonded
and bonded interactions selected through the pair_style command,
bond_style command, angle_style command, dihedral_style command,
improper_style command, and kspace_style command commands. Since these
styles all share common interfaces, it is possible to write generic test
programs that will assemble LAMMPS inputs from templates with different
settings and call those common interfaces for small test systems with
less than 100 atoms and compare the results with pre-recorded reference
results. A test run is then a collection of multiple individual test
runs, each with many comparisons to reference results based on template
input files, individual command settings, relative error margins, and
reference data stored in a YAML format file with Below is an example command and output for running a single test named
$ ctest -R MolPairStyle:lj_cut$ -V [...] Start 199: MolPairStyle:lj_cut 199: Test command: /home/akohlmey/compile/lammps/build-test/test_pair_style "/home/akohlmey/compile/lammps/unittest/force-styles/tests/mol-pair-lj_cut.yaml" 199: Working Directory: /home/akohlmey/compile/lammps/build-test/unittest/force-styles 199: Environment variables: 199: PYTHONPATH=/home/akohlmey/compile/lammps/unittest/force-styles/tests:/home/akohlmey/compile/lammps/python: 199: PYTHONUNBUFFERED=1 199: PYTHONDONTWRITEBYTECODE=1 199: OMP_PROC_BIND=false 199: OMP_NUM_THREADS=4 199: LAMMPS_POTENTIALS=/home/akohlmey/compile/lammps/potentials 199: LD_LIBRARY_PATH=/home/akohlmey/compile/lammps/build-test:/usr/lib64/mpich/lib:/home/akohlmey/.local/lib:: 199: Test timeout computed to be: 1500 199: [==========] Running 9 tests from 1 test suite. 199: [----------] Global test environment set-up. 199: [----------] 9 tests from PairStyle 199: [ RUN ] PairStyle.plain 199: [ OK ] PairStyle.plain (17 ms) 199: [ RUN ] PairStyle.omp 199: [ OK ] PairStyle.omp (3 ms) 199: [ RUN ] PairStyle.kokkos_omp 199: [ OK ] PairStyle.kokkos_omp (6 ms) 199: [ RUN ] PairStyle.gpu 199: /home/akohlmey/compile/lammps/unittest/force-styles/test_pair_style.cpp:793: Skipped 199: 199: 199: [ SKIPPED ] PairStyle.gpu (0 ms) 199: [ RUN ] PairStyle.intel 199: [ OK ] PairStyle.intel (2 ms) 199: [ RUN ] PairStyle.opt 199: [ OK ] PairStyle.opt (2 ms) 199: [ RUN ] PairStyle.single 199: [ OK ] PairStyle.single (2 ms) 199: [ RUN ] PairStyle.extract 199: [ OK ] PairStyle.extract (1 ms) 199: [ RUN ] PairStyle.extract_omp 199: [ OK ] PairStyle.extract_omp (1 ms) 199: [----------] 9 tests from PairStyle (37 ms total) 199: 199: [----------] Global test environment tear-down 199: [==========] 9 tests from 1 test suite ran. (37 ms total) 199: [ PASSED ] 8 tests. 199: [ SKIPPED ] 1 test, listed below: 199: [ SKIPPED ] PairStyle.gpu 1/1 Test #199: MolPairStyle:lj_cut .............. Passed 0.75 sec The following tests passed: MolPairStyle:lj_cut 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.76 sec In this particular case, 8 out of 9 sets of tests were conducted, the
tests for the The force style test programs have a common set of options:
Since the env TEST_ARGS=-s ctest -V -R BondStyle This adds output with statistics for the computed error of the various tests relative to the reference (e.g. the per-atom force components). To add a test for a style that is not yet covered, it is usually best
to copy a YAML file for a similar style to a new file, edit the details
of the style (how to call it, how to set its coefficients) and then
run test command with either the Some of the force style tests are rather slow to run and some are very
sensitive to small differences like CPU architecture, compiler
tool chain, compiler optimization. Those tests are flagged with a “slow”
and/or “unstable” label, and thus those tests can be selectively
excluded with the Recommendations and notes for YAML files
Unit tests for timestepping related fixesA substantial subset of fix styles are invoked regularly during MD timestepping and manipulate per-atom properties like positions, velocities, and forces. For those fix styles, testing can be done in a very similar fashion as for force fields and thus there is a test program test_fix_timestep that shares a lot of code, properties, and command-line flags with the force field style testers described in the previous section. This tester will set up a small molecular system run with verlet run
style for 4 MD steps, then write a binary restart and continue for
another 4 MD steps. At this point coordinates and velocities are
recorded and compared to reference data. Then the system is cleared,
restarted and running the second 4 MD steps again and the data is
compared to the same reference. That is followed by another restart
after which per atom type masses are replaced with per-atom masses and
the second 4 MD steps are repeated again and compared to the same
reference. Also global scalar and vector data of the fix is recorded
and compared. If the fix is a thermostat and thus the internal property
If the fix has a multi-threaded version in the OPENMP package, then the entire set of tests is repeated for that version as well. For this to work, some additional conditions have to be met by the YAML format test inputs.
Use custom linker for faster link times when ENABLE_TESTING is activeWhen compiling LAMMPS with testing enabled, most test executables will
need to be linked against the LAMMPS library and re-linked whenever
there is a change to LAMMPS. Since this can be a very large library
with many C++ objects when many packages are enabled, link times can
become very long on machines that use the GNU BFD linker (e.g. Linux
systems). Alternative linker programs like the Building LAMMPS as a shared library with Distribute unit tests across multiple NVIDIA GPUsAdded in version 13Nov2026. When LAMMPS is compiled with the GPU package or the KOKKOS package with
GPU support, running tests in parallel with With CMake 3.29 or later on Linux and similar operating systems, tests
can instead be distributed over multiple NVIDIA GPUs through the CTest
resource allocation feature
where available GPUs are listed as entries with an assigned “slots” value
in a resource file. Then every test requests one slot of a GPU and is run
through a launcher script that sets the assigned GPU. This will restrict
the number of concurrent runs to the total number of available slots in
the resource file. Thus a command like The resource specification file
is in JSON format and its location is set with the CMake variable
{ "version": { "major": 1, "minor": 0 }, "local": [ { "gpus": [ { "id": "0", "slots": 1, "name": "Tesla V100-SXM2-16GB", "pci_bus_id": "00000000:1A:00.0" }, { "id": "1", "slots": 1, "name": "Tesla V100-SXM2-16GB", "pci_bus_id": "00000000:3A:00.0" } ] } ] } An existing file is used unchanged, so it can be edited and also be
shared between multiple build folders. The If the Tests for other components and utility functionsAdditional tests that validate utility functions or specific components
of LAMMPS are implemented as standalone executable which may, or may not
require creating a suitable LAMMPS instance. These tests are more specific
and do not require YAML format input files. To add a test, either an
existing source file needs to be extended or a new file added, which in turn
requires additions to the Collect and visualize code coverage metricsYou can also collect code coverage metrics while running LAMMPS or the tests by enabling code coverage support during the CMake configuration: -D ENABLE_COVERAGE=on # enable coverage measurements (off by default) This will instrument all object files to write information about which lines of code were accessed during execution in files next to the corresponding object files. These can be post-processed to visually show the degree of coverage and which code paths are accessed and which are not taken. When working on unit tests (see above), this can be extremely helpful to determine which parts of the code are not executed and thus what kind of tests are still missing. The coverage data is cumulative, i.e. new data is added with each new run. Enabling code coverage will also add the following build targets to generate coverage reports after running the LAMMPS executable or the unit tests: cmake --build build --target gen_coverage_html # generate coverage report in HTML format cmake --build build --target gen_coverage_xml # generate coverage report in XML format cmake --build build --target clean_coverage_html # delete folder with HTML format coverage report cmake --build build --target reset_coverage # delete all collected coverage data and HTML output These reports require GCOVR to be installed. The easiest way to do this to install it via pip: python3 -m pip install gcovr After post-processing with
3.13.6. Coding style utilitiesTo aid with enforcing some of the coding style conventions in LAMMPS
some additional build targets have been added to the makefile in the
The following options are available (to be run in the make check-whitespace # search for files with whitespace issues make fix-whitespace # correct whitespace issues in files make check-homepage # search for files with old LAMMPS homepage URLs make fix-homepage # correct LAMMPS homepage URLs in files make check-errordocs # search for deprecated error docs in header files make fix-errordocs # remove error docs in header files make check-permissions # search for files with permissions issues make fix-permissions # correct permissions issues in files make check-docs # search for several issues in the manual make check-version # list files with pending release version tags make check # run all check targets from above The whitespace, homepage, and permission checks and fixes are also
available as targets of the CMake build, e.g. These should help to make source and documentation files conforming to some the coding style preferences of the LAMMPS developers. 3.13.7. Clang-format supportFor the code in the It is recommended for all newly contributed files to use the clang-format processing while writing the code or do the coding style processing (including the scripts mentioned in the previous paragraph) If clang-format is available, files can be updated individually with commands like the following: clang-format -i some_file.cpp 3.13.8. GitHub command-line interfaceGitHub has developed a command-line tool
to interact with the GitHub website via a command called
The capabilities of 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. |