Reimplement constant acceleration groups
[alexxy/gromacs.git] / src / programs / mdrun / tests / CMakeLists.txt
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2013,2014,2015,2016,2017 The GROMACS development team.
5 # Copyright (c) 2018,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.
9 #
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.
14 #
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.
19 #
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.
24 #
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.
32 #
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.
35
36 # Make a static library for test infrastructure code that we re-use
37 # in multiple test executables across the repository.
38 gmx_add_unit_test_library(mdrun_test_infrastructure
39     energyreader.cpp
40     energycomparison.cpp
41     moduletest.cpp
42     simulatorcomparison.cpp
43     terminationhelper.cpp
44     trajectorycomparison.cpp
45     trajectoryreader.cpp
46     # pseudo-library for code for mdrun
47     $<TARGET_OBJECTS:mdrun_objlib>
48     )
49 target_include_directories(mdrun_test_infrastructure SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/external)
50 target_link_libraries(mdrun_test_infrastructure PUBLIC legacy_api utility)
51
52 # To avoid running into test timeouts, some end-to-end tests of mdrun
53 # functionality are split off. This can be rearranged in future as we
54 # see fit.
55 set(testname "MdrunOutputTests")
56 set(exename "mdrun-output-test")
57
58 gmx_add_gtest_executable(${exename}
59     CPP_SOURCE_FILES
60         compressed_x_output.cpp
61         helpwriting.cpp
62         outputfiles.cpp
63         trajectory_writing.cpp
64         # pseudo-library for code for mdrun
65         $<TARGET_OBJECTS:mdrun_objlib>
66     )
67 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
68 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
69
70 set(testname "MdrunModulesTests")
71 set(exename "mdrun-modules-test")
72
73 gmx_add_gtest_executable(${exename}
74     CPP_SOURCE_FILES
75         densityfittingmodule.cpp
76         interactiveMD.cpp
77         mimic.cpp
78         # pseudo-library for code for mdrun
79         $<TARGET_OBJECTS:mdrun_objlib>
80     )
81 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
82 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
83
84 set(testname "MdrunIOTests")
85 set(exename "mdrun-io-test")
86
87 gmx_add_gtest_executable(${exename}
88     CPP_SOURCE_FILES
89         checkpoint.cpp
90         exactcontinuation.cpp
91         grompp.cpp
92         initialconstraints.cpp
93         termination.cpp
94         # pseudo-library for code for mdrun
95         $<TARGET_OBJECTS:mdrun_objlib>
96     )
97 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
98 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
99
100 # To avoid running into test timeouts, some end-to-end tests of mdrun
101 # functionality are split off. This can be rearranged in future as we
102 # see fit.
103 set(testname "MdrunTests")
104 set(exename "mdrun-test")
105
106 gmx_add_gtest_executable(${exename}
107     CPP_SOURCE_FILES
108         ewaldsurfaceterm.cpp
109         multiple_time_stepping.cpp
110         orires.cpp
111         swapcoords.cpp
112         tabulated_bonded_interactions.cpp
113         freezegroups.cpp
114         constantacceleration.cpp
115         # pseudo-library for code for mdrun
116         $<TARGET_OBJECTS:mdrun_objlib>
117     )
118 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
119 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
120
121
122 set(testname "MdrunPmeTests")
123 set(exename "mdrun-pme-test")
124
125 gmx_add_gtest_executable(${exename}
126     CPP_SOURCE_FILES
127         pmetest.cpp
128         # pseudo-library for code for mdrun
129         $<TARGET_OBJECTS:mdrun_objlib>
130     )
131 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
132 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
133
134
135 set(testname "MdrunNonIntegratorTests")
136 set(exename "mdrun-non-integrator-test")
137
138 gmx_add_gtest_executable(${exename}
139     CPP_SOURCE_FILES
140         # files with code for tests
141         minimize.cpp
142         nonbonded_bench.cpp
143         normalmodes.cpp
144         rerun.cpp
145         simple_mdrun.cpp
146         # pseudo-library for code for mdrun
147         $<TARGET_OBJECTS:mdrun_objlib>
148         )
149 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
150 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
151
152 # TPI does not support OpenMP, so we need a separate test binary
153 set(testname "MdrunTpiTests")
154 set(exename "mdrun-tpi-test")
155
156 gmx_add_gtest_executable(${exename}
157     CPP_SOURCE_FILES
158         # files with code for tests
159         tpitest.cpp
160         # pseudo-library for code for mdrun
161         $<TARGET_OBJECTS:mdrun_objlib>
162         )
163 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
164 gmx_register_gtest_test(${testname} ${exename} INTEGRATION_TEST IGNORE_LEAKS)
165
166 # Tests that only make sense to run with multiple ranks and/or real
167 # MPI are implemented here.
168 set(testname "MdrunMpiTests")
169 set(exename "mdrun-mpi-test")
170
171 gmx_add_gtest_executable(${exename} MPI
172     CPP_SOURCE_FILES
173         # files with code for tests
174         domain_decomposition.cpp
175         minimize.cpp
176         mimic.cpp
177         pmetest.cpp
178         # pseudo-library for code for mdrun
179         $<TARGET_OBJECTS:mdrun_objlib>
180         )
181 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
182 gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
183
184 # Multi sim only makes sense with real MPI, and ideally at least 4 ranks,
185 # to allow for multiple simulations (>= 2 sims) each using DD (>= 2 ranks per sim)
186 set(testname "MdrunMultiSimTests")
187 set(exename "mdrun-multisim-test")
188
189 gmx_add_gtest_executable(${exename} MPI
190     CPP_SOURCE_FILES
191         # files with code for tests
192         multisim.cpp
193         multisimtest.cpp
194         # pseudo-library for code for mdrun
195         $<TARGET_OBJECTS:mdrun_objlib>
196         )
197 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
198 gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 4 INTEGRATION_TEST IGNORE_LEAKS)
199
200 set(testname "MdrunMultiSimReplexTests")
201 set(exename "mdrun-multisim-replex-test")
202
203 gmx_add_gtest_executable(${exename} MPI
204     CPP_SOURCE_FILES
205         # files with code for tests
206         multisimtest.cpp
207         replicaexchange.cpp
208         # pseudo-library for code for mdrun
209         $<TARGET_OBJECTS:mdrun_objlib>
210         )
211 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
212 gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 4 INTEGRATION_TEST IGNORE_LEAKS)
213
214 set(testname "MdrunMultiSimReplexEquivalenceTests")
215 set(exename "mdrun-multisim-replex-equivalence-test")
216
217 gmx_add_gtest_executable(${exename} MPI
218     CPP_SOURCE_FILES
219         # files with code for tests
220         multisimtest.cpp
221         replicaexchange_equivalence.cpp
222         # pseudo-library for code for mdrun
223         $<TARGET_OBJECTS:mdrun_objlib>
224         )
225 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
226 gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 4 INTEGRATION_TEST IGNORE_LEAKS)
227
228 # Tests that only make sense to run with multiple ranks and/or real
229 # MPI are implemented here. Special case for slow PME tests
230 set(testname "MdrunMpiPmeTests")
231 set(exename "mdrun-mpi-pme-test")
232
233 gmx_add_gtest_executable(${exename} MPI
234     CPP_SOURCE_FILES
235         # files with code for tests
236         pmetest.cpp
237         # pseudo-library for code for mdrun
238         $<TARGET_OBJECTS:mdrun_objlib>
239         )
240 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
241 gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
242
243 # Slow-running tests that target testing multiple-rank coordination behaviors
244 # These tests are extremely slow without optimization or OpenMP, so only run them for
245 # build types like Release or RelWithDebInfo and if the build has been configured
246 # with OpenMP enabled
247 set(exename "mdrun-mpi-coordination-basic-test")
248 gmx_add_gtest_executable(${exename} MPI
249     CPP_SOURCE_FILES
250         # files with code for tests
251         periodicactions.cpp
252         periodicactions_basic.cpp
253         # pseudo-library for code for mdrun
254         $<TARGET_OBJECTS:mdrun_objlib>
255         )
256 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
257
258 if (CMAKE_BUILD_TYPE MATCHES "Rel" AND GMX_OPENMP)
259     set(testname "MdrunMpiCoordinationBasicTestsOneRank")
260     gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 1 SLOW_TEST IGNORE_LEAKS)
261     set(testname "MdrunMpiCoordinationBasicTestsTwoRanks")
262     gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 2 SLOW_TEST IGNORE_LEAKS)
263 endif()
264
265 set(exename "mdrun-mpi-coordination-coupling-test")
266 gmx_add_gtest_executable(${exename} MPI
267     CPP_SOURCE_FILES
268         # files with code for tests
269         periodicactions.cpp
270         periodicactions_coupling.cpp
271         # pseudo-library for code for mdrun
272         $<TARGET_OBJECTS:mdrun_objlib>
273         )
274 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
275
276 if (CMAKE_BUILD_TYPE MATCHES "Rel" AND GMX_OPENMP)
277     set(testname "MdrunMpiCoordinationCouplingTestsOneRank")
278     gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 1 SLOW_TEST IGNORE_LEAKS)
279     set(testname "MdrunMpiCoordinationCouplingTestsTwoRanks")
280     gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 2 SLOW_TEST IGNORE_LEAKS)
281 endif()
282
283 set(exename "mdrun-mpi-coordination-constraints-test")
284 gmx_add_gtest_executable(${exename} MPI
285     CPP_SOURCE_FILES
286         # files with code for tests
287         periodicactions.cpp
288         periodicactions_constraints.cpp
289         # pseudo-library for code for mdrun
290         $<TARGET_OBJECTS:mdrun_objlib>
291         )
292 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
293
294 if (CMAKE_BUILD_TYPE MATCHES "Rel" AND GMX_OPENMP)
295     set(testname "MdrunMpiCoordinationConstraintsTestsOneRank")
296     gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 1 SLOW_TEST IGNORE_LEAKS)
297     set(testname "MdrunMpiCoordinationConstraintsTestsTwoRanks")
298     gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 2 SLOW_TEST IGNORE_LEAKS)
299 endif()
300
301 # Keeping the FEP tests separate for now to be able to judge runtime more easily
302 # Can be included in mdrun tests later
303 set(testname "MdrunFEPTests")
304 set(exename "mdrun-fep-test")
305
306 gmx_add_gtest_executable(${exename}
307         CPP_SOURCE_FILES
308         # files with code for tests
309         freeenergy.cpp
310         # pseudo-library for code for mdrun
311         $<TARGET_OBJECTS:mdrun_objlib>
312 )
313 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
314 # TODO: Link specific modules: topology
315
316 # End-to-end test for pull functionality
317 target_link_libraries(${exename} PRIVATE legacy_modules)
318 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
319 set(testname "MdrunPullTests")
320 set(exename "mdrun-pull-test")
321
322 gmx_add_gtest_executable(${exename}
323         CPP_SOURCE_FILES
324         # files with code for tests
325         pull.cpp
326         # pseudo-library for code for mdrun
327         $<TARGET_OBJECTS:mdrun_objlib>
328 )
329 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
330 target_link_libraries(${exename} PRIVATE legacy_modules)
331 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
332
333 # End-to-end tests comparing different simulator code paths
334 set(testname "MdrunSimulatorComparison")
335 set(exename "mdrun-simulator-comparison-test")
336
337 gmx_add_gtest_executable(${exename}
338         CPP_SOURCE_FILES
339         # files with code for tests
340         simulator.cpp
341         # pseudo-library for code for mdrun
342         $<TARGET_OBJECTS:mdrun_objlib>
343         )
344 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
345 gmx_register_gtest_test(${testname} ${exename} OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS)
346
347 # Tests checking virtual sites - we want to run them with multiple ranks
348 set(testname "MdrunVirtualSiteTests")
349 set(exename "mdrun-vsites-test")
350
351 gmx_add_gtest_executable(${exename} MPI
352         CPP_SOURCE_FILES
353         # files with code for tests
354         virtualsites.cpp
355         # pseudo-library for code for mdrun
356         $<TARGET_OBJECTS:mdrun_objlib>
357         )
358 target_link_libraries(${exename} PRIVATE mdrun_test_infrastructure)
359 gmx_register_gtest_test(${testname} ${exename} MPI_RANKS 2 INTEGRATION_TEST IGNORE_LEAKS)