2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019,2020,2021, 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.
37 * Defines routine for building simulation workload task description.
39 * \author Paul Bauer <paul.bauer.q@gmail.com>
40 * \ingroup module_taskassignment
44 #include "decidesimulationworkload.h"
46 #include "gromacs/ewald/pme.h"
47 #include "gromacs/mdtypes/multipletimestepping.h"
48 #include "gromacs/taskassignment/decidegpuusage.h"
49 #include "gromacs/taskassignment/taskassignment.h"
50 #include "gromacs/utility/arrayref.h"
55 SimulationWorkload createSimulationWorkload(const t_inputrec& inputrec,
56 const bool disableNonbondedCalculation,
57 const DevelopmentFeatureFlags& devFlags,
58 bool havePpDomainDecomposition,
59 bool haveSeparatePmeRank,
60 bool useGpuForNonbonded,
61 PmeRunMode pmeRunMode,
64 bool useGpuDirectHalo)
66 SimulationWorkload simulationWorkload;
67 simulationWorkload.computeNonbonded = !disableNonbondedCalculation;
68 simulationWorkload.computeNonbondedAtMtsLevel1 =
69 simulationWorkload.computeNonbonded && inputrec.useMts
70 && inputrec.mtsLevels.back().forceGroups[static_cast<int>(MtsForceGroups::Nonbonded)];
71 simulationWorkload.computeMuTot = inputrecNeedMutot(&inputrec);
72 simulationWorkload.useCpuNonbonded = !useGpuForNonbonded;
73 simulationWorkload.useGpuNonbonded = useGpuForNonbonded;
74 simulationWorkload.useCpuPme = (pmeRunMode == PmeRunMode::CPU);
75 simulationWorkload.useGpuPme = (pmeRunMode == PmeRunMode::GPU || pmeRunMode == PmeRunMode::Mixed);
76 simulationWorkload.useGpuPmeFft = (pmeRunMode == PmeRunMode::Mixed);
77 simulationWorkload.useGpuBonded = useGpuForBonded;
78 simulationWorkload.useGpuUpdate = useGpuForUpdate;
79 simulationWorkload.useGpuBufferOps =
80 (devFlags.enableGpuBufferOps || useGpuForUpdate) && !inputrec.useMts;
81 simulationWorkload.havePpDomainDecomposition = havePpDomainDecomposition;
82 simulationWorkload.useCpuHaloExchange = havePpDomainDecomposition && !useGpuDirectHalo;
83 simulationWorkload.useGpuHaloExchange = useGpuDirectHalo;
84 if (pmeRunMode == PmeRunMode::None)
86 GMX_RELEASE_ASSERT(!haveSeparatePmeRank, "Can not have separate PME rank(s) without PME.");
88 simulationWorkload.haveSeparatePmeRank = haveSeparatePmeRank;
89 simulationWorkload.useGpuPmePpCommunication =
90 haveSeparatePmeRank && devFlags.enableGpuPmePPComm && (pmeRunMode == PmeRunMode::GPU);
91 simulationWorkload.useCpuPmePpCommunication =
92 haveSeparatePmeRank && !simulationWorkload.useGpuPmePpCommunication;
93 GMX_RELEASE_ASSERT(!(simulationWorkload.useGpuPmePpCommunication
94 && simulationWorkload.useCpuPmePpCommunication),
95 "Cannot do PME-PP communication on both CPU and GPU");
96 simulationWorkload.useGpuDirectCommunication =
97 devFlags.enableGpuHaloExchange || devFlags.enableGpuPmePPComm;
98 simulationWorkload.haveEwaldSurfaceContribution = haveEwaldSurfaceContribution(inputrec);
99 simulationWorkload.useMts = inputrec.useMts;
101 return simulationWorkload;