2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2013,2014,2015,2016,2018 by the GROMACS development team.
5 * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
6 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 * and including many others, as listed in the AUTHORS file in the
8 * top-level source directory and at http://www.gromacs.org.
10 * GROMACS is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * GROMACS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with GROMACS; if not, see
22 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * If you want to redistribute modifications to GROMACS, please
26 * consider that scientific software is very special. Version
27 * control is crucial - bugs must be traceable. We will be happy to
28 * consider code for inclusion in the official distribution, but
29 * derived work must not be called official GROMACS. Details are found
30 * in the README & COPYING files - if they are missing, get the
31 * official version at http://www.gromacs.org.
33 * To help us fund GROMACS development, we humbly ask that you cite
34 * the research papers on the package. Check out http://www.gromacs.org.
39 * Tests for the mdrun multi-simulation functionality
41 * \author Mark Abraham <mark.j.abraham@gmail.com>
42 * \ingroup module_mdrun_integration_tests
48 #include <gtest/gtest.h>
50 #include "gromacs/mdtypes/md_enums.h"
52 #include "multisimtest.h"
59 /* This test ensures mdrun can run multi-simulations. It runs one
60 * simulation per MPI rank.
62 * TODO Preferably, we could test that mdrun correctly refuses to run
63 * multi-simulation unless compiled with real MPI with more than one
64 * rank available. However, if we just call mdrun blindly, those cases
65 * trigger an error that is currently fatal to mdrun and also to the
66 * test binary. So, in the meantime we must not test those cases. If
67 * there is no MPI, we disable the test, so that there is a reminder
68 * that it is disabled. There's no elegant way to conditionally
69 * disable a test at run time, so currently there is no feedback if
70 * only one rank is available. However, the test harness knows to run
71 * this test with more than one rank. */
72 TEST_P(MultiSimTest, ExitsNormally)
74 runExitsNormallyTest();
77 TEST_P(MultiSimTest, ExitsNormallyWithDifferentNumbersOfStepsPerSimulation)
81 // MPI setup is not suitable for multi-sim
84 SimulationRunner runner(&fileManager_);
85 runner.useTopGroAndNdxFromDatabase("spc2");
87 // Do some different small numbers of steps in each simulation
88 int numSteps = simulationNumber_ % 4;
89 runGrompp(&runner, numSteps);
91 ASSERT_EQ(0, runner.callMdrun(*mdrunCaller_));
94 /* Note, not all preprocessor implementations nest macro expansions
95 the same way / at all, if we would try to duplicate less code. */
97 INSTANTIATE_TEST_CASE_P(InNvt,
99 ::testing::Combine(::testing::Values(NumRanksPerSimulation(1),
100 NumRanksPerSimulation(2)),
101 ::testing::Values(IntegrationAlgorithm::MD),
102 ::testing::Values(TemperatureCoupling::VRescale),
103 ::testing::Values(PressureCoupling::No)));
105 // Test needs real MPI to run
106 INSTANTIATE_TEST_CASE_P(DISABLED_InNvt,
108 ::testing::Combine(::testing::Values(NumRanksPerSimulation(1),
109 NumRanksPerSimulation(2)),
110 ::testing::Values(IntegrationAlgorithm::MD),
111 ::testing::Values(TemperatureCoupling::VRescale),
112 ::testing::Values(PressureCoupling::No)));
115 //! Convenience typedef
116 typedef MultiSimTest MultiSimTerminationTest;
118 TEST_P(MultiSimTerminationTest, WritesCheckpointAfterMaxhTerminationAndThenRestarts)
123 INSTANTIATE_TEST_CASE_P(InNvt,
124 MultiSimTerminationTest,
125 ::testing::Combine(::testing::Values(NumRanksPerSimulation(1),
126 NumRanksPerSimulation(2)),
127 ::testing::Values(IntegrationAlgorithm::MD),
128 ::testing::Values(TemperatureCoupling::VRescale),
129 ::testing::Values(PressureCoupling::No)));