2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * \brief SETTLE tests runners.
38 * Declares test runner class for SETTLE algorithm. The test runners abstract
39 * class is used to unify the interfaces for CPU and GPU implementations of the
40 * SETTLE algorithm. This allows to run the same test on the same data using
41 * different implementations of the parent class, that inherit its interfaces.
43 * \author Artem Zhmurov <zhmurov@gmail.com>
44 * \ingroup module_mdlib
46 #ifndef GMX_MDLIB_TESTS_SETTLETESTRUNNERS_H
47 #define GMX_MDLIB_TESTS_SETTLETESTRUNNERS_H
49 #include <gtest/gtest.h>
51 #include "testutils/test_device.h"
53 #include "settletestdata.h"
62 /* \brief SETTLE test runner interface.
64 * Wraps the actual implementation of SETTLE into common interface.
66 class ISettleTestRunner
69 //! Virtual destructor.
70 virtual ~ISettleTestRunner() {}
72 /*! \brief Apply SETTLE using CPU version of the algorithm
74 * Initializes SETTLE object, applies algorithm, destroys the object. The coordinates, velocities
75 * and virial are updated in the testData object.
77 * \param[in,out] testData An object, containing all the data structures needed by SETTLE.
78 * \param[in] pbc Periodic boundary setup.
79 * \param[in] updateVelocities If the velocities should be updated.
80 * \param[in] calcVirial If the virial should be computed.
81 * \param[in] testDescription Brief description that will be printed in case of test failure.
83 virtual void applySettle(SettleTestData
* testData
,
85 bool updateVelocities
,
87 const std::string
& testDescription
) = 0;
88 /*! \brief Get the hardware description
90 * \returns A string, describing hardware used by the runner.
92 virtual std::string
hardwareDescription() = 0;
95 // Runner for the CPU implementation of SETTLE.
96 class SettleHostTestRunner
: public ISettleTestRunner
99 //! Default constructor.
100 SettleHostTestRunner() {}
101 /*! \brief Apply SETTLE using CPU version of the algorithm
103 * Initializes SETTLE object, applies algorithm, destroys the object. The coordinates, velocities
104 * and virial are updated in the testData object.
106 * \param[in,out] testData An object, containing all the data structures needed by SETTLE.
107 * \param[in] pbc Periodic boundary setup.
108 * \param[in] updateVelocities If the velocities should be updated.
109 * \param[in] calcVirial If the virial should be computed.
110 * \param[in] testDescription Brief description that will be printed in case of test failure.
112 void applySettle(SettleTestData
* testData
,
114 bool updateVelocities
,
116 const std::string
& testDescription
) override
;
117 /*! \brief Get the hardware description
119 * \returns "CPU" string.
121 std::string
hardwareDescription() override
{ return "CPU"; }
124 // Runner for the GPU implementation of SETTLE.
125 class SettleDeviceTestRunner
: public ISettleTestRunner
128 /*! \brief Constructor. Keeps a copy of the hardware context.
130 * \param[in] testDevice The device hardware context to be used by the runner.
132 SettleDeviceTestRunner(const TestDevice
& testDevice
) : testDevice_(testDevice
) {}
133 /*! \brief Apply SETTLE using GPU version of the algorithm
135 * Initializes SETTLE object, copied data to the GPU, applies algorithm, copies the data back,
136 * destroys the object. The coordinates, velocities and virial are updated in the testData object.
138 * \param[in,out] testData An object, containing all the data structures needed by SETTLE.
139 * \param[in] pbc Periodic boundary setup.
140 * \param[in] updateVelocities If the velocities should be updated.
141 * \param[in] calcVirial If the virial should be computed.
142 * \param[in] testDescription Brief description that will be printed in case of test failure.
144 void applySettle(SettleTestData
* testData
,
146 bool updateVelocities
,
148 const std::string
& testDescription
) override
;
149 /*! \brief Get the hardware description
151 * \returns A string with GPU description.
153 std::string
hardwareDescription() override
{ return testDevice_
.description(); }
156 //! Test test device to be used in the runner.
157 const TestDevice
& testDevice_
;
163 #endif // GMX_MDLIB_TESTS_SETTLETESTRUNNERS_H