From: Szilárd Páll Date: Fri, 10 Jan 2020 15:37:32 +0000 (+0100) Subject: Fix PME run mode without PME X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=6a5f388db7dad42fd80e4741494a803b4216dfab;p=alexxy%2Fgromacs.git Fix PME run mode without PME pmeRunMode was incorrectly set to CPU when the PME task is not assigned to a GPU in a non-PME run. This change make sure that non-PME runs pmeRunMode is correctly set to None. It also moves this setup code to a function in the taskassignment module. Change-Id: I2c2c609e56d3cb6eef5cfccf2f0489545cedf6ef --- diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index bae0c18e96..b66f487291 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -729,12 +729,11 @@ int Mdrunner::mdrunner() userGpuTaskAssignment = parseUserTaskAssignmentString(hw_opt.userGpuTaskAssignment); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR - auto nonbondedTarget = findTaskTarget(nbpu_opt); - auto pmeTarget = findTaskTarget(pme_opt); - auto pmeFftTarget = findTaskTarget(pme_fft_opt); - auto bondedTarget = findTaskTarget(bonded_opt); - auto updateTarget = findTaskTarget(update_opt); - PmeRunMode pmeRunMode = PmeRunMode::None; + auto nonbondedTarget = findTaskTarget(nbpu_opt); + auto pmeTarget = findTaskTarget(pme_opt); + auto pmeFftTarget = findTaskTarget(pme_fft_opt); + auto bondedTarget = findTaskTarget(bonded_opt); + auto updateTarget = findTaskTarget(update_opt); FILE* fplog = nullptr; // If we are appending, we don't write log output because we need @@ -884,24 +883,11 @@ int Mdrunner::mdrunner() useGpuForNonbonded, useGpuForPme, bondedTarget, canUseGpuForBonded, EVDW_PME(inputrec->vdwtype), EEL_PME_EWALD(inputrec->coulombtype), domdecOptions.numPmeRanks, gpusWereDetected); - - pmeRunMode = (useGpuForPme ? PmeRunMode::GPU : PmeRunMode::CPU); - if (pmeRunMode == PmeRunMode::GPU) - { - if (pmeFftTarget == TaskTarget::Cpu) - { - pmeRunMode = PmeRunMode::Mixed; - } - } - else if (pmeFftTarget == TaskTarget::Gpu) - { - gmx_fatal(FARGS, - "Assigning FFTs to GPU requires PME to be assigned to GPU as well. With PME " - "on CPU you should not be using -pmefft."); - } } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR + const PmeRunMode pmeRunMode = determinePmeRunMode(useGpuForPme, pmeFftTarget, *inputrec); + // Initialize development feature flags that enabled by environment variable // and report those features that are enabled. const DevelopmentFeatureFlags devFlags = diff --git a/src/gromacs/taskassignment/decidegpuusage.cpp b/src/gromacs/taskassignment/decidegpuusage.cpp index 3974e7b013..ea249317da 100644 --- a/src/gromacs/taskassignment/decidegpuusage.cpp +++ b/src/gromacs/taskassignment/decidegpuusage.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -428,6 +428,37 @@ bool decideWhetherToUseGpusForPme(const bool useGpuForNonbonded, return false; } + +PmeRunMode determinePmeRunMode(const bool useGpuForPme, const TaskTarget& pmeFftTarget, const t_inputrec& inputrec) +{ + if (!EEL_PME(inputrec.coulombtype)) + { + return PmeRunMode::None; + } + + if (useGpuForPme) + { + if (pmeFftTarget == TaskTarget::Cpu) + { + return PmeRunMode::Mixed; + } + else + { + return PmeRunMode::GPU; + } + } + else + { + if (pmeFftTarget == TaskTarget::Gpu) + { + gmx_fatal(FARGS, + "Assigning FFTs to GPU requires PME to be assigned to GPU as well. With PME " + "on CPU you should not be using -pmefft."); + } + return PmeRunMode::CPU; + } +} + bool decideWhetherToUseGpusForBonded(const bool useGpuForNonbonded, const bool useGpuForPme, const TaskTarget bondedTarget, diff --git a/src/gromacs/taskassignment/decidegpuusage.h b/src/gromacs/taskassignment/decidegpuusage.h index 6d22cf843a..921b0a778b 100644 --- a/src/gromacs/taskassignment/decidegpuusage.h +++ b/src/gromacs/taskassignment/decidegpuusage.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -209,6 +209,20 @@ bool decideWhetherToUseGpusForPme(bool useGpuForNonbonded, int numPmeRanksPerSimulation, bool gpusWereDetected); +/*! \brief Determine PME run mode. + * + * Given the PME task assignment in \p useGpuForPme and the user-provided + * FFT task target in \p pmeFftTarget, returns a PME run mode for the + * current run. It also checks the compatibility of the two. + * + * \note Aborts the run upon incompatible values of \p useGpuForPme and \p pmeFftTarget. + * + * \param[in] useGpuForPme PME task assignment, true if PME task is mapped to the GPU. + * \param[in] pmeFftTarget The user's choice for -pmefft for where to assign the FFT + * work of the PME task. \param[in] inputrec The user input record + * */ +PmeRunMode determinePmeRunMode(bool useGpuForPme, const TaskTarget& pmeFftTarget, const t_inputrec& inputrec); + /*! \brief Decide whether the simulation will try to run bonded tasks on GPUs. * * \param[in] useGpuForNonbonded Whether GPUs will be used for nonbonded interactions.