hillclimber 0.1.6__cp313-cp313-macosx_15_0_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hillclimber/__init__.py +41 -0
- hillclimber/actions.py +53 -0
- hillclimber/analysis.py +590 -0
- hillclimber/biases.py +293 -0
- hillclimber/calc.py +22 -0
- hillclimber/cvs.py +1070 -0
- hillclimber/interfaces.py +133 -0
- hillclimber/metadynamics.py +416 -0
- hillclimber/nodes.py +6 -0
- hillclimber/opes.py +359 -0
- hillclimber/pycv.py +362 -0
- hillclimber/selectors.py +230 -0
- hillclimber/virtual_atoms.py +341 -0
- hillclimber-0.1.6.dist-info/METADATA +325 -0
- hillclimber-0.1.6.dist-info/RECORD +468 -0
- hillclimber-0.1.6.dist-info/WHEEL +6 -0
- hillclimber-0.1.6.dist-info/entry_points.txt +8 -0
- hillclimber-0.1.6.dist-info/licenses/LICENSE +165 -0
- plumed/__init__.py +104 -0
- plumed/_lib/bin/plumed +0 -0
- plumed/_lib/bin/plumed-config +9 -0
- plumed/_lib/bin/plumed-patch +9 -0
- plumed/_lib/include/plumed/adjmat/AdjacencyMatrixBase.h +659 -0
- plumed/_lib/include/plumed/adjmat/ContactMatrix.h +59 -0
- plumed/_lib/include/plumed/asmjit/arch.h +228 -0
- plumed/_lib/include/plumed/asmjit/arm.h +43 -0
- plumed/_lib/include/plumed/asmjit/asmjit.h +69 -0
- plumed/_lib/include/plumed/asmjit/asmjit_apibegin.h +143 -0
- plumed/_lib/include/plumed/asmjit/asmjit_apiend.h +93 -0
- plumed/_lib/include/plumed/asmjit/asmjit_build.h +971 -0
- plumed/_lib/include/plumed/asmjit/assembler.h +183 -0
- plumed/_lib/include/plumed/asmjit/base.h +56 -0
- plumed/_lib/include/plumed/asmjit/codebuilder.h +944 -0
- plumed/_lib/include/plumed/asmjit/codecompiler.h +767 -0
- plumed/_lib/include/plumed/asmjit/codeemitter.h +528 -0
- plumed/_lib/include/plumed/asmjit/codeholder.h +777 -0
- plumed/_lib/include/plumed/asmjit/constpool.h +286 -0
- plumed/_lib/include/plumed/asmjit/cpuinfo.h +402 -0
- plumed/_lib/include/plumed/asmjit/func.h +1327 -0
- plumed/_lib/include/plumed/asmjit/globals.h +370 -0
- plumed/_lib/include/plumed/asmjit/inst.h +137 -0
- plumed/_lib/include/plumed/asmjit/logging.h +317 -0
- plumed/_lib/include/plumed/asmjit/misc_p.h +103 -0
- plumed/_lib/include/plumed/asmjit/moved_string.h +318 -0
- plumed/_lib/include/plumed/asmjit/operand.h +1599 -0
- plumed/_lib/include/plumed/asmjit/osutils.h +207 -0
- plumed/_lib/include/plumed/asmjit/regalloc_p.h +597 -0
- plumed/_lib/include/plumed/asmjit/runtime.h +227 -0
- plumed/_lib/include/plumed/asmjit/simdtypes.h +1104 -0
- plumed/_lib/include/plumed/asmjit/utils.h +1387 -0
- plumed/_lib/include/plumed/asmjit/vmem.h +183 -0
- plumed/_lib/include/plumed/asmjit/x86.h +45 -0
- plumed/_lib/include/plumed/asmjit/x86assembler.h +125 -0
- plumed/_lib/include/plumed/asmjit/x86builder.h +117 -0
- plumed/_lib/include/plumed/asmjit/x86compiler.h +322 -0
- plumed/_lib/include/plumed/asmjit/x86emitter.h +5149 -0
- plumed/_lib/include/plumed/asmjit/x86globals.h +535 -0
- plumed/_lib/include/plumed/asmjit/x86inst.h +2547 -0
- plumed/_lib/include/plumed/asmjit/x86instimpl_p.h +74 -0
- plumed/_lib/include/plumed/asmjit/x86internal_p.h +108 -0
- plumed/_lib/include/plumed/asmjit/x86logging_p.h +92 -0
- plumed/_lib/include/plumed/asmjit/x86misc.h +417 -0
- plumed/_lib/include/plumed/asmjit/x86operand.h +1133 -0
- plumed/_lib/include/plumed/asmjit/x86regalloc_p.h +734 -0
- plumed/_lib/include/plumed/asmjit/zone.h +1157 -0
- plumed/_lib/include/plumed/bias/Bias.h +82 -0
- plumed/_lib/include/plumed/bias/ReweightBase.h +58 -0
- plumed/_lib/include/plumed/blas/blas.h +253 -0
- plumed/_lib/include/plumed/blas/def_external.h +61 -0
- plumed/_lib/include/plumed/blas/def_internal.h +97 -0
- plumed/_lib/include/plumed/blas/real.h +49 -0
- plumed/_lib/include/plumed/cltools/CLTool.h +32 -0
- plumed/_lib/include/plumed/clusters/ClusteringBase.h +70 -0
- plumed/_lib/include/plumed/colvar/Colvar.h +32 -0
- plumed/_lib/include/plumed/colvar/ColvarInput.h +68 -0
- plumed/_lib/include/plumed/colvar/ColvarShortcut.h +81 -0
- plumed/_lib/include/plumed/colvar/CoordinationBase.h +52 -0
- plumed/_lib/include/plumed/colvar/MultiColvarTemplate.h +333 -0
- plumed/_lib/include/plumed/colvar/PathMSDBase.h +101 -0
- plumed/_lib/include/plumed/colvar/RMSDVector.h +78 -0
- plumed/_lib/include/plumed/config/Config.h +118 -0
- plumed/_lib/include/plumed/config/version.h +9 -0
- plumed/_lib/include/plumed/contour/ContourFindingObject.h +87 -0
- plumed/_lib/include/plumed/contour/DistanceFromContourBase.h +82 -0
- plumed/_lib/include/plumed/contour/FindContour.h +67 -0
- plumed/_lib/include/plumed/core/Action.h +540 -0
- plumed/_lib/include/plumed/core/ActionAnyorder.h +48 -0
- plumed/_lib/include/plumed/core/ActionAtomistic.h +343 -0
- plumed/_lib/include/plumed/core/ActionForInterface.h +99 -0
- plumed/_lib/include/plumed/core/ActionPilot.h +57 -0
- plumed/_lib/include/plumed/core/ActionRegister.h +124 -0
- plumed/_lib/include/plumed/core/ActionSet.h +163 -0
- plumed/_lib/include/plumed/core/ActionSetup.h +48 -0
- plumed/_lib/include/plumed/core/ActionShortcut.h +73 -0
- plumed/_lib/include/plumed/core/ActionToGetData.h +59 -0
- plumed/_lib/include/plumed/core/ActionToPutData.h +101 -0
- plumed/_lib/include/plumed/core/ActionWithArguments.h +140 -0
- plumed/_lib/include/plumed/core/ActionWithMatrix.h +87 -0
- plumed/_lib/include/plumed/core/ActionWithValue.h +258 -0
- plumed/_lib/include/plumed/core/ActionWithVector.h +94 -0
- plumed/_lib/include/plumed/core/ActionWithVirtualAtom.h +123 -0
- plumed/_lib/include/plumed/core/CLTool.h +177 -0
- plumed/_lib/include/plumed/core/CLToolMain.h +102 -0
- plumed/_lib/include/plumed/core/CLToolRegister.h +108 -0
- plumed/_lib/include/plumed/core/Colvar.h +115 -0
- plumed/_lib/include/plumed/core/DataPassingObject.h +94 -0
- plumed/_lib/include/plumed/core/DataPassingTools.h +54 -0
- plumed/_lib/include/plumed/core/DomainDecomposition.h +120 -0
- plumed/_lib/include/plumed/core/ExchangePatterns.h +47 -0
- plumed/_lib/include/plumed/core/FlexibleBin.h +63 -0
- plumed/_lib/include/plumed/core/GREX.h +61 -0
- plumed/_lib/include/plumed/core/GenericMolInfo.h +89 -0
- plumed/_lib/include/plumed/core/Group.h +41 -0
- plumed/_lib/include/plumed/core/ModuleMap.h +30 -0
- plumed/_lib/include/plumed/core/ParallelTaskManager.h +1023 -0
- plumed/_lib/include/plumed/core/PbcAction.h +61 -0
- plumed/_lib/include/plumed/core/PlumedMain.h +632 -0
- plumed/_lib/include/plumed/core/PlumedMainInitializer.h +118 -0
- plumed/_lib/include/plumed/core/RegisterBase.h +340 -0
- plumed/_lib/include/plumed/core/TargetDist.h +48 -0
- plumed/_lib/include/plumed/core/Value.h +547 -0
- plumed/_lib/include/plumed/core/WithCmd.h +93 -0
- plumed/_lib/include/plumed/dimred/SMACOF.h +55 -0
- plumed/_lib/include/plumed/drr/DRR.h +383 -0
- plumed/_lib/include/plumed/drr/colvar_UIestimator.h +777 -0
- plumed/_lib/include/plumed/fisst/legendre_rule_fast.h +44 -0
- plumed/_lib/include/plumed/function/Custom.h +54 -0
- plumed/_lib/include/plumed/function/Function.h +85 -0
- plumed/_lib/include/plumed/function/FunctionOfMatrix.h +368 -0
- plumed/_lib/include/plumed/function/FunctionOfScalar.h +135 -0
- plumed/_lib/include/plumed/function/FunctionOfVector.h +296 -0
- plumed/_lib/include/plumed/function/FunctionSetup.h +180 -0
- plumed/_lib/include/plumed/function/FunctionShortcut.h +130 -0
- plumed/_lib/include/plumed/function/FunctionWithSingleArgument.h +165 -0
- plumed/_lib/include/plumed/gridtools/ActionWithGrid.h +43 -0
- plumed/_lib/include/plumed/gridtools/EvaluateGridFunction.h +99 -0
- plumed/_lib/include/plumed/gridtools/FunctionOfGrid.h +295 -0
- plumed/_lib/include/plumed/gridtools/GridCoordinatesObject.h +179 -0
- plumed/_lib/include/plumed/gridtools/GridSearch.h +135 -0
- plumed/_lib/include/plumed/gridtools/Interpolator.h +45 -0
- plumed/_lib/include/plumed/gridtools/KDE.h +455 -0
- plumed/_lib/include/plumed/gridtools/RDF.h +40 -0
- plumed/_lib/include/plumed/gridtools/SumOfKernels.h +219 -0
- plumed/_lib/include/plumed/isdb/MetainferenceBase.h +398 -0
- plumed/_lib/include/plumed/lapack/def_external.h +207 -0
- plumed/_lib/include/plumed/lapack/def_internal.h +388 -0
- plumed/_lib/include/plumed/lapack/lapack.h +899 -0
- plumed/_lib/include/plumed/lapack/lapack_limits.h +79 -0
- plumed/_lib/include/plumed/lapack/real.h +50 -0
- plumed/_lib/include/plumed/lepton/CompiledExpression.h +164 -0
- plumed/_lib/include/plumed/lepton/CustomFunction.h +143 -0
- plumed/_lib/include/plumed/lepton/Exception.h +93 -0
- plumed/_lib/include/plumed/lepton/ExpressionProgram.h +137 -0
- plumed/_lib/include/plumed/lepton/ExpressionTreeNode.h +145 -0
- plumed/_lib/include/plumed/lepton/Lepton.h +85 -0
- plumed/_lib/include/plumed/lepton/MSVC_erfc.h +123 -0
- plumed/_lib/include/plumed/lepton/Operation.h +1302 -0
- plumed/_lib/include/plumed/lepton/ParsedExpression.h +165 -0
- plumed/_lib/include/plumed/lepton/Parser.h +111 -0
- plumed/_lib/include/plumed/lepton/windowsIncludes.h +73 -0
- plumed/_lib/include/plumed/mapping/Path.h +44 -0
- plumed/_lib/include/plumed/mapping/PathProjectionCalculator.h +57 -0
- plumed/_lib/include/plumed/matrixtools/MatrixOperationBase.h +54 -0
- plumed/_lib/include/plumed/matrixtools/MatrixTimesMatrix.h +309 -0
- plumed/_lib/include/plumed/matrixtools/MatrixTimesVectorBase.h +365 -0
- plumed/_lib/include/plumed/matrixtools/OuterProduct.h +238 -0
- plumed/_lib/include/plumed/maze/Core.h +65 -0
- plumed/_lib/include/plumed/maze/Loss.h +86 -0
- plumed/_lib/include/plumed/maze/Member.h +66 -0
- plumed/_lib/include/plumed/maze/Memetic.h +799 -0
- plumed/_lib/include/plumed/maze/Optimizer.h +357 -0
- plumed/_lib/include/plumed/maze/Random_MT.h +156 -0
- plumed/_lib/include/plumed/maze/Tools.h +183 -0
- plumed/_lib/include/plumed/metatomic/vesin.h +188 -0
- plumed/_lib/include/plumed/molfile/Gromacs.h +2013 -0
- plumed/_lib/include/plumed/molfile/endianswap.h +217 -0
- plumed/_lib/include/plumed/molfile/fastio.h +683 -0
- plumed/_lib/include/plumed/molfile/largefiles.h +78 -0
- plumed/_lib/include/plumed/molfile/libmolfile_plugin.h +77 -0
- plumed/_lib/include/plumed/molfile/molfile_plugin.h +1034 -0
- plumed/_lib/include/plumed/molfile/periodic_table.h +248 -0
- plumed/_lib/include/plumed/molfile/readpdb.h +447 -0
- plumed/_lib/include/plumed/molfile/vmdplugin.h +236 -0
- plumed/_lib/include/plumed/multicolvar/MultiColvarShortcuts.h +45 -0
- plumed/_lib/include/plumed/opes/ExpansionCVs.h +79 -0
- plumed/_lib/include/plumed/sasa/Sasa.h +32 -0
- plumed/_lib/include/plumed/secondarystructure/SecondaryStructureBase.h +372 -0
- plumed/_lib/include/plumed/setup/ActionSetup.h +25 -0
- plumed/_lib/include/plumed/small_vector/small_vector.h +6114 -0
- plumed/_lib/include/plumed/symfunc/CoordinationNumbers.h +41 -0
- plumed/_lib/include/plumed/tools/Angle.h +52 -0
- plumed/_lib/include/plumed/tools/AtomDistribution.h +138 -0
- plumed/_lib/include/plumed/tools/AtomNumber.h +152 -0
- plumed/_lib/include/plumed/tools/BiasRepresentation.h +106 -0
- plumed/_lib/include/plumed/tools/BitmaskEnum.h +167 -0
- plumed/_lib/include/plumed/tools/Brent1DRootSearch.h +159 -0
- plumed/_lib/include/plumed/tools/CheckInRange.h +44 -0
- plumed/_lib/include/plumed/tools/Citations.h +74 -0
- plumed/_lib/include/plumed/tools/ColvarOutput.h +118 -0
- plumed/_lib/include/plumed/tools/Communicator.h +316 -0
- plumed/_lib/include/plumed/tools/ConjugateGradient.h +80 -0
- plumed/_lib/include/plumed/tools/DLLoader.h +79 -0
- plumed/_lib/include/plumed/tools/ERMSD.h +73 -0
- plumed/_lib/include/plumed/tools/Exception.h +406 -0
- plumed/_lib/include/plumed/tools/File.h +28 -0
- plumed/_lib/include/plumed/tools/FileBase.h +153 -0
- plumed/_lib/include/plumed/tools/FileTools.h +37 -0
- plumed/_lib/include/plumed/tools/ForwardDecl.h +54 -0
- plumed/_lib/include/plumed/tools/Grid.h +638 -0
- plumed/_lib/include/plumed/tools/HistogramBead.h +136 -0
- plumed/_lib/include/plumed/tools/IFile.h +117 -0
- plumed/_lib/include/plumed/tools/KernelFunctions.h +113 -0
- plumed/_lib/include/plumed/tools/Keywords.h +380 -0
- plumed/_lib/include/plumed/tools/LatticeReduction.h +66 -0
- plumed/_lib/include/plumed/tools/LeptonCall.h +64 -0
- plumed/_lib/include/plumed/tools/LinkCells.h +126 -0
- plumed/_lib/include/plumed/tools/Log.h +41 -0
- plumed/_lib/include/plumed/tools/LoopUnroller.h +163 -0
- plumed/_lib/include/plumed/tools/Matrix.h +721 -0
- plumed/_lib/include/plumed/tools/MatrixSquareBracketsAccess.h +138 -0
- plumed/_lib/include/plumed/tools/MergeVectorTools.h +153 -0
- plumed/_lib/include/plumed/tools/Minimise1DBrent.h +244 -0
- plumed/_lib/include/plumed/tools/MinimiseBase.h +120 -0
- plumed/_lib/include/plumed/tools/MolDataClass.h +51 -0
- plumed/_lib/include/plumed/tools/NeighborList.h +112 -0
- plumed/_lib/include/plumed/tools/OFile.h +286 -0
- plumed/_lib/include/plumed/tools/OpenACC.h +180 -0
- plumed/_lib/include/plumed/tools/OpenMP.h +75 -0
- plumed/_lib/include/plumed/tools/PDB.h +154 -0
- plumed/_lib/include/plumed/tools/Pbc.h +139 -0
- plumed/_lib/include/plumed/tools/PlumedHandle.h +105 -0
- plumed/_lib/include/plumed/tools/RMSD.h +493 -0
- plumed/_lib/include/plumed/tools/Random.h +80 -0
- plumed/_lib/include/plumed/tools/RootFindingBase.h +79 -0
- plumed/_lib/include/plumed/tools/Stopwatch.h +475 -0
- plumed/_lib/include/plumed/tools/Subprocess.h +142 -0
- plumed/_lib/include/plumed/tools/SwitchingFunction.h +208 -0
- plumed/_lib/include/plumed/tools/Tensor.h +724 -0
- plumed/_lib/include/plumed/tools/TokenizedLine.h +123 -0
- plumed/_lib/include/plumed/tools/Tools.h +638 -0
- plumed/_lib/include/plumed/tools/Torsion.h +55 -0
- plumed/_lib/include/plumed/tools/TrajectoryParser.h +118 -0
- plumed/_lib/include/plumed/tools/Tree.h +61 -0
- plumed/_lib/include/plumed/tools/TypesafePtr.h +463 -0
- plumed/_lib/include/plumed/tools/Units.h +167 -0
- plumed/_lib/include/plumed/tools/Vector.h +433 -0
- plumed/_lib/include/plumed/tools/View.h +296 -0
- plumed/_lib/include/plumed/tools/View2D.h +100 -0
- plumed/_lib/include/plumed/tools/h36.h +39 -0
- plumed/_lib/include/plumed/vatom/ActionWithVirtualAtom.h +32 -0
- plumed/_lib/include/plumed/ves/BasisFunctions.h +380 -0
- plumed/_lib/include/plumed/ves/CoeffsBase.h +310 -0
- plumed/_lib/include/plumed/ves/CoeffsMatrix.h +220 -0
- plumed/_lib/include/plumed/ves/CoeffsVector.h +251 -0
- plumed/_lib/include/plumed/ves/FermiSwitchingFunction.h +74 -0
- plumed/_lib/include/plumed/ves/GridIntegrationWeights.h +50 -0
- plumed/_lib/include/plumed/ves/GridLinearInterpolation.h +81 -0
- plumed/_lib/include/plumed/ves/GridProjWeights.h +61 -0
- plumed/_lib/include/plumed/ves/LinearBasisSetExpansion.h +303 -0
- plumed/_lib/include/plumed/ves/Optimizer.h +444 -0
- plumed/_lib/include/plumed/ves/TargetDistModifer.h +53 -0
- plumed/_lib/include/plumed/ves/TargetDistribution.h +266 -0
- plumed/_lib/include/plumed/ves/VesBias.h +545 -0
- plumed/_lib/include/plumed/ves/VesTools.h +142 -0
- plumed/_lib/include/plumed/ves/WaveletGrid.h +75 -0
- plumed/_lib/include/plumed/volumes/ActionVolume.h +268 -0
- plumed/_lib/include/plumed/volumes/VolumeShortcut.h +147 -0
- plumed/_lib/include/plumed/wrapper/Plumed.h +5025 -0
- plumed/_lib/include/plumed/xdrfile/xdrfile.h +663 -0
- plumed/_lib/include/plumed/xdrfile/xdrfile_trr.h +89 -0
- plumed/_lib/include/plumed/xdrfile/xdrfile_xtc.h +90 -0
- plumed/_lib/lib/PythonCVInterface.dylib +0 -0
- plumed/_lib/lib/libplumed.dylib +0 -0
- plumed/_lib/lib/libplumedKernel.dylib +0 -0
- plumed/_lib/lib/libplumedWrapper.a +0 -0
- plumed/_lib/lib/pkgconfig/plumed.pc +13 -0
- plumed/_lib/lib/pkgconfig/plumedInternals.pc +13 -0
- plumed/_lib/lib/pkgconfig/plumedWrapper.pc +13 -0
- plumed/_lib/lib/plumed/fortran/plumed.f90 +879 -0
- plumed/_lib/lib/plumed/fortran/plumed_f08.f90 +2625 -0
- plumed/_lib/lib/plumed/modulefile +69 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.config +43 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt +543 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt.preplumed +540 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp +1628 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1590 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h +103 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h.preplumed +99 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp +2527 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2513 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +408 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +394 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp +2348 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2091 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp +3573 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3495 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1506 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1402 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp +997 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +906 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp +2780 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2738 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
- plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.config +43 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt +549 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt.preplumed +546 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h +104 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp +2624 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2610 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +409 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +395 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp +2419 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2164 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp +3546 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3468 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp +991 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +900 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp +2895 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2849 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp +886 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +880 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +347 -0
- plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +345 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.config +43 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt +575 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt.preplumed +572 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h +104 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp +2564 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2550 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h +410 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +396 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp +2435 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp.preplumed +2187 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp +3592 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3514 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp +958 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp.preplumed +929 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp +2987 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp.preplumed +2941 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp +904 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +898 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +353 -0
- plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +351 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.config +39 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake +82 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake.preplumed +82 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp +162 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp.preplumed +154 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp +107 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp.preplumed +99 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h +120 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h.preplumed +111 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp +215 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp.preplumed +197 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h +87 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h.preplumed +86 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp +2971 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp.preplumed +2970 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h +430 -0
- plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h.preplumed +429 -0
- plumed/_lib/lib/plumed/patches/namd-2.12.config +30 -0
- plumed/_lib/lib/plumed/patches/namd-2.12.diff +267 -0
- plumed/_lib/lib/plumed/patches/namd-2.13.config +30 -0
- plumed/_lib/lib/plumed/patches/namd-2.13.diff +267 -0
- plumed/_lib/lib/plumed/patches/namd-2.14.config +30 -0
- plumed/_lib/lib/plumed/patches/namd-2.14.diff +268 -0
- plumed/_lib/lib/plumed/patches/patch.sh +500 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.config +25 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90 +368 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90.preplumed +366 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90 +71 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90.preplumed +24 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90 +62 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90 +189 -0
- plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90.preplumed +185 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.config +26 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90 +422 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90.preplumed +420 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 +70 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90 +62 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90 +233 -0
- plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90.preplumed +230 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.config +28 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile +175 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile.preplumed +171 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90 +486 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90.preplumed +484 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 +74 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90 +64 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90 +532 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90.preplumed +518 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.config +28 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile +249 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile.preplumed +244 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90 +532 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90.preplumed +535 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90 +74 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90 +64 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90 +569 -0
- plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90.preplumed +560 -0
- plumed/_lib/lib/plumed/plumed-config +9 -0
- plumed/_lib/lib/plumed/plumed-mklib +9 -0
- plumed/_lib/lib/plumed/plumed-newcv +9 -0
- plumed/_lib/lib/plumed/plumed-partial_tempering +9 -0
- plumed/_lib/lib/plumed/plumed-patch +9 -0
- plumed/_lib/lib/plumed/plumed-runtime +0 -0
- plumed/_lib/lib/plumed/plumed-selector +9 -0
- plumed/_lib/lib/plumed/plumed-vim2html +9 -0
- plumed/_lib/lib/plumed/scripts/config.sh +126 -0
- plumed/_lib/lib/plumed/scripts/mklib.sh +175 -0
- plumed/_lib/lib/plumed/scripts/newcv.sh +26 -0
- plumed/_lib/lib/plumed/scripts/partial_tempering.sh +319 -0
- plumed/_lib/lib/plumed/scripts/patch.sh +4 -0
- plumed/_lib/lib/plumed/scripts/selector.sh +234 -0
- plumed/_lib/lib/plumed/scripts/vim2html.sh +190 -0
- plumed/_lib/lib/plumed/src/colvar/Template.cpp +116 -0
- plumed/_lib/lib/plumed/src/config/compile_options.sh +3 -0
- plumed/_lib/lib/plumed/src/config/config.txt +181 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.cmake +6 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.cmake.runtime +5 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.cmake.shared +5 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.cmake.static +3 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.inc +6 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.inc.runtime +5 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.inc.shared +5 -0
- plumed/_lib/lib/plumed/src/lib/Plumed.inc.static +3 -0
- plumed/_lib/lib/plumed/vim/scripts.vim +6 -0
- plumed/_plumed_core.cpython-311-darwin.so +0 -0
- plumed/_plumed_core.cpython-312-darwin.so +0 -0
- plumed/_plumed_core.cpython-313-darwin.so +0 -0
- plumedCommunications.cpython-311-darwin.so +0 -0
- plumedCommunications.cpython-312-darwin.so +0 -0
- plumedCommunications.cpython-313-darwin.so +0 -0
- plumedCommunications.pyi +431 -0
|
@@ -0,0 +1,2780 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the GROMACS molecular simulation package.
|
|
3
|
+
*
|
|
4
|
+
* Copyright 1991- The GROMACS Authors
|
|
5
|
+
* and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
|
|
6
|
+
* Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
|
|
7
|
+
*
|
|
8
|
+
* GROMACS is free software; you can redistribute it and/or
|
|
9
|
+
* modify it under the terms of the GNU Lesser General Public License
|
|
10
|
+
* as published by the Free Software Foundation; either version 2.1
|
|
11
|
+
* of the License, or (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* GROMACS is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16
|
+
* Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
19
|
+
* License along with GROMACS; if not, see
|
|
20
|
+
* https://www.gnu.org/licenses, or write to the Free Software Foundation,
|
|
21
|
+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
22
|
+
*
|
|
23
|
+
* If you want to redistribute modifications to GROMACS, please
|
|
24
|
+
* consider that scientific software is very special. Version
|
|
25
|
+
* control is crucial - bugs must be traceable. We will be happy to
|
|
26
|
+
* consider code for inclusion in the official distribution, but
|
|
27
|
+
* derived work must not be called official GROMACS. Details are found
|
|
28
|
+
* in the README & COPYING files - if they are missing, get the
|
|
29
|
+
* official version at https://www.gromacs.org.
|
|
30
|
+
*
|
|
31
|
+
* To help us fund GROMACS development, we humbly ask that you cite
|
|
32
|
+
* the research papers on the package. Check out https://www.gromacs.org.
|
|
33
|
+
*/
|
|
34
|
+
/*! \internal \file
|
|
35
|
+
*
|
|
36
|
+
* \brief Implements the MD runner routine calling all integrators.
|
|
37
|
+
*
|
|
38
|
+
* \author David van der Spoel <david.vanderspoel@icm.uu.se>
|
|
39
|
+
* \ingroup module_mdrun
|
|
40
|
+
*/
|
|
41
|
+
#include "gmxpre.h"
|
|
42
|
+
|
|
43
|
+
#include "runner.h"
|
|
44
|
+
|
|
45
|
+
#include "config.h"
|
|
46
|
+
|
|
47
|
+
#include <cassert>
|
|
48
|
+
#include <cinttypes>
|
|
49
|
+
#include <csignal>
|
|
50
|
+
#include <cstdlib>
|
|
51
|
+
#include <cstring>
|
|
52
|
+
|
|
53
|
+
#include <algorithm>
|
|
54
|
+
#include <memory>
|
|
55
|
+
|
|
56
|
+
#include "gromacs/commandline/filenm.h"
|
|
57
|
+
#include "gromacs/domdec/builder.h"
|
|
58
|
+
#include "gromacs/domdec/domdec.h"
|
|
59
|
+
#include "gromacs/domdec/domdec_struct.h"
|
|
60
|
+
#include "gromacs/domdec/gpuhaloexchange.h"
|
|
61
|
+
#include "gromacs/domdec/localatomsetmanager.h"
|
|
62
|
+
#include "gromacs/domdec/makebondedlinks.h"
|
|
63
|
+
#include "gromacs/domdec/partition.h"
|
|
64
|
+
#include "gromacs/domdec/reversetopology.h"
|
|
65
|
+
#include "gromacs/ewald/ewald_utils.h"
|
|
66
|
+
#include "gromacs/ewald/pme.h"
|
|
67
|
+
#include "gromacs/ewald/pme_gpu_program.h"
|
|
68
|
+
#include "gromacs/ewald/pme_only.h"
|
|
69
|
+
#include "gromacs/ewald/pme_pp_comm_gpu.h"
|
|
70
|
+
#include "gromacs/fileio/checkpoint.h"
|
|
71
|
+
#include "gromacs/fileio/gmxfio.h"
|
|
72
|
+
#include "gromacs/fileio/oenv.h"
|
|
73
|
+
#include "gromacs/fileio/tpxio.h"
|
|
74
|
+
#include "gromacs/gmxlib/network.h"
|
|
75
|
+
#include "gromacs/gmxlib/nrnb.h"
|
|
76
|
+
#include "gromacs/gpu_utils/device_stream_manager.h"
|
|
77
|
+
#include "gromacs/hardware/cpuinfo.h"
|
|
78
|
+
#include "gromacs/hardware/detecthardware.h"
|
|
79
|
+
#include "gromacs/hardware/device_management.h"
|
|
80
|
+
#include "gromacs/hardware/hardwaretopology.h"
|
|
81
|
+
#include "gromacs/hardware/printhardware.h"
|
|
82
|
+
#include "gromacs/imd/imd.h"
|
|
83
|
+
#include "gromacs/listed_forces/disre.h"
|
|
84
|
+
#include "gromacs/listed_forces/listed_forces_gpu.h"
|
|
85
|
+
#include "gromacs/listed_forces/listed_forces.h"
|
|
86
|
+
#include "gromacs/listed_forces/orires.h"
|
|
87
|
+
#include "gromacs/math/functions.h"
|
|
88
|
+
#include "gromacs/math/utilities.h"
|
|
89
|
+
#include "gromacs/math/vec.h"
|
|
90
|
+
#include "gromacs/mdlib/boxdeformation.h"
|
|
91
|
+
#include "gromacs/mdlib/broadcaststructs.h"
|
|
92
|
+
#include "gromacs/mdlib/calc_verletbuf.h"
|
|
93
|
+
#include "gromacs/mdlib/dispersioncorrection.h"
|
|
94
|
+
#include "gromacs/mdlib/enerdata_utils.h"
|
|
95
|
+
#include "gromacs/mdlib/force.h"
|
|
96
|
+
#include "gromacs/mdlib/forcerec.h"
|
|
97
|
+
#include "gromacs/mdlib/gmx_omp_nthreads.h"
|
|
98
|
+
#include "gromacs/mdlib/gpuforcereduction.h"
|
|
99
|
+
#include "gromacs/mdlib/makeconstraints.h"
|
|
100
|
+
#include "gromacs/mdlib/md_support.h"
|
|
101
|
+
#include "gromacs/mdlib/mdatoms.h"
|
|
102
|
+
#include "gromacs/mdlib/sighandler.h"
|
|
103
|
+
#include "gromacs/mdlib/stophandler.h"
|
|
104
|
+
#include "gromacs/mdlib/tgroup.h"
|
|
105
|
+
#include "gromacs/mdlib/updategroups.h"
|
|
106
|
+
#include "gromacs/mdlib/vsite.h"
|
|
107
|
+
#include "gromacs/mdrun/mdmodules.h"
|
|
108
|
+
#include "gromacs/mdrun/simulationcontext.h"
|
|
109
|
+
#include "gromacs/mdrun/simulationinput.h"
|
|
110
|
+
#include "gromacs/mdrun/simulationinputhandle.h"
|
|
111
|
+
#include "gromacs/mdrunutility/handlerestart.h"
|
|
112
|
+
#include "gromacs/mdrunutility/logging.h"
|
|
113
|
+
#include "gromacs/mdrunutility/multisim.h"
|
|
114
|
+
#include "gromacs/mdrunutility/printtime.h"
|
|
115
|
+
#include "gromacs/mdrunutility/threadaffinity.h"
|
|
116
|
+
#include "gromacs/mdtypes/checkpointdata.h"
|
|
117
|
+
#include "gromacs/mdtypes/commrec.h"
|
|
118
|
+
#include "gromacs/mdtypes/enerdata.h"
|
|
119
|
+
#include "gromacs/mdtypes/fcdata.h"
|
|
120
|
+
#include "gromacs/mdtypes/forcerec.h"
|
|
121
|
+
#include "gromacs/mdtypes/group.h"
|
|
122
|
+
#include "gromacs/mdtypes/inputrec.h"
|
|
123
|
+
#include "gromacs/mdtypes/interaction_const.h"
|
|
124
|
+
#include "gromacs/mdtypes/md_enums.h"
|
|
125
|
+
#include "gromacs/mdtypes/mdatom.h"
|
|
126
|
+
#include "gromacs/mdtypes/mdrunoptions.h"
|
|
127
|
+
#include "gromacs/mdtypes/multipletimestepping.h"
|
|
128
|
+
#include "gromacs/mdtypes/observableshistory.h"
|
|
129
|
+
#include "gromacs/mdtypes/observablesreducer.h"
|
|
130
|
+
#include "gromacs/mdtypes/simulation_workload.h"
|
|
131
|
+
#include "gromacs/mdtypes/state.h"
|
|
132
|
+
#include "gromacs/mdtypes/state_propagator_data_gpu.h"
|
|
133
|
+
#include "gromacs/modularsimulator/modularsimulator.h"
|
|
134
|
+
#include "gromacs/nbnxm/gpu_data_mgmt.h"
|
|
135
|
+
#include "gromacs/nbnxm/nbnxm.h"
|
|
136
|
+
#include "gromacs/nbnxm/pairlist_tuning.h"
|
|
137
|
+
#include "gromacs/pbcutil/pbc.h"
|
|
138
|
+
#include "gromacs/pulling/output.h"
|
|
139
|
+
#include "gromacs/pulling/pull.h"
|
|
140
|
+
#include "gromacs/pulling/pull_rotation.h"
|
|
141
|
+
#include "gromacs/restraint/manager.h"
|
|
142
|
+
#include "gromacs/restraint/restraintmdmodule.h"
|
|
143
|
+
#include "gromacs/restraint/restraintpotential.h"
|
|
144
|
+
#include "gromacs/swap/swapcoords.h"
|
|
145
|
+
#include "gromacs/taskassignment/decidegpuusage.h"
|
|
146
|
+
#include "gromacs/taskassignment/decidesimulationworkload.h"
|
|
147
|
+
#include "gromacs/taskassignment/resourcedivision.h"
|
|
148
|
+
#include "gromacs/taskassignment/taskassignment.h"
|
|
149
|
+
#include "gromacs/taskassignment/usergpuids.h"
|
|
150
|
+
#include "gromacs/timing/gpu_timing.h"
|
|
151
|
+
#include "gromacs/timing/wallcycle.h"
|
|
152
|
+
#include "gromacs/timing/wallcyclereporting.h"
|
|
153
|
+
#include "gromacs/topology/mtop_util.h"
|
|
154
|
+
#include "gromacs/trajectory/trajectoryframe.h"
|
|
155
|
+
#include "gromacs/utility/basenetwork.h"
|
|
156
|
+
#include "gromacs/utility/cstringutil.h"
|
|
157
|
+
#include "gromacs/utility/exceptions.h"
|
|
158
|
+
#include "gromacs/utility/fatalerror.h"
|
|
159
|
+
#include "gromacs/utility/filestream.h"
|
|
160
|
+
#include "gromacs/utility/gmxassert.h"
|
|
161
|
+
#include "gromacs/utility/gmxmpi.h"
|
|
162
|
+
#include "gromacs/utility/keyvaluetree.h"
|
|
163
|
+
#include "gromacs/utility/logger.h"
|
|
164
|
+
#include "gromacs/utility/loggerbuilder.h"
|
|
165
|
+
#include "gromacs/utility/mdmodulesnotifiers.h"
|
|
166
|
+
#include "gromacs/utility/physicalnodecommunicator.h"
|
|
167
|
+
#include "gromacs/utility/pleasecite.h"
|
|
168
|
+
#include "gromacs/utility/programcontext.h"
|
|
169
|
+
#include "gromacs/utility/smalloc.h"
|
|
170
|
+
#include "gromacs/utility/stringutil.h"
|
|
171
|
+
#include "gromacs/utility/mpiinfo.h"
|
|
172
|
+
|
|
173
|
+
#include "isimulator.h"
|
|
174
|
+
#include "membedholder.h"
|
|
175
|
+
#include "replicaexchange.h"
|
|
176
|
+
#include "simulatorbuilder.h"
|
|
177
|
+
|
|
178
|
+
/* PLUMED */
|
|
179
|
+
#include "../../../Plumed.h"
|
|
180
|
+
int plumedswitch;
|
|
181
|
+
plumed plumedmain;
|
|
182
|
+
/* END PLUMED */
|
|
183
|
+
|
|
184
|
+
/* PLUMED HREX */
|
|
185
|
+
int plumed_hrex;
|
|
186
|
+
/* END PLUMED HREX */
|
|
187
|
+
|
|
188
|
+
namespace gmx
|
|
189
|
+
{
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
/*! \brief Manage any development feature flag variables encountered
|
|
193
|
+
*
|
|
194
|
+
* The use of dev features indicated by environment variables is
|
|
195
|
+
* logged in order to ensure that runs with such features enabled can
|
|
196
|
+
* be identified from their log and standard output. Any cross
|
|
197
|
+
* dependencies are also checked, and if unsatisfied, a fatal error
|
|
198
|
+
* issued.
|
|
199
|
+
*
|
|
200
|
+
* Note that some development features overrides are applied already here:
|
|
201
|
+
* the GPU communication flags are set to false in non-tMPI and non-CUDA builds.
|
|
202
|
+
*
|
|
203
|
+
* \param[in] mdlog Logger object.
|
|
204
|
+
* \param[in] useGpuForNonbonded True if the nonbonded task is offloaded in this run.
|
|
205
|
+
* \param[in] pmeRunMode Run mode indicating what resource is PME execured on.
|
|
206
|
+
* \param[in] numRanksPerSimulation The number of ranks in each simulation.
|
|
207
|
+
* \param[in] numPmeRanksPerSimulation The number of PME ranks in each simulation, can be -1
|
|
208
|
+
* \returns The object populated with development feature flags.
|
|
209
|
+
*/
|
|
210
|
+
static DevelopmentFeatureFlags manageDevelopmentFeatures(const gmx::MDLogger& mdlog,
|
|
211
|
+
const bool useGpuForNonbonded,
|
|
212
|
+
const PmeRunMode pmeRunMode,
|
|
213
|
+
const int numRanksPerSimulation,
|
|
214
|
+
const int numPmeRanksPerSimulation)
|
|
215
|
+
{
|
|
216
|
+
DevelopmentFeatureFlags devFlags;
|
|
217
|
+
|
|
218
|
+
devFlags.enableGpuBufferOps = (GMX_GPU_CUDA || GMX_GPU_SYCL) && useGpuForNonbonded
|
|
219
|
+
&& (getenv("GMX_USE_GPU_BUFFER_OPS") != nullptr);
|
|
220
|
+
devFlags.forceGpuUpdateDefault = (getenv("GMX_FORCE_UPDATE_DEFAULT_GPU") != nullptr) || GMX_FAHCORE;
|
|
221
|
+
|
|
222
|
+
// Flag use to enable GPU-aware MPI depenendent features such PME GPU decomposition
|
|
223
|
+
// GPU-aware MPI is marked available if it has been detected by GROMACS or detection fails but
|
|
224
|
+
// user wants to force its use
|
|
225
|
+
devFlags.canUseGpuAwareMpi = false;
|
|
226
|
+
|
|
227
|
+
// Direct GPU comm path is being used with GPU-aware MPI
|
|
228
|
+
// make sure underlying MPI implementation is GPU-aware
|
|
229
|
+
|
|
230
|
+
if (GMX_LIB_MPI && GMX_GPU_CUDA)
|
|
231
|
+
{
|
|
232
|
+
// Allow overriding the detection for GPU-aware MPI
|
|
233
|
+
GpuAwareMpiStatus gpuAwareMpiStatus = checkMpiCudaAwareSupport();
|
|
234
|
+
const bool forceGpuAwareMpi = gpuAwareMpiStatus == GpuAwareMpiStatus::Forced;
|
|
235
|
+
const bool haveDetectedGpuAwareMpi = gpuAwareMpiStatus == GpuAwareMpiStatus::Supported;
|
|
236
|
+
if (getenv("GMX_FORCE_CUDA_AWARE_MPI") != nullptr)
|
|
237
|
+
{
|
|
238
|
+
GMX_LOG(mdlog.warning)
|
|
239
|
+
.asParagraph()
|
|
240
|
+
.appendText(
|
|
241
|
+
"GMX_FORCE_CUDA_AWARE_MPI environment variable is inactive. "
|
|
242
|
+
"Please use GMX_FORCE_GPU_AWARE_MPI instead.");
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
devFlags.canUseGpuAwareMpi = haveDetectedGpuAwareMpi || forceGpuAwareMpi;
|
|
246
|
+
if (getenv("GMX_ENABLE_DIRECT_GPU_COMM") != nullptr)
|
|
247
|
+
{
|
|
248
|
+
if (!haveDetectedGpuAwareMpi && forceGpuAwareMpi)
|
|
249
|
+
{
|
|
250
|
+
// GPU-aware support not detected in MPI library but, user has forced it's use
|
|
251
|
+
GMX_LOG(mdlog.warning)
|
|
252
|
+
.asParagraph()
|
|
253
|
+
.appendText(
|
|
254
|
+
"This run has forced use of 'GPU-aware MPI', ie. 'CUDA-aware MPI'. "
|
|
255
|
+
"However, GROMACS cannot determine if underlying MPI is GPU-aware. "
|
|
256
|
+
"GROMACS recommends use of latest OpenMPI version for GPU-aware "
|
|
257
|
+
"support. If you observe failures at runtime, try unsetting the "
|
|
258
|
+
"GMX_FORCE_GPU_AWARE_MPI environment variable.");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (devFlags.canUseGpuAwareMpi)
|
|
262
|
+
{
|
|
263
|
+
GMX_LOG(mdlog.warning)
|
|
264
|
+
.asParagraph()
|
|
265
|
+
.appendText(
|
|
266
|
+
"GMX_ENABLE_DIRECT_GPU_COMM environment variable detected, "
|
|
267
|
+
"enabling direct GPU communication using GPU-aware MPI.");
|
|
268
|
+
}
|
|
269
|
+
else
|
|
270
|
+
{
|
|
271
|
+
GMX_LOG(mdlog.warning)
|
|
272
|
+
.asParagraph()
|
|
273
|
+
.appendText(
|
|
274
|
+
"GPU-aware MPI was not detected, will not use direct GPU "
|
|
275
|
+
"communication. GROMACS recommends use of latest OpenMPI version "
|
|
276
|
+
"for GPU-aware support. If you are certain about GPU-aware support "
|
|
277
|
+
"in your MPI library, you can force its use by setting the "
|
|
278
|
+
"GMX_FORCE_GPU_AWARE_MPI environment variable. Note that such "
|
|
279
|
+
"support is often called \"CUDA-aware MPI.\"");
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else if (haveDetectedGpuAwareMpi)
|
|
283
|
+
{
|
|
284
|
+
// GPU-aware MPI was detected, let the user know that using it may improve performance
|
|
285
|
+
GMX_LOG(mdlog.warning)
|
|
286
|
+
.asParagraph()
|
|
287
|
+
.appendText(
|
|
288
|
+
"GPU-aware MPI detected, but by default GROMACS will not "
|
|
289
|
+
"make use the direct GPU communication capabilities of MPI. "
|
|
290
|
+
"For improved performance try enabling the feature by setting "
|
|
291
|
+
"the GMX_ENABLE_DIRECT_GPU_COMM environment variable.");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else
|
|
295
|
+
{
|
|
296
|
+
if (getenv("GMX_FORCE_GPU_AWARE_MPI") != nullptr)
|
|
297
|
+
{
|
|
298
|
+
// Cannot force use of GPU-aware MPI in this build configuration
|
|
299
|
+
GMX_LOG(mdlog.info)
|
|
300
|
+
.asParagraph()
|
|
301
|
+
.appendText(
|
|
302
|
+
"A CUDA build with an external MPI library is required in order to "
|
|
303
|
+
"benefit from GMX_FORCE_GPU_AWARE_MPI. That environment variable is "
|
|
304
|
+
"being ignored because such a build is not in use.");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (devFlags.enableGpuBufferOps)
|
|
309
|
+
{
|
|
310
|
+
GMX_LOG(mdlog.warning)
|
|
311
|
+
.asParagraph()
|
|
312
|
+
.appendTextFormatted(
|
|
313
|
+
"This run uses the 'GPU buffer ops' feature, enabled by the "
|
|
314
|
+
"GMX_USE_GPU_BUFFER_OPS environment variable.");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (devFlags.forceGpuUpdateDefault)
|
|
318
|
+
{
|
|
319
|
+
GMX_LOG(mdlog.warning)
|
|
320
|
+
.asParagraph()
|
|
321
|
+
.appendTextFormatted(
|
|
322
|
+
"This run will default to '-update gpu' as requested by the "
|
|
323
|
+
"GMX_FORCE_UPDATE_DEFAULT_GPU environment variable.");
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// PME decomposition is supported only with CUDA-backend in mixed mode
|
|
327
|
+
// CUDA-backend also needs GPU-aware MPI support for decomposition to work
|
|
328
|
+
const bool pmeGpuDecompositionRequested =
|
|
329
|
+
(pmeRunMode == PmeRunMode::GPU || pmeRunMode == PmeRunMode::Mixed)
|
|
330
|
+
&& ((numRanksPerSimulation > 1 && numPmeRanksPerSimulation == 0)
|
|
331
|
+
|| numPmeRanksPerSimulation > 1);
|
|
332
|
+
const bool pmeGpuDecompositionSupported =
|
|
333
|
+
(devFlags.canUseGpuAwareMpi && pmeRunMode == PmeRunMode::Mixed);
|
|
334
|
+
|
|
335
|
+
const bool forcePmeGpuDecomposition = getenv("GMX_GPU_PME_DECOMPOSITION") != nullptr;
|
|
336
|
+
|
|
337
|
+
if (pmeGpuDecompositionSupported && pmeGpuDecompositionRequested)
|
|
338
|
+
{
|
|
339
|
+
// PME decomposition is supported only when it is forced using GMX_GPU_PME_DECOMPOSITION
|
|
340
|
+
if (forcePmeGpuDecomposition)
|
|
341
|
+
{
|
|
342
|
+
GMX_LOG(mdlog.warning)
|
|
343
|
+
.asParagraph()
|
|
344
|
+
.appendTextFormatted(
|
|
345
|
+
"This run has requested the 'GPU PME decomposition' feature, enabled "
|
|
346
|
+
"by the GMX_GPU_PME_DECOMPOSITION environment variable. "
|
|
347
|
+
"PME decomposition lacks substantial testing "
|
|
348
|
+
"and should be used with caution.");
|
|
349
|
+
}
|
|
350
|
+
else
|
|
351
|
+
{
|
|
352
|
+
gmx_fatal(FARGS,
|
|
353
|
+
"Multiple PME tasks were required to run on GPUs, "
|
|
354
|
+
"but that is not supported. "
|
|
355
|
+
"Use GMX_GPU_PME_DECOMPOSITION environment variable to enable it.");
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (!pmeGpuDecompositionSupported && pmeGpuDecompositionRequested)
|
|
360
|
+
{
|
|
361
|
+
gmx_fatal(FARGS,
|
|
362
|
+
"PME tasks were required to run on GPUs, but that is not implemented with "
|
|
363
|
+
"more than one PME rank. Use a single rank simulation, or a separate PME rank, "
|
|
364
|
+
"or permit PME tasks to be assigned to the CPU.");
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
devFlags.enableGpuPmeDecomposition =
|
|
368
|
+
forcePmeGpuDecomposition && pmeGpuDecompositionRequested && pmeGpuDecompositionSupported;
|
|
369
|
+
|
|
370
|
+
return devFlags;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/*! \brief Barrier for safe simultaneous thread access to mdrunner data
|
|
374
|
+
*
|
|
375
|
+
* Used to ensure that the master thread does not modify mdrunner during copy
|
|
376
|
+
* on the spawned threads. */
|
|
377
|
+
static void threadMpiMdrunnerAccessBarrier()
|
|
378
|
+
{
|
|
379
|
+
#if GMX_THREAD_MPI
|
|
380
|
+
MPI_Barrier(MPI_COMM_WORLD);
|
|
381
|
+
#endif
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
Mdrunner Mdrunner::cloneOnSpawnedThread() const
|
|
385
|
+
{
|
|
386
|
+
auto newRunner = Mdrunner(std::make_unique<MDModules>());
|
|
387
|
+
|
|
388
|
+
// All runners in the same process share a restraint manager resource because it is
|
|
389
|
+
// part of the interface to the client code, which is associated only with the
|
|
390
|
+
// original thread. Handles to the same resources can be obtained by copy.
|
|
391
|
+
{
|
|
392
|
+
newRunner.restraintManager_ = std::make_unique<RestraintManager>(*restraintManager_);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Copy members of master runner.
|
|
396
|
+
// \todo Replace with builder when Simulation context and/or runner phases are better defined.
|
|
397
|
+
// Ref https://gitlab.com/gromacs/gromacs/-/issues/2587 and https://gitlab.com/gromacs/gromacs/-/issues/2375
|
|
398
|
+
newRunner.hw_opt = hw_opt;
|
|
399
|
+
newRunner.filenames = filenames;
|
|
400
|
+
|
|
401
|
+
newRunner.hwinfo_ = hwinfo_;
|
|
402
|
+
newRunner.oenv = oenv;
|
|
403
|
+
newRunner.mdrunOptions = mdrunOptions;
|
|
404
|
+
newRunner.domdecOptions = domdecOptions;
|
|
405
|
+
newRunner.nbpu_opt = nbpu_opt;
|
|
406
|
+
newRunner.pme_opt = pme_opt;
|
|
407
|
+
newRunner.pme_fft_opt = pme_fft_opt;
|
|
408
|
+
newRunner.bonded_opt = bonded_opt;
|
|
409
|
+
newRunner.update_opt = update_opt;
|
|
410
|
+
newRunner.nstlist_cmdline = nstlist_cmdline;
|
|
411
|
+
newRunner.replExParams = replExParams;
|
|
412
|
+
newRunner.pforce = pforce;
|
|
413
|
+
// Give the spawned thread the newly created valid communicator
|
|
414
|
+
// for the simulation.
|
|
415
|
+
newRunner.libraryWorldCommunicator = MPI_COMM_WORLD;
|
|
416
|
+
newRunner.simulationCommunicator = MPI_COMM_WORLD;
|
|
417
|
+
newRunner.ms = ms;
|
|
418
|
+
newRunner.startingBehavior = startingBehavior;
|
|
419
|
+
newRunner.stopHandlerBuilder_ = std::make_unique<StopHandlerBuilder>(*stopHandlerBuilder_);
|
|
420
|
+
newRunner.inputHolder_ = inputHolder_;
|
|
421
|
+
|
|
422
|
+
threadMpiMdrunnerAccessBarrier();
|
|
423
|
+
|
|
424
|
+
return newRunner;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/*! \brief The callback used for running on spawned threads.
|
|
428
|
+
*
|
|
429
|
+
* Obtains the pointer to the master mdrunner object from the one
|
|
430
|
+
* argument permitted to the thread-launch API call, copies it to make
|
|
431
|
+
* a new runner for this thread, reinitializes necessary data, and
|
|
432
|
+
* proceeds to the simulation. */
|
|
433
|
+
static void mdrunner_start_fn(const void* arg)
|
|
434
|
+
{
|
|
435
|
+
try
|
|
436
|
+
{
|
|
437
|
+
const auto* masterMdrunner = reinterpret_cast<const gmx::Mdrunner*>(arg);
|
|
438
|
+
/* copy the arg list to make sure that it's thread-local. This
|
|
439
|
+
doesn't copy pointed-to items, of course; fnm, cr and fplog
|
|
440
|
+
are reset in the call below, all others should be const. */
|
|
441
|
+
gmx::Mdrunner mdrunner = masterMdrunner->cloneOnSpawnedThread();
|
|
442
|
+
mdrunner.mdrunner();
|
|
443
|
+
}
|
|
444
|
+
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
void Mdrunner::spawnThreads(int numThreadsToLaunch)
|
|
449
|
+
{
|
|
450
|
+
#if GMX_THREAD_MPI
|
|
451
|
+
/* now spawn new threads that start mdrunner_start_fn(), while
|
|
452
|
+
the main thread returns. Thread affinity is handled later. */
|
|
453
|
+
if (tMPI_Init_fn(TRUE, numThreadsToLaunch, TMPI_AFFINITY_NONE, mdrunner_start_fn, static_cast<const void*>(this))
|
|
454
|
+
!= TMPI_SUCCESS)
|
|
455
|
+
{
|
|
456
|
+
GMX_THROW(gmx::InternalError("Failed to spawn thread-MPI threads"));
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// Give the master thread the newly created valid communicator for
|
|
460
|
+
// the simulation.
|
|
461
|
+
libraryWorldCommunicator = MPI_COMM_WORLD;
|
|
462
|
+
simulationCommunicator = MPI_COMM_WORLD;
|
|
463
|
+
threadMpiMdrunnerAccessBarrier();
|
|
464
|
+
#else
|
|
465
|
+
GMX_UNUSED_VALUE(numThreadsToLaunch);
|
|
466
|
+
GMX_UNUSED_VALUE(mdrunner_start_fn);
|
|
467
|
+
#endif
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
} // namespace gmx
|
|
471
|
+
|
|
472
|
+
/*! \brief Initialize variables for Verlet scheme simulation */
|
|
473
|
+
static void prepare_verlet_scheme(FILE* fplog,
|
|
474
|
+
t_commrec* cr,
|
|
475
|
+
t_inputrec* ir,
|
|
476
|
+
int nstlist_cmdline,
|
|
477
|
+
const gmx_mtop_t& mtop,
|
|
478
|
+
const matrix box,
|
|
479
|
+
bool makeGpuPairList,
|
|
480
|
+
const gmx::CpuInfo& cpuinfo)
|
|
481
|
+
{
|
|
482
|
+
// We checked the cut-offs in grompp, but double-check here.
|
|
483
|
+
// We have PME+LJcutoff kernels for rcoulomb>rvdw.
|
|
484
|
+
if (EEL_PME_EWALD(ir->coulombtype) && ir->vdwtype == VanDerWaalsType::Cut)
|
|
485
|
+
{
|
|
486
|
+
GMX_RELEASE_ASSERT(ir->rcoulomb >= ir->rvdw,
|
|
487
|
+
"With Verlet lists and PME we should have rcoulomb>=rvdw");
|
|
488
|
+
}
|
|
489
|
+
else
|
|
490
|
+
{
|
|
491
|
+
GMX_RELEASE_ASSERT(ir->rcoulomb == ir->rvdw,
|
|
492
|
+
"With Verlet lists and no PME rcoulomb and rvdw should be identical");
|
|
493
|
+
}
|
|
494
|
+
/* For NVE simulations, we will retain the initial list buffer */
|
|
495
|
+
if (EI_DYNAMICS(ir->eI) && ir->verletbuf_tol > 0
|
|
496
|
+
&& !(EI_MD(ir->eI) && ir->etc == TemperatureCoupling::No))
|
|
497
|
+
{
|
|
498
|
+
/* Update the Verlet buffer size for the current run setup */
|
|
499
|
+
|
|
500
|
+
/* Here we assume SIMD-enabled kernels are being used. But as currently
|
|
501
|
+
* calc_verlet_buffer_size gives the same results for 4x8 and 4x4
|
|
502
|
+
* and 4x2 gives a larger buffer than 4x4, this is ok.
|
|
503
|
+
*/
|
|
504
|
+
ListSetupType listType =
|
|
505
|
+
(makeGpuPairList ? ListSetupType::Gpu : ListSetupType::CpuSimdWhenSupported);
|
|
506
|
+
VerletbufListSetup listSetup = verletbufGetSafeListSetup(listType);
|
|
507
|
+
|
|
508
|
+
const real rlist_new =
|
|
509
|
+
calcVerletBufferSize(mtop, det(box), *ir, ir->nstlist, ir->nstlist - 1, -1, listSetup);
|
|
510
|
+
|
|
511
|
+
if (rlist_new != ir->rlist)
|
|
512
|
+
{
|
|
513
|
+
if (fplog != nullptr)
|
|
514
|
+
{
|
|
515
|
+
fprintf(fplog,
|
|
516
|
+
"\nChanging rlist from %g to %g for non-bonded %dx%d atom kernels\n\n",
|
|
517
|
+
ir->rlist,
|
|
518
|
+
rlist_new,
|
|
519
|
+
listSetup.cluster_size_i,
|
|
520
|
+
listSetup.cluster_size_j);
|
|
521
|
+
}
|
|
522
|
+
ir->rlist = rlist_new;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (nstlist_cmdline > 0 && (!EI_DYNAMICS(ir->eI) || ir->verletbuf_tol <= 0))
|
|
527
|
+
{
|
|
528
|
+
gmx_fatal(FARGS,
|
|
529
|
+
"Can not set nstlist without %s",
|
|
530
|
+
!EI_DYNAMICS(ir->eI) ? "dynamics" : "verlet-buffer-tolerance");
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (EI_DYNAMICS(ir->eI))
|
|
534
|
+
{
|
|
535
|
+
/* Set or try nstlist values */
|
|
536
|
+
increaseNstlist(fplog, cr, ir, nstlist_cmdline, &mtop, box, makeGpuPairList, cpuinfo);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/*! \brief Override the nslist value in inputrec
|
|
541
|
+
*
|
|
542
|
+
* with value passed on the command line (if any)
|
|
543
|
+
*/
|
|
544
|
+
static void override_nsteps_cmdline(const gmx::MDLogger& mdlog, int64_t nsteps_cmdline, t_inputrec* ir)
|
|
545
|
+
{
|
|
546
|
+
assert(ir);
|
|
547
|
+
|
|
548
|
+
/* override with anything else than the default -2 */
|
|
549
|
+
if (nsteps_cmdline > -2)
|
|
550
|
+
{
|
|
551
|
+
char sbuf_steps[STEPSTRSIZE];
|
|
552
|
+
char sbuf_msg[STRLEN];
|
|
553
|
+
|
|
554
|
+
ir->nsteps = nsteps_cmdline;
|
|
555
|
+
if (EI_DYNAMICS(ir->eI) && nsteps_cmdline != -1)
|
|
556
|
+
{
|
|
557
|
+
sprintf(sbuf_msg,
|
|
558
|
+
"Overriding nsteps with value passed on the command line: %s steps, %.3g ps",
|
|
559
|
+
gmx_step_str(nsteps_cmdline, sbuf_steps),
|
|
560
|
+
fabs(nsteps_cmdline * ir->delta_t));
|
|
561
|
+
}
|
|
562
|
+
else
|
|
563
|
+
{
|
|
564
|
+
sprintf(sbuf_msg,
|
|
565
|
+
"Overriding nsteps with value passed on the command line: %s steps",
|
|
566
|
+
gmx_step_str(nsteps_cmdline, sbuf_steps));
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
GMX_LOG(mdlog.warning).asParagraph().appendText(sbuf_msg);
|
|
570
|
+
}
|
|
571
|
+
else if (nsteps_cmdline < -2)
|
|
572
|
+
{
|
|
573
|
+
gmx_fatal(FARGS, "Invalid nsteps value passed on the command line: %" PRId64, nsteps_cmdline);
|
|
574
|
+
}
|
|
575
|
+
/* Do nothing if nsteps_cmdline == -2 */
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
namespace gmx
|
|
579
|
+
{
|
|
580
|
+
|
|
581
|
+
/*! \brief Return whether GPU acceleration of nonbondeds is supported with the given settings.
|
|
582
|
+
*
|
|
583
|
+
* If not, and if a warning may be issued, logs a warning about
|
|
584
|
+
* falling back to CPU code. With thread-MPI, only the first
|
|
585
|
+
* call to this function should have \c issueWarning true. */
|
|
586
|
+
static bool gpuAccelerationOfNonbondedIsUseful(const MDLogger& mdlog,
|
|
587
|
+
const t_inputrec& ir,
|
|
588
|
+
const bool issueWarning,
|
|
589
|
+
const bool doRerun)
|
|
590
|
+
{
|
|
591
|
+
bool gpuIsUseful = true;
|
|
592
|
+
std::string warning;
|
|
593
|
+
|
|
594
|
+
if (ir.opts.ngener - ir.nwall > 1)
|
|
595
|
+
{
|
|
596
|
+
/* The GPU code does not support more than one energy group.
|
|
597
|
+
* If the user requested GPUs explicitly, a fatal error is given later.
|
|
598
|
+
*/
|
|
599
|
+
gpuIsUseful = false;
|
|
600
|
+
if (!doRerun)
|
|
601
|
+
{
|
|
602
|
+
warning =
|
|
603
|
+
"Multiple energy groups is not implemented for GPUs, falling back to the CPU. "
|
|
604
|
+
"For better performance, run on the GPU without energy groups and then do "
|
|
605
|
+
"gmx mdrun -rerun option on the trajectory with an energy group .tpr file.";
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/* There are resource handling issues in the GPU code paths with MTS on anything else than only
|
|
610
|
+
* PME. Also those code paths need more testing.
|
|
611
|
+
*/
|
|
612
|
+
MtsLevel mtsLevelOnlyPme;
|
|
613
|
+
mtsLevelOnlyPme.forceGroups.set(static_cast<int>(MtsForceGroups::LongrangeNonbonded));
|
|
614
|
+
if (ir.useMts && !(ir.mtsLevels.size() == 2 && ir.mtsLevels[1].forceGroups == mtsLevelOnlyPme.forceGroups))
|
|
615
|
+
{
|
|
616
|
+
gpuIsUseful = false;
|
|
617
|
+
warning = gmx::formatString(
|
|
618
|
+
"Multiple time stepping is only supported with GPUs when MTS is only applied to %s "
|
|
619
|
+
"forces.",
|
|
620
|
+
mtsForceGroupNames[MtsForceGroups::LongrangeNonbonded].c_str());
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if (EI_TPI(ir.eI))
|
|
624
|
+
{
|
|
625
|
+
gpuIsUseful = false;
|
|
626
|
+
warning = "TPI is not implemented for GPUs.";
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
if (!gpuIsUseful && issueWarning)
|
|
630
|
+
{
|
|
631
|
+
GMX_LOG(mdlog.warning).asParagraph().appendText(warning);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return gpuIsUseful;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
//! Initializes the logger for mdrun.
|
|
638
|
+
static gmx::LoggerOwner buildLogger(FILE* fplog, const bool isSimulationMasterRank)
|
|
639
|
+
{
|
|
640
|
+
gmx::LoggerBuilder builder;
|
|
641
|
+
if (fplog != nullptr)
|
|
642
|
+
{
|
|
643
|
+
builder.addTargetFile(gmx::MDLogger::LogLevel::Info, fplog);
|
|
644
|
+
}
|
|
645
|
+
if (isSimulationMasterRank)
|
|
646
|
+
{
|
|
647
|
+
builder.addTargetStream(gmx::MDLogger::LogLevel::Warning, &gmx::TextOutputFile::standardError());
|
|
648
|
+
}
|
|
649
|
+
return builder.build();
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
//! Make a TaskTarget from an mdrun argument string.
|
|
653
|
+
static TaskTarget findTaskTarget(const char* optionString)
|
|
654
|
+
{
|
|
655
|
+
TaskTarget returnValue = TaskTarget::Auto;
|
|
656
|
+
|
|
657
|
+
if (strncmp(optionString, "auto", 3) == 0)
|
|
658
|
+
{
|
|
659
|
+
returnValue = TaskTarget::Auto;
|
|
660
|
+
}
|
|
661
|
+
else if (strncmp(optionString, "cpu", 3) == 0)
|
|
662
|
+
{
|
|
663
|
+
returnValue = TaskTarget::Cpu;
|
|
664
|
+
}
|
|
665
|
+
else if (strncmp(optionString, "gpu", 3) == 0)
|
|
666
|
+
{
|
|
667
|
+
returnValue = TaskTarget::Gpu;
|
|
668
|
+
}
|
|
669
|
+
else
|
|
670
|
+
{
|
|
671
|
+
GMX_ASSERT(false, "Option string should have been checked for sanity already");
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
return returnValue;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
//! Finish run, aggregate data to print performance info.
|
|
678
|
+
static void finish_run(FILE* fplog,
|
|
679
|
+
const gmx::MDLogger& mdlog,
|
|
680
|
+
const t_commrec* cr,
|
|
681
|
+
const t_inputrec& inputrec,
|
|
682
|
+
t_nrnb nrnb[],
|
|
683
|
+
gmx_wallcycle* wcycle,
|
|
684
|
+
gmx_walltime_accounting_t walltime_accounting,
|
|
685
|
+
nonbonded_verlet_t* nbv,
|
|
686
|
+
const gmx_pme_t* pme,
|
|
687
|
+
gmx_bool bWriteStat)
|
|
688
|
+
{
|
|
689
|
+
double delta_t = 0;
|
|
690
|
+
double nbfs = 0, mflop = 0;
|
|
691
|
+
double elapsed_time, elapsed_time_over_all_ranks, elapsed_time_over_all_threads,
|
|
692
|
+
elapsed_time_over_all_threads_over_all_ranks;
|
|
693
|
+
/* Control whether it is valid to print a report. Only the
|
|
694
|
+
simulation master may print, but it should not do so if the run
|
|
695
|
+
terminated e.g. before a scheduled reset step. This is
|
|
696
|
+
complicated by the fact that PME ranks are unaware of the
|
|
697
|
+
reason why they were sent a pmerecvqxFINISH. To avoid
|
|
698
|
+
communication deadlocks, we always do the communication for the
|
|
699
|
+
report, even if we've decided not to write the report, because
|
|
700
|
+
how long it takes to finish the run is not important when we've
|
|
701
|
+
decided not to report on the simulation performance.
|
|
702
|
+
|
|
703
|
+
Further, we only report performance for dynamical integrators,
|
|
704
|
+
because those are the only ones for which we plan to
|
|
705
|
+
consider doing any optimizations. */
|
|
706
|
+
bool printReport = EI_DYNAMICS(inputrec.eI) && SIMMASTER(cr);
|
|
707
|
+
|
|
708
|
+
if (printReport && !walltime_accounting_get_valid_finish(walltime_accounting))
|
|
709
|
+
{
|
|
710
|
+
GMX_LOG(mdlog.warning)
|
|
711
|
+
.asParagraph()
|
|
712
|
+
.appendText("Simulation ended prematurely, no performance report will be written.");
|
|
713
|
+
printReport = false;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
t_nrnb* nrnb_tot;
|
|
717
|
+
std::unique_ptr<t_nrnb> nrnbTotalStorage;
|
|
718
|
+
if (cr->nnodes > 1)
|
|
719
|
+
{
|
|
720
|
+
nrnbTotalStorage = std::make_unique<t_nrnb>();
|
|
721
|
+
nrnb_tot = nrnbTotalStorage.get();
|
|
722
|
+
#if GMX_MPI
|
|
723
|
+
MPI_Allreduce(nrnb->n.data(), nrnb_tot->n.data(), eNRNB, MPI_DOUBLE, MPI_SUM, cr->mpi_comm_mysim);
|
|
724
|
+
#endif
|
|
725
|
+
}
|
|
726
|
+
else
|
|
727
|
+
{
|
|
728
|
+
nrnb_tot = nrnb;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
elapsed_time = walltime_accounting_get_time_since_reset(walltime_accounting);
|
|
732
|
+
elapsed_time_over_all_threads =
|
|
733
|
+
walltime_accounting_get_time_since_reset_over_all_threads(walltime_accounting);
|
|
734
|
+
if (GMX_MPI && cr->nnodes > 1)
|
|
735
|
+
{
|
|
736
|
+
#if GMX_MPI
|
|
737
|
+
/* reduce elapsed_time over all MPI ranks in the current simulation */
|
|
738
|
+
MPI_Allreduce(&elapsed_time, &elapsed_time_over_all_ranks, 1, MPI_DOUBLE, MPI_SUM, cr->mpi_comm_mysim);
|
|
739
|
+
elapsed_time_over_all_ranks /= cr->nnodes;
|
|
740
|
+
/* Reduce elapsed_time_over_all_threads over all MPI ranks in the
|
|
741
|
+
* current simulation. */
|
|
742
|
+
MPI_Allreduce(&elapsed_time_over_all_threads,
|
|
743
|
+
&elapsed_time_over_all_threads_over_all_ranks,
|
|
744
|
+
1,
|
|
745
|
+
MPI_DOUBLE,
|
|
746
|
+
MPI_SUM,
|
|
747
|
+
cr->mpi_comm_mysim);
|
|
748
|
+
#endif
|
|
749
|
+
}
|
|
750
|
+
else
|
|
751
|
+
{
|
|
752
|
+
elapsed_time_over_all_ranks = elapsed_time;
|
|
753
|
+
elapsed_time_over_all_threads_over_all_ranks = elapsed_time_over_all_threads;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
if (printReport)
|
|
757
|
+
{
|
|
758
|
+
print_flop(fplog, nrnb_tot, &nbfs, &mflop);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (thisRankHasDuty(cr, DUTY_PP) && haveDDAtomOrdering(*cr))
|
|
762
|
+
{
|
|
763
|
+
print_dd_statistics(cr, inputrec, fplog);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/* TODO Move the responsibility for any scaling by thread counts
|
|
767
|
+
* to the code that handled the thread region, so that there's a
|
|
768
|
+
* mechanism to keep cycle counting working during the transition
|
|
769
|
+
* to task parallelism. */
|
|
770
|
+
int nthreads_pp = gmx_omp_nthreads_get(ModuleMultiThread::Nonbonded);
|
|
771
|
+
int nthreads_pme = gmx_omp_nthreads_get(ModuleMultiThread::Pme);
|
|
772
|
+
wallcycle_scale_by_num_threads(
|
|
773
|
+
wcycle, thisRankHasDuty(cr, DUTY_PME) && !thisRankHasDuty(cr, DUTY_PP), nthreads_pp, nthreads_pme);
|
|
774
|
+
auto cycle_sum(wallcycle_sum(cr, wcycle));
|
|
775
|
+
|
|
776
|
+
if (printReport)
|
|
777
|
+
{
|
|
778
|
+
auto* nbnxn_gpu_timings =
|
|
779
|
+
(nbv != nullptr && nbv->useGpu()) ? Nbnxm::gpu_get_timings(nbv->gpu_nbv) : nullptr;
|
|
780
|
+
gmx_wallclock_gpu_pme_t pme_gpu_timings = {};
|
|
781
|
+
|
|
782
|
+
if (pme_gpu_task_enabled(pme))
|
|
783
|
+
{
|
|
784
|
+
pme_gpu_get_timings(pme, &pme_gpu_timings);
|
|
785
|
+
}
|
|
786
|
+
wallcycle_print(fplog,
|
|
787
|
+
mdlog,
|
|
788
|
+
cr->nnodes,
|
|
789
|
+
cr->npmenodes,
|
|
790
|
+
nthreads_pp,
|
|
791
|
+
nthreads_pme,
|
|
792
|
+
elapsed_time_over_all_ranks,
|
|
793
|
+
wcycle,
|
|
794
|
+
cycle_sum,
|
|
795
|
+
nbnxn_gpu_timings,
|
|
796
|
+
&pme_gpu_timings);
|
|
797
|
+
|
|
798
|
+
if (EI_DYNAMICS(inputrec.eI))
|
|
799
|
+
{
|
|
800
|
+
delta_t = inputrec.delta_t;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
if (fplog)
|
|
804
|
+
{
|
|
805
|
+
print_perf(fplog,
|
|
806
|
+
elapsed_time_over_all_threads_over_all_ranks,
|
|
807
|
+
elapsed_time_over_all_ranks,
|
|
808
|
+
walltime_accounting_get_nsteps_done_since_reset(walltime_accounting),
|
|
809
|
+
delta_t,
|
|
810
|
+
nbfs,
|
|
811
|
+
mflop);
|
|
812
|
+
}
|
|
813
|
+
if (bWriteStat)
|
|
814
|
+
{
|
|
815
|
+
print_perf(stderr,
|
|
816
|
+
elapsed_time_over_all_threads_over_all_ranks,
|
|
817
|
+
elapsed_time_over_all_ranks,
|
|
818
|
+
walltime_accounting_get_nsteps_done_since_reset(walltime_accounting),
|
|
819
|
+
delta_t,
|
|
820
|
+
nbfs,
|
|
821
|
+
mflop);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
int Mdrunner::mdrunner()
|
|
827
|
+
{
|
|
828
|
+
matrix box;
|
|
829
|
+
std::unique_ptr<t_forcerec> fr;
|
|
830
|
+
real ewaldcoeff_q = 0;
|
|
831
|
+
real ewaldcoeff_lj = 0;
|
|
832
|
+
int nChargePerturbed = -1, nTypePerturbed = 0;
|
|
833
|
+
gmx_walltime_accounting_t walltime_accounting = nullptr;
|
|
834
|
+
MembedHolder membedHolder(filenames.size(), filenames.data());
|
|
835
|
+
|
|
836
|
+
/* CAUTION: threads may be started later on in this function, so
|
|
837
|
+
cr doesn't reflect the final parallel state right now */
|
|
838
|
+
gmx_mtop_t mtop;
|
|
839
|
+
|
|
840
|
+
/* TODO: inputrec should tell us whether we use an algorithm, not a file option */
|
|
841
|
+
const bool doEssentialDynamics = opt2bSet("-ei", filenames.size(), filenames.data());
|
|
842
|
+
const bool doRerun = mdrunOptions.rerun;
|
|
843
|
+
|
|
844
|
+
// Handle task-assignment related user options.
|
|
845
|
+
EmulateGpuNonbonded emulateGpuNonbonded =
|
|
846
|
+
(getenv("GMX_EMULATE_GPU") != nullptr ? EmulateGpuNonbonded::Yes : EmulateGpuNonbonded::No);
|
|
847
|
+
|
|
848
|
+
std::vector<int> userGpuTaskAssignment;
|
|
849
|
+
try
|
|
850
|
+
{
|
|
851
|
+
userGpuTaskAssignment = parseUserTaskAssignmentString(hw_opt.userGpuTaskAssignment);
|
|
852
|
+
}
|
|
853
|
+
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
|
|
854
|
+
auto nonbondedTarget = findTaskTarget(nbpu_opt);
|
|
855
|
+
auto pmeTarget = findTaskTarget(pme_opt);
|
|
856
|
+
auto pmeFftTarget = findTaskTarget(pme_fft_opt);
|
|
857
|
+
auto bondedTarget = findTaskTarget(bonded_opt);
|
|
858
|
+
auto updateTarget = findTaskTarget(update_opt);
|
|
859
|
+
|
|
860
|
+
FILE* fplog = nullptr;
|
|
861
|
+
// If we are appending, we don't write log output because we need
|
|
862
|
+
// to check that the old log file matches what the checkpoint file
|
|
863
|
+
// expects. Otherwise, we should start to write log output now if
|
|
864
|
+
// there is a file ready for it.
|
|
865
|
+
if (logFileHandle != nullptr && startingBehavior != StartingBehavior::RestartWithAppending)
|
|
866
|
+
{
|
|
867
|
+
fplog = gmx_fio_getfp(logFileHandle);
|
|
868
|
+
}
|
|
869
|
+
const bool isSimulationMasterRank = findIsSimulationMasterRank(ms, simulationCommunicator);
|
|
870
|
+
gmx::LoggerOwner logOwner(buildLogger(fplog, isSimulationMasterRank));
|
|
871
|
+
gmx::MDLogger mdlog(logOwner.logger());
|
|
872
|
+
|
|
873
|
+
gmx_print_detected_hardware(fplog, isSimulationMasterRank && isMasterSim(ms), mdlog, hwinfo_);
|
|
874
|
+
|
|
875
|
+
std::vector<int> availableDevices =
|
|
876
|
+
makeListOfAvailableDevices(hwinfo_->deviceInfoList, hw_opt.devicesSelectedByUser);
|
|
877
|
+
const int numAvailableDevices = gmx::ssize(availableDevices);
|
|
878
|
+
|
|
879
|
+
// Print citation requests after all software/hardware printing
|
|
880
|
+
pleaseCiteGromacs(fplog);
|
|
881
|
+
|
|
882
|
+
// Note: legacy program logic relies on checking whether these pointers are assigned.
|
|
883
|
+
// Objects may or may not be allocated later.
|
|
884
|
+
std::unique_ptr<t_inputrec> inputrec;
|
|
885
|
+
std::unique_ptr<t_state> globalState;
|
|
886
|
+
|
|
887
|
+
auto partialDeserializedTpr = std::make_unique<PartialDeserializedTprFile>();
|
|
888
|
+
|
|
889
|
+
if (isSimulationMasterRank)
|
|
890
|
+
{
|
|
891
|
+
// Allocate objects to be initialized by later function calls.
|
|
892
|
+
/* Only the master rank has the global state */
|
|
893
|
+
globalState = std::make_unique<t_state>();
|
|
894
|
+
inputrec = std::make_unique<t_inputrec>();
|
|
895
|
+
|
|
896
|
+
/* Read (nearly) all data required for the simulation
|
|
897
|
+
* and keep the partly serialized tpr contents to send to other ranks later
|
|
898
|
+
*/
|
|
899
|
+
applyGlobalSimulationState(
|
|
900
|
+
*inputHolder_.get(), partialDeserializedTpr.get(), globalState.get(), inputrec.get(), &mtop);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/* Check and update the hardware options for internal consistency */
|
|
904
|
+
checkAndUpdateHardwareOptions(
|
|
905
|
+
mdlog, &hw_opt, isSimulationMasterRank, domdecOptions.numPmeRanks, inputrec.get());
|
|
906
|
+
|
|
907
|
+
if (GMX_THREAD_MPI && isSimulationMasterRank)
|
|
908
|
+
{
|
|
909
|
+
bool useGpuForNonbonded = false;
|
|
910
|
+
bool useGpuForPme = false;
|
|
911
|
+
try
|
|
912
|
+
{
|
|
913
|
+
GMX_RELEASE_ASSERT(inputrec != nullptr, "Keep the compiler happy");
|
|
914
|
+
|
|
915
|
+
// If the user specified the number of ranks, then we must
|
|
916
|
+
// respect that, but in default mode, we need to allow for
|
|
917
|
+
// the number of GPUs to choose the number of ranks.
|
|
918
|
+
auto canUseGpuForNonbonded = buildSupportsNonbondedOnGpu(nullptr);
|
|
919
|
+
useGpuForNonbonded = decideWhetherToUseGpusForNonbondedWithThreadMpi(
|
|
920
|
+
nonbondedTarget,
|
|
921
|
+
numAvailableDevices > 0,
|
|
922
|
+
userGpuTaskAssignment,
|
|
923
|
+
emulateGpuNonbonded,
|
|
924
|
+
canUseGpuForNonbonded,
|
|
925
|
+
gpuAccelerationOfNonbondedIsUseful(mdlog, *inputrec, GMX_THREAD_MPI, doRerun),
|
|
926
|
+
hw_opt.nthreads_tmpi);
|
|
927
|
+
useGpuForPme = decideWhetherToUseGpusForPmeWithThreadMpi(useGpuForNonbonded,
|
|
928
|
+
pmeTarget,
|
|
929
|
+
pmeFftTarget,
|
|
930
|
+
numAvailableDevices,
|
|
931
|
+
userGpuTaskAssignment,
|
|
932
|
+
*hwinfo_,
|
|
933
|
+
*inputrec,
|
|
934
|
+
hw_opt.nthreads_tmpi,
|
|
935
|
+
domdecOptions.numPmeRanks);
|
|
936
|
+
}
|
|
937
|
+
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
|
|
938
|
+
|
|
939
|
+
/* Determine how many thread-MPI ranks to start.
|
|
940
|
+
*
|
|
941
|
+
* TODO Over-writing the user-supplied value here does
|
|
942
|
+
* prevent any possible subsequent checks from working
|
|
943
|
+
* correctly. */
|
|
944
|
+
hw_opt.nthreads_tmpi = get_nthreads_mpi(hwinfo_,
|
|
945
|
+
&hw_opt,
|
|
946
|
+
numAvailableDevices,
|
|
947
|
+
useGpuForNonbonded,
|
|
948
|
+
useGpuForPme,
|
|
949
|
+
inputrec.get(),
|
|
950
|
+
mtop,
|
|
951
|
+
mdlog,
|
|
952
|
+
membedHolder.doMembed());
|
|
953
|
+
|
|
954
|
+
// Now start the threads for thread MPI.
|
|
955
|
+
spawnThreads(hw_opt.nthreads_tmpi);
|
|
956
|
+
// The spawned threads enter mdrunner() and execution of
|
|
957
|
+
// master and spawned threads joins at the end of this block.
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
GMX_RELEASE_ASSERT(!GMX_MPI || ms || simulationCommunicator != MPI_COMM_NULL,
|
|
961
|
+
"Must have valid communicator unless running a multi-simulation");
|
|
962
|
+
CommrecHandle crHandle = init_commrec(simulationCommunicator);
|
|
963
|
+
t_commrec* cr = crHandle.get();
|
|
964
|
+
GMX_RELEASE_ASSERT(cr != nullptr, "Must have valid commrec");
|
|
965
|
+
|
|
966
|
+
PhysicalNodeCommunicator physicalNodeComm(libraryWorldCommunicator, gmx_physicalnode_id_hash());
|
|
967
|
+
|
|
968
|
+
if (PAR(cr))
|
|
969
|
+
{
|
|
970
|
+
/* now broadcast everything to the non-master nodes/threads: */
|
|
971
|
+
if (!isSimulationMasterRank)
|
|
972
|
+
{
|
|
973
|
+
// Until now, only the master rank has a non-null pointer.
|
|
974
|
+
// On non-master ranks, allocate the object that will receive data in the following call.
|
|
975
|
+
inputrec = std::make_unique<t_inputrec>();
|
|
976
|
+
}
|
|
977
|
+
init_parallel(cr->mpiDefaultCommunicator,
|
|
978
|
+
MASTER(cr),
|
|
979
|
+
inputrec.get(),
|
|
980
|
+
&mtop,
|
|
981
|
+
partialDeserializedTpr.get());
|
|
982
|
+
}
|
|
983
|
+
GMX_RELEASE_ASSERT(inputrec != nullptr, "All ranks should have a valid inputrec now");
|
|
984
|
+
partialDeserializedTpr.reset(nullptr);
|
|
985
|
+
|
|
986
|
+
// Note that these variables describe only their own node.
|
|
987
|
+
//
|
|
988
|
+
// Note that when bonded interactions run on a GPU they always run
|
|
989
|
+
// alongside a nonbonded task, so do not influence task assignment
|
|
990
|
+
// even though they affect the force calculation workload.
|
|
991
|
+
bool useGpuForNonbonded = false;
|
|
992
|
+
bool useGpuForPme = false;
|
|
993
|
+
bool useGpuForBonded = false;
|
|
994
|
+
bool useGpuForUpdate = false;
|
|
995
|
+
bool gpusWereDetected = hwinfo_->ngpu_compatible_tot > 0;
|
|
996
|
+
try
|
|
997
|
+
{
|
|
998
|
+
// It's possible that there are different numbers of GPUs on
|
|
999
|
+
// different nodes, which is the user's responsibility to
|
|
1000
|
+
// handle. If unsuitable, we will notice that during task
|
|
1001
|
+
// assignment.
|
|
1002
|
+
auto canUseGpuForNonbonded = buildSupportsNonbondedOnGpu(nullptr);
|
|
1003
|
+
useGpuForNonbonded = decideWhetherToUseGpusForNonbonded(
|
|
1004
|
+
nonbondedTarget,
|
|
1005
|
+
userGpuTaskAssignment,
|
|
1006
|
+
emulateGpuNonbonded,
|
|
1007
|
+
canUseGpuForNonbonded,
|
|
1008
|
+
gpuAccelerationOfNonbondedIsUseful(mdlog, *inputrec, !GMX_THREAD_MPI, doRerun),
|
|
1009
|
+
gpusWereDetected);
|
|
1010
|
+
useGpuForPme = decideWhetherToUseGpusForPme(useGpuForNonbonded,
|
|
1011
|
+
pmeTarget,
|
|
1012
|
+
pmeFftTarget,
|
|
1013
|
+
userGpuTaskAssignment,
|
|
1014
|
+
*hwinfo_,
|
|
1015
|
+
*inputrec,
|
|
1016
|
+
cr->sizeOfDefaultCommunicator,
|
|
1017
|
+
domdecOptions.numPmeRanks,
|
|
1018
|
+
gpusWereDetected);
|
|
1019
|
+
useGpuForBonded = decideWhetherToUseGpusForBonded(
|
|
1020
|
+
useGpuForNonbonded, useGpuForPme, bondedTarget, *inputrec, mtop, domdecOptions.numPmeRanks, gpusWereDetected);
|
|
1021
|
+
}
|
|
1022
|
+
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
|
|
1023
|
+
|
|
1024
|
+
const PmeRunMode pmeRunMode = determinePmeRunMode(useGpuForPme, pmeFftTarget, *inputrec);
|
|
1025
|
+
|
|
1026
|
+
// Initialize development feature flags that enabled by environment variable
|
|
1027
|
+
// and report those features that are enabled.
|
|
1028
|
+
const DevelopmentFeatureFlags devFlags = manageDevelopmentFeatures(
|
|
1029
|
+
mdlog, useGpuForNonbonded, pmeRunMode, cr->sizeOfDefaultCommunicator, domdecOptions.numPmeRanks);
|
|
1030
|
+
|
|
1031
|
+
const bool useModularSimulator = checkUseModularSimulator(false,
|
|
1032
|
+
inputrec.get(),
|
|
1033
|
+
doRerun,
|
|
1034
|
+
mtop,
|
|
1035
|
+
ms,
|
|
1036
|
+
replExParams,
|
|
1037
|
+
nullptr,
|
|
1038
|
+
doEssentialDynamics,
|
|
1039
|
+
membedHolder.doMembed() && (plumedswitch==0) /* PLUMED */);
|
|
1040
|
+
|
|
1041
|
+
// Now the number of ranks is known to all ranks, and each knows
|
|
1042
|
+
// the inputrec read by the master rank. The ranks can now all run
|
|
1043
|
+
// the task-deciding functions and will agree on the result
|
|
1044
|
+
// without needing to communicate.
|
|
1045
|
+
// The LBFGS minimizer, test-particle insertion, normal modes and shell dynamics don't support DD
|
|
1046
|
+
const bool canUseDomainDecomposition =
|
|
1047
|
+
!(inputrec->eI == IntegrationAlgorithm::LBFGS || EI_TPI(inputrec->eI)
|
|
1048
|
+
|| inputrec->eI == IntegrationAlgorithm::NM
|
|
1049
|
+
|| gmx_mtop_particletype_count(mtop)[ParticleType::Shell] > 0);
|
|
1050
|
+
GMX_RELEASE_ASSERT(!PAR(cr) || canUseDomainDecomposition,
|
|
1051
|
+
"A parallel run should not arrive here without DD support");
|
|
1052
|
+
|
|
1053
|
+
int useDDWithSingleRank = -1;
|
|
1054
|
+
if (const char* ddSingleRankEnv = getenv("GMX_DD_SINGLE_RANK"))
|
|
1055
|
+
{
|
|
1056
|
+
useDDWithSingleRank = std::strtol(ddSingleRankEnv, nullptr, 10);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// The overhead of DD partitioning is only compensated when we have both non-bondeds and PME on the CPU
|
|
1060
|
+
const bool useDomainDecomposition =
|
|
1061
|
+
canUseDomainDecomposition
|
|
1062
|
+
&& (PAR(cr)
|
|
1063
|
+
|| (!useGpuForNonbonded && EEL_FULL(inputrec->coulombtype) && useDDWithSingleRank != 0)
|
|
1064
|
+
|| useDDWithSingleRank == 1);
|
|
1065
|
+
|
|
1066
|
+
ObservablesReducerBuilder observablesReducerBuilder;
|
|
1067
|
+
|
|
1068
|
+
// Build restraints.
|
|
1069
|
+
// TODO: hide restraint implementation details from Mdrunner.
|
|
1070
|
+
// There is nothing unique about restraints at this point as far as the
|
|
1071
|
+
// Mdrunner is concerned. The Mdrunner should just be getting a sequence of
|
|
1072
|
+
// factory functions from the SimulationContext on which to call mdModules_->add().
|
|
1073
|
+
// TODO: capture all restraints into a single RestraintModule, passed to the runner builder.
|
|
1074
|
+
for (auto&& restraint : restraintManager_->getRestraints())
|
|
1075
|
+
{
|
|
1076
|
+
auto module = RestraintMDModule::create(restraint, restraint->sites());
|
|
1077
|
+
mdModules_->add(std::move(module));
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// TODO: Error handling
|
|
1081
|
+
mdModules_->assignOptionsToModules(*inputrec->params, nullptr);
|
|
1082
|
+
// now that the MDModules know their options, they know which callbacks to sign up to
|
|
1083
|
+
mdModules_->subscribeToSimulationSetupNotifications();
|
|
1084
|
+
const auto& setupNotifier = mdModules_->notifiers().simulationSetupNotifier_;
|
|
1085
|
+
|
|
1086
|
+
// Notify MdModules of existing logger
|
|
1087
|
+
setupNotifier.notify(mdlog);
|
|
1088
|
+
|
|
1089
|
+
// Notify MdModules of internal parameters, saved into KVT
|
|
1090
|
+
if (inputrec->internalParameters != nullptr)
|
|
1091
|
+
{
|
|
1092
|
+
setupNotifier.notify(*inputrec->internalParameters);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// Let MdModules know the .tpr filename
|
|
1096
|
+
{
|
|
1097
|
+
gmx::MdRunInputFilename mdRunInputFilename = { ftp2fn(efTPR, filenames.size(), filenames.data()) };
|
|
1098
|
+
setupNotifier.notify(mdRunInputFilename);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
if (fplog != nullptr)
|
|
1102
|
+
{
|
|
1103
|
+
pr_inputrec(fplog, 0, "Input Parameters", inputrec.get(), FALSE);
|
|
1104
|
+
fprintf(fplog, "\n");
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
if (SIMMASTER(cr))
|
|
1108
|
+
{
|
|
1109
|
+
/* In rerun, set velocities to zero if present */
|
|
1110
|
+
if (doRerun && ((globalState->flags & enumValueToBitMask(StateEntry::V)) != 0))
|
|
1111
|
+
{
|
|
1112
|
+
// rerun does not use velocities
|
|
1113
|
+
GMX_LOG(mdlog.info)
|
|
1114
|
+
.asParagraph()
|
|
1115
|
+
.appendText(
|
|
1116
|
+
"Rerun trajectory contains velocities. Rerun does only evaluate "
|
|
1117
|
+
"potential energy and forces. The velocities will be ignored.");
|
|
1118
|
+
for (int i = 0; i < globalState->natoms; i++)
|
|
1119
|
+
{
|
|
1120
|
+
clear_rvec(globalState->v[i]);
|
|
1121
|
+
}
|
|
1122
|
+
globalState->flags &= ~enumValueToBitMask(StateEntry::V);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/* now make sure the state is initialized and propagated */
|
|
1126
|
+
set_state_entries(globalState.get(), inputrec.get(), useModularSimulator);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/* NM and TPI parallelize over force/energy calculations, not atoms,
|
|
1130
|
+
* so we need to initialize and broadcast the global state.
|
|
1131
|
+
*/
|
|
1132
|
+
if (inputrec->eI == IntegrationAlgorithm::NM || inputrec->eI == IntegrationAlgorithm::TPI)
|
|
1133
|
+
{
|
|
1134
|
+
if (!MASTER(cr))
|
|
1135
|
+
{
|
|
1136
|
+
globalState = std::make_unique<t_state>();
|
|
1137
|
+
}
|
|
1138
|
+
broadcastStateWithoutDynamics(
|
|
1139
|
+
cr->mpiDefaultCommunicator, haveDDAtomOrdering(*cr), PAR(cr), globalState.get());
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/* A parallel command line option consistency check that we can
|
|
1143
|
+
only do after any threads have started. */
|
|
1144
|
+
if (!PAR(cr)
|
|
1145
|
+
&& (domdecOptions.numCells[XX] > 1 || domdecOptions.numCells[YY] > 1
|
|
1146
|
+
|| domdecOptions.numCells[ZZ] > 1 || domdecOptions.numPmeRanks > 0))
|
|
1147
|
+
{
|
|
1148
|
+
gmx_fatal(FARGS,
|
|
1149
|
+
"The -dd or -npme option request a parallel simulation, "
|
|
1150
|
+
#if !GMX_MPI
|
|
1151
|
+
"but %s was compiled without threads or MPI enabled",
|
|
1152
|
+
output_env_get_program_display_name(oenv));
|
|
1153
|
+
#elif GMX_THREAD_MPI
|
|
1154
|
+
"but the number of MPI-threads (option -ntmpi) is not set or is 1");
|
|
1155
|
+
#else
|
|
1156
|
+
"but %s was not started through mpirun/mpiexec or only one rank was requested "
|
|
1157
|
+
"through mpirun/mpiexec",
|
|
1158
|
+
output_env_get_program_display_name(oenv));
|
|
1159
|
+
#endif
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
if (doRerun && (EI_ENERGY_MINIMIZATION(inputrec->eI) || IntegrationAlgorithm::NM == inputrec->eI))
|
|
1163
|
+
{
|
|
1164
|
+
gmx_fatal(FARGS,
|
|
1165
|
+
"The .mdp file specified an energy mininization or normal mode algorithm, and "
|
|
1166
|
+
"these are not compatible with mdrun -rerun");
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/* NMR restraints must be initialized before load_checkpoint,
|
|
1170
|
+
* since with time averaging the history is added to t_state.
|
|
1171
|
+
* For proper consistency check we therefore need to extend
|
|
1172
|
+
* t_state here.
|
|
1173
|
+
* So the PME-only nodes (if present) will also initialize
|
|
1174
|
+
* the distance restraints.
|
|
1175
|
+
*/
|
|
1176
|
+
|
|
1177
|
+
/* This needs to be called before read_checkpoint to extend the state */
|
|
1178
|
+
t_disresdata* disresdata;
|
|
1179
|
+
snew(disresdata, 1);
|
|
1180
|
+
init_disres(fplog,
|
|
1181
|
+
mtop,
|
|
1182
|
+
inputrec.get(),
|
|
1183
|
+
DisResRunMode::MDRun,
|
|
1184
|
+
MASTER(cr) ? DDRole::Master : DDRole::Agent,
|
|
1185
|
+
PAR(cr) ? NumRanks::Multiple : NumRanks::Single,
|
|
1186
|
+
cr->mpi_comm_mysim,
|
|
1187
|
+
ms,
|
|
1188
|
+
disresdata,
|
|
1189
|
+
globalState.get(),
|
|
1190
|
+
replExParams.exchangeInterval > 0);
|
|
1191
|
+
|
|
1192
|
+
if (gmx_mtop_ftype_count(mtop, F_ORIRES) > 0 && isSimulationMasterRank)
|
|
1193
|
+
{
|
|
1194
|
+
extendStateWithOriresHistory(mtop, *inputrec, globalState.get());
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
#if GMX_FAHCORE
|
|
1198
|
+
/* We have to remember the generation's first step before reading checkpoint.
|
|
1199
|
+
This way, we can report to the F@H core both the generation's first step
|
|
1200
|
+
and the restored first step, thus making it able to distinguish between
|
|
1201
|
+
an interruption/resume and start of the n-th generation simulation.
|
|
1202
|
+
Having this information, the F@H core can correctly calculate and report
|
|
1203
|
+
the progress.
|
|
1204
|
+
*/
|
|
1205
|
+
int gen_first_step = 0;
|
|
1206
|
+
if (MASTER(cr))
|
|
1207
|
+
{
|
|
1208
|
+
gen_first_step = inputrec->init_step;
|
|
1209
|
+
}
|
|
1210
|
+
#endif
|
|
1211
|
+
|
|
1212
|
+
ObservablesHistory observablesHistory = {};
|
|
1213
|
+
|
|
1214
|
+
auto modularSimulatorCheckpointData = std::make_unique<ReadCheckpointDataHolder>();
|
|
1215
|
+
if (startingBehavior != StartingBehavior::NewSimulation)
|
|
1216
|
+
{
|
|
1217
|
+
/* Check if checkpoint file exists before doing continuation.
|
|
1218
|
+
* This way we can use identical input options for the first and subsequent runs...
|
|
1219
|
+
*/
|
|
1220
|
+
if (mdrunOptions.numStepsCommandline > -2)
|
|
1221
|
+
{
|
|
1222
|
+
/* Temporarily set the number of steps to unlimited to avoid
|
|
1223
|
+
* triggering the nsteps check in load_checkpoint().
|
|
1224
|
+
* This hack will go away soon when the -nsteps option is removed.
|
|
1225
|
+
*/
|
|
1226
|
+
inputrec->nsteps = -1;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// Finish applying initial simulation state information from external sources on all ranks.
|
|
1230
|
+
// Reconcile checkpoint file data with Mdrunner state established up to this point.
|
|
1231
|
+
applyLocalState(*inputHolder_.get(),
|
|
1232
|
+
logFileHandle,
|
|
1233
|
+
cr,
|
|
1234
|
+
domdecOptions.numCells,
|
|
1235
|
+
inputrec.get(),
|
|
1236
|
+
globalState.get(),
|
|
1237
|
+
&observablesHistory,
|
|
1238
|
+
mdrunOptions.reproducible,
|
|
1239
|
+
mdModules_->notifiers(),
|
|
1240
|
+
modularSimulatorCheckpointData.get(),
|
|
1241
|
+
useModularSimulator);
|
|
1242
|
+
// TODO: (#3652) Synchronize filesystem state, SimulationInput contents, and program
|
|
1243
|
+
// invariants
|
|
1244
|
+
// on all code paths.
|
|
1245
|
+
// Write checkpoint or provide hook to update SimulationInput.
|
|
1246
|
+
// If there was a checkpoint file, SimulationInput contains more information
|
|
1247
|
+
// than if there wasn't. At this point, we have synchronized the in-memory
|
|
1248
|
+
// state with the filesystem state only for restarted simulations. We should
|
|
1249
|
+
// be calling applyLocalState unconditionally and expect that the completeness
|
|
1250
|
+
// of SimulationInput is not dependent on its creation method.
|
|
1251
|
+
|
|
1252
|
+
if (startingBehavior == StartingBehavior::RestartWithAppending && logFileHandle)
|
|
1253
|
+
{
|
|
1254
|
+
// Now we can start normal logging to the truncated log file.
|
|
1255
|
+
fplog = gmx_fio_getfp(logFileHandle);
|
|
1256
|
+
prepareLogAppending(fplog);
|
|
1257
|
+
logOwner = buildLogger(fplog, MASTER(cr));
|
|
1258
|
+
mdlog = logOwner.logger();
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
#if GMX_FAHCORE
|
|
1263
|
+
if (MASTER(cr))
|
|
1264
|
+
{
|
|
1265
|
+
fcRegisterSteps(inputrec->nsteps + inputrec->init_step, gen_first_step);
|
|
1266
|
+
}
|
|
1267
|
+
#endif
|
|
1268
|
+
|
|
1269
|
+
if (mdrunOptions.numStepsCommandline > -2)
|
|
1270
|
+
{
|
|
1271
|
+
GMX_LOG(mdlog.info)
|
|
1272
|
+
.asParagraph()
|
|
1273
|
+
.appendText(
|
|
1274
|
+
"The -nsteps functionality is deprecated, and may be removed in a future "
|
|
1275
|
+
"version. "
|
|
1276
|
+
"Consider using gmx convert-tpr -nsteps or changing the appropriate .mdp "
|
|
1277
|
+
"file field.");
|
|
1278
|
+
}
|
|
1279
|
+
/* override nsteps with value set on the commandline */
|
|
1280
|
+
override_nsteps_cmdline(mdlog, mdrunOptions.numStepsCommandline, inputrec.get());
|
|
1281
|
+
|
|
1282
|
+
if (isSimulationMasterRank)
|
|
1283
|
+
{
|
|
1284
|
+
copy_mat(globalState->box, box);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
if (PAR(cr))
|
|
1288
|
+
{
|
|
1289
|
+
gmx_bcast(sizeof(box), box, cr->mpiDefaultCommunicator);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
if (inputrec->cutoff_scheme != CutoffScheme::Verlet)
|
|
1293
|
+
{
|
|
1294
|
+
gmx_fatal(FARGS,
|
|
1295
|
+
"This group-scheme .tpr file can no longer be run by mdrun. Please update to the "
|
|
1296
|
+
"Verlet scheme, or use an earlier version of GROMACS if necessary.");
|
|
1297
|
+
}
|
|
1298
|
+
/* Update rlist and nstlist. */
|
|
1299
|
+
/* Note: prepare_verlet_scheme is calling increaseNstlist(...), which (while attempting to
|
|
1300
|
+
* increase rlist) tries to check if the newly chosen value fits with the DD scheme. As this is
|
|
1301
|
+
* run before any DD scheme is set up, this check is never executed. See #3334 for more details.
|
|
1302
|
+
*/
|
|
1303
|
+
prepare_verlet_scheme(fplog,
|
|
1304
|
+
cr,
|
|
1305
|
+
inputrec.get(),
|
|
1306
|
+
nstlist_cmdline,
|
|
1307
|
+
mtop,
|
|
1308
|
+
box,
|
|
1309
|
+
useGpuForNonbonded || (emulateGpuNonbonded == EmulateGpuNonbonded::Yes),
|
|
1310
|
+
*hwinfo_->cpuInfo);
|
|
1311
|
+
|
|
1312
|
+
// We need to decide on update groups early, as this affects
|
|
1313
|
+
// inter-domain communication distances.
|
|
1314
|
+
auto updateGroupingsPerMoleculeType = makeUpdateGroupingsPerMoleculeType(mtop);
|
|
1315
|
+
const real maxUpdateGroupRadius = computeMaxUpdateGroupRadius(
|
|
1316
|
+
mtop, updateGroupingsPerMoleculeType, maxReferenceTemperature(*inputrec));
|
|
1317
|
+
const real cutoffMargin = std::sqrt(max_cutoff2(inputrec->pbcType, box)) - inputrec->rlist;
|
|
1318
|
+
UpdateGroups updateGroups = makeUpdateGroups(mdlog,
|
|
1319
|
+
std::move(updateGroupingsPerMoleculeType),
|
|
1320
|
+
maxUpdateGroupRadius,
|
|
1321
|
+
useDomainDecomposition,
|
|
1322
|
+
systemHasConstraintsOrVsites(mtop),
|
|
1323
|
+
cutoffMargin);
|
|
1324
|
+
|
|
1325
|
+
try
|
|
1326
|
+
{
|
|
1327
|
+
const bool haveFrozenAtoms = inputrecFrozenAtoms(inputrec.get());
|
|
1328
|
+
|
|
1329
|
+
useGpuForUpdate = decideWhetherToUseGpuForUpdate(useDomainDecomposition,
|
|
1330
|
+
updateGroups.useUpdateGroups(),
|
|
1331
|
+
pmeRunMode,
|
|
1332
|
+
domdecOptions.numPmeRanks > 0,
|
|
1333
|
+
useGpuForNonbonded,
|
|
1334
|
+
updateTarget,
|
|
1335
|
+
gpusWereDetected,
|
|
1336
|
+
*inputrec,
|
|
1337
|
+
mtop,
|
|
1338
|
+
doEssentialDynamics,
|
|
1339
|
+
gmx_mtop_ftype_count(mtop, F_ORIRES) > 0,
|
|
1340
|
+
haveFrozenAtoms,
|
|
1341
|
+
doRerun,
|
|
1342
|
+
devFlags,
|
|
1343
|
+
mdlog);
|
|
1344
|
+
}
|
|
1345
|
+
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
|
|
1346
|
+
|
|
1347
|
+
const bool canUseDirectGpuComm = decideWhetherDirectGpuCommunicationCanBeUsed(
|
|
1348
|
+
devFlags, inputrec->useMts, (inputrec->eSwapCoords != SwapType::No), mdlog);
|
|
1349
|
+
|
|
1350
|
+
bool useGpuDirectHalo = false;
|
|
1351
|
+
|
|
1352
|
+
if (useGpuForNonbonded)
|
|
1353
|
+
{
|
|
1354
|
+
// cr->npmenodes is not yet initialized.
|
|
1355
|
+
// domdecOptions.numPmeRanks == -1 results in 0 separate PME ranks when useGpuForNonbonded is true.
|
|
1356
|
+
// Todo: remove this assumption later once auto mode has support for separate PME rank
|
|
1357
|
+
const int numPmeRanks = domdecOptions.numPmeRanks > 0 ? domdecOptions.numPmeRanks : 0;
|
|
1358
|
+
bool havePPDomainDecomposition = (cr->sizeOfDefaultCommunicator - numPmeRanks) > 1;
|
|
1359
|
+
useGpuDirectHalo = decideWhetherToUseGpuForHalo(havePPDomainDecomposition,
|
|
1360
|
+
useGpuForNonbonded,
|
|
1361
|
+
canUseDirectGpuComm,
|
|
1362
|
+
useModularSimulator,
|
|
1363
|
+
doRerun,
|
|
1364
|
+
EI_ENERGY_MINIMIZATION(inputrec->eI),
|
|
1365
|
+
mdlog);
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
// This builder is necessary while we have multi-part construction
|
|
1369
|
+
// of DD. Before DD is constructed, we use the existence of
|
|
1370
|
+
// the builder object to indicate that further construction of DD
|
|
1371
|
+
// is needed.
|
|
1372
|
+
std::unique_ptr<DomainDecompositionBuilder> ddBuilder;
|
|
1373
|
+
if (useDomainDecomposition)
|
|
1374
|
+
{
|
|
1375
|
+
// The DD builder will disable useGpuDirectHalo if the Y or Z component of any domain is
|
|
1376
|
+
// smaller than twice the communication distance, since GPU-direct communication presently
|
|
1377
|
+
// only works with a single pulse in these dimensions, and we want to avoid box scaling
|
|
1378
|
+
// resulting in fatal errors far into the simulation. Such small systems will not
|
|
1379
|
+
// perform well on multiple GPUs in any case, but it is important that our core functionality
|
|
1380
|
+
// (in particular for testing) does not break depending on GPU direct communication being enabled.
|
|
1381
|
+
ddBuilder = std::make_unique<DomainDecompositionBuilder>(
|
|
1382
|
+
mdlog,
|
|
1383
|
+
cr,
|
|
1384
|
+
domdecOptions,
|
|
1385
|
+
mdrunOptions,
|
|
1386
|
+
mtop,
|
|
1387
|
+
*inputrec,
|
|
1388
|
+
mdModules_->notifiers(),
|
|
1389
|
+
box,
|
|
1390
|
+
updateGroups.updateGroupingPerMoleculeType(),
|
|
1391
|
+
updateGroups.useUpdateGroups(),
|
|
1392
|
+
updateGroups.maxUpdateGroupRadius(),
|
|
1393
|
+
positionsFromStatePointer(globalState.get()),
|
|
1394
|
+
useGpuForNonbonded,
|
|
1395
|
+
useGpuForPme,
|
|
1396
|
+
useGpuForUpdate,
|
|
1397
|
+
&useGpuDirectHalo,
|
|
1398
|
+
devFlags.enableGpuPmeDecomposition);
|
|
1399
|
+
}
|
|
1400
|
+
else
|
|
1401
|
+
{
|
|
1402
|
+
/* PME, if used, is done on all nodes with 1D decomposition */
|
|
1403
|
+
cr->nnodes = cr->sizeOfDefaultCommunicator;
|
|
1404
|
+
cr->sim_nodeid = cr->rankInDefaultCommunicator;
|
|
1405
|
+
cr->nodeid = cr->rankInDefaultCommunicator;
|
|
1406
|
+
cr->npmenodes = 0;
|
|
1407
|
+
cr->duty = (DUTY_PP | DUTY_PME);
|
|
1408
|
+
|
|
1409
|
+
if (inputrec->pbcType == PbcType::Screw)
|
|
1410
|
+
{
|
|
1411
|
+
gmx_fatal(FARGS, "pbc=screw is only implemented with domain decomposition");
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// Produce the task assignment for all ranks on this node - done after DD is constructed
|
|
1416
|
+
GpuTaskAssignments gpuTaskAssignments = GpuTaskAssignmentsBuilder::build(
|
|
1417
|
+
availableDevices,
|
|
1418
|
+
userGpuTaskAssignment,
|
|
1419
|
+
*hwinfo_,
|
|
1420
|
+
simulationCommunicator,
|
|
1421
|
+
physicalNodeComm,
|
|
1422
|
+
nonbondedTarget,
|
|
1423
|
+
pmeTarget,
|
|
1424
|
+
bondedTarget,
|
|
1425
|
+
updateTarget,
|
|
1426
|
+
useGpuForNonbonded,
|
|
1427
|
+
useGpuForPme,
|
|
1428
|
+
thisRankHasDuty(cr, DUTY_PP),
|
|
1429
|
+
// TODO cr->duty & DUTY_PME should imply that a PME
|
|
1430
|
+
// algorithm is active, but currently does not.
|
|
1431
|
+
EEL_PME(inputrec->coulombtype) && thisRankHasDuty(cr, DUTY_PME));
|
|
1432
|
+
|
|
1433
|
+
// Get the device handle for the modules on this rank, nullptr
|
|
1434
|
+
// when no task is assigned.
|
|
1435
|
+
int deviceId = -1;
|
|
1436
|
+
DeviceInformation* deviceInfo = gpuTaskAssignments.initDevice(&deviceId);
|
|
1437
|
+
|
|
1438
|
+
// TODO Currently this is always built, yet DD partition code
|
|
1439
|
+
// checks if it is built before using it. Probably it should
|
|
1440
|
+
// become an MDModule that is made only when another module
|
|
1441
|
+
// requires it (e.g. pull, CompEl, density fitting), so that we
|
|
1442
|
+
// don't update the local atom sets unilaterally every step.
|
|
1443
|
+
LocalAtomSetManager atomSets;
|
|
1444
|
+
|
|
1445
|
+
// Local state and topology are declared (and perhaps constructed)
|
|
1446
|
+
// now, because DD needs them for the LocalTopologyChecker, but
|
|
1447
|
+
// they do not contain valid data until after the first DD
|
|
1448
|
+
// partition.
|
|
1449
|
+
std::unique_ptr<t_state> localStateInstance;
|
|
1450
|
+
t_state* localState;
|
|
1451
|
+
gmx_localtop_t localTopology(mtop.ffparams);
|
|
1452
|
+
|
|
1453
|
+
if (ddBuilder)
|
|
1454
|
+
{
|
|
1455
|
+
localStateInstance = std::make_unique<t_state>();
|
|
1456
|
+
localState = localStateInstance.get();
|
|
1457
|
+
// TODO Pass the GPU streams to ddBuilder to use in buffer
|
|
1458
|
+
// transfers (e.g. halo exchange)
|
|
1459
|
+
cr->dd = ddBuilder->build(&atomSets, localTopology, *localState, &observablesReducerBuilder);
|
|
1460
|
+
// The builder's job is done, so destruct it
|
|
1461
|
+
ddBuilder.reset(nullptr);
|
|
1462
|
+
// Note that local state still does not exist yet.
|
|
1463
|
+
}
|
|
1464
|
+
else
|
|
1465
|
+
{
|
|
1466
|
+
// Without DD, the local state is merely an alias to the global state,
|
|
1467
|
+
// so we don't need to allocate anything.
|
|
1468
|
+
localState = globalState.get();
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// Ensure that all atoms within the same update group are in the
|
|
1472
|
+
// same periodic image. Otherwise, a simulation that did not use
|
|
1473
|
+
// update groups (e.g. a single-rank simulation) cannot always be
|
|
1474
|
+
// correctly restarted in a way that does use update groups
|
|
1475
|
+
// (e.g. a multi-rank simulation).
|
|
1476
|
+
if (isSimulationMasterRank)
|
|
1477
|
+
{
|
|
1478
|
+
const bool useUpdateGroups = cr->dd ? ddUsesUpdateGroups(*cr->dd) : false;
|
|
1479
|
+
if (useUpdateGroups)
|
|
1480
|
+
{
|
|
1481
|
+
putUpdateGroupAtomsInSamePeriodicImage(*cr->dd, mtop, globalState->box, globalState->x);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
const bool disableNonbondedCalculation = (getenv("GMX_NO_NONBONDED") != nullptr);
|
|
1486
|
+
if (disableNonbondedCalculation)
|
|
1487
|
+
{
|
|
1488
|
+
/* turn off non-bonded calculations */
|
|
1489
|
+
GMX_LOG(mdlog.warning)
|
|
1490
|
+
.asParagraph()
|
|
1491
|
+
.appendText(
|
|
1492
|
+
"Found environment variable GMX_NO_NONBONDED.\n"
|
|
1493
|
+
"Disabling nonbonded calculations.");
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
const NumPmeDomains numPmeDomains = getNumPmeDomains(cr->dd);
|
|
1497
|
+
const bool useGpuPmeDecomposition = numPmeDomains.x * numPmeDomains.y > 1 && useGpuForPme;
|
|
1498
|
+
GMX_RELEASE_ASSERT(!useGpuPmeDecomposition || devFlags.enableGpuPmeDecomposition,
|
|
1499
|
+
"GPU PME decomposition works only in the cases where it is supported");
|
|
1500
|
+
|
|
1501
|
+
MdrunScheduleWorkload runScheduleWork;
|
|
1502
|
+
|
|
1503
|
+
// Also populates the simulation constant workload description.
|
|
1504
|
+
// Note: currently the default duty is DUTY_PP | DUTY_PME for all simulations, including those without PME,
|
|
1505
|
+
// so this boolean is sufficient on all ranks to determine whether separate PME ranks are used,
|
|
1506
|
+
// but this will no longer be the case if cr->duty is changed for !EEL_PME(fr->ic->eeltype).
|
|
1507
|
+
const bool haveSeparatePmeRank = (!thisRankHasDuty(cr, DUTY_PP) || !thisRankHasDuty(cr, DUTY_PME));
|
|
1508
|
+
runScheduleWork.simulationWork = createSimulationWorkload(*inputrec,
|
|
1509
|
+
disableNonbondedCalculation,
|
|
1510
|
+
devFlags,
|
|
1511
|
+
havePPDomainDecomposition(cr),
|
|
1512
|
+
haveSeparatePmeRank,
|
|
1513
|
+
useGpuForNonbonded,
|
|
1514
|
+
pmeRunMode,
|
|
1515
|
+
useGpuForBonded,
|
|
1516
|
+
useGpuForUpdate,
|
|
1517
|
+
useGpuDirectHalo,
|
|
1518
|
+
canUseDirectGpuComm,
|
|
1519
|
+
useGpuPmeDecomposition);
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
if (isSimulationMasterRank && GMX_GPU_SYCL)
|
|
1523
|
+
{
|
|
1524
|
+
const SimulationWorkload& simWorkload = runScheduleWork.simulationWork;
|
|
1525
|
+
bool haveAnyGpuWork = simWorkload.useGpuPme || simWorkload.useGpuBonded
|
|
1526
|
+
|| simWorkload.useGpuNonbonded || simWorkload.useGpuUpdate;
|
|
1527
|
+
if (haveAnyGpuWork)
|
|
1528
|
+
{
|
|
1529
|
+
GMX_LOG(mdlog.warning)
|
|
1530
|
+
.asParagraph()
|
|
1531
|
+
.appendText(
|
|
1532
|
+
"\nNOTE: SYCL GPU support in GROMACS is still new and less tested than "
|
|
1533
|
+
"other backends.\n"
|
|
1534
|
+
"Please, pay extra attention to the correctness of your results.");
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
const bool printHostName = (cr->nnodes > 1);
|
|
1539
|
+
gpuTaskAssignments.reportGpuUsage(mdlog, printHostName, pmeRunMode, runScheduleWork.simulationWork);
|
|
1540
|
+
|
|
1541
|
+
std::unique_ptr<DeviceStreamManager> deviceStreamManager = nullptr;
|
|
1542
|
+
|
|
1543
|
+
if (deviceInfo != nullptr)
|
|
1544
|
+
{
|
|
1545
|
+
if (runScheduleWork.simulationWork.havePpDomainDecomposition && thisRankHasDuty(cr, DUTY_PP))
|
|
1546
|
+
{
|
|
1547
|
+
dd_setup_dlb_resource_sharing(cr, deviceId);
|
|
1548
|
+
}
|
|
1549
|
+
const bool useGpuTiming = decideGpuTimingsUsage();
|
|
1550
|
+
deviceStreamManager = std::make_unique<DeviceStreamManager>(
|
|
1551
|
+
*deviceInfo, havePPDomainDecomposition(cr), runScheduleWork.simulationWork, useGpuTiming);
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
// If the user chose a task assignment, give them some hints
|
|
1555
|
+
// where appropriate.
|
|
1556
|
+
if (!userGpuTaskAssignment.empty())
|
|
1557
|
+
{
|
|
1558
|
+
gpuTaskAssignments.logPerformanceHints(mdlog, numAvailableDevices);
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
if (PAR(cr))
|
|
1562
|
+
{
|
|
1563
|
+
/* After possible communicator splitting in make_dd_communicators.
|
|
1564
|
+
* we can set up the intra/inter node communication.
|
|
1565
|
+
*/
|
|
1566
|
+
gmx_setup_nodecomm(fplog, cr);
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
#if GMX_MPI
|
|
1570
|
+
if (isMultiSim(ms))
|
|
1571
|
+
{
|
|
1572
|
+
GMX_LOG(mdlog.warning)
|
|
1573
|
+
.asParagraph()
|
|
1574
|
+
.appendTextFormatted(
|
|
1575
|
+
"This is simulation %d out of %d running as a composite GROMACS\n"
|
|
1576
|
+
"multi-simulation job. Setup for this simulation:\n",
|
|
1577
|
+
ms->simulationIndex_,
|
|
1578
|
+
ms->numSimulations_);
|
|
1579
|
+
}
|
|
1580
|
+
GMX_LOG(mdlog.warning)
|
|
1581
|
+
.appendTextFormatted("Using %d MPI %s\n",
|
|
1582
|
+
cr->nnodes,
|
|
1583
|
+
# if GMX_THREAD_MPI
|
|
1584
|
+
cr->nnodes == 1 ? "thread" : "threads"
|
|
1585
|
+
# else
|
|
1586
|
+
cr->nnodes == 1 ? "process" : "processes"
|
|
1587
|
+
# endif
|
|
1588
|
+
);
|
|
1589
|
+
fflush(stderr);
|
|
1590
|
+
#endif
|
|
1591
|
+
|
|
1592
|
+
// If mdrun -pin auto honors any affinity setting that already
|
|
1593
|
+
// exists. If so, it is nice to provide feedback about whether
|
|
1594
|
+
// that existing affinity setting was from OpenMP or something
|
|
1595
|
+
// else, so we run this code both before and after we initialize
|
|
1596
|
+
// the OpenMP support.
|
|
1597
|
+
gmx_check_thread_affinity_set(mdlog, &hw_opt, hwinfo_->hardwareTopology->maxThreads(), FALSE);
|
|
1598
|
+
/* Check and update the number of OpenMP threads requested */
|
|
1599
|
+
checkAndUpdateRequestedNumOpenmpThreads(
|
|
1600
|
+
&hw_opt, *hwinfo_, cr, ms, physicalNodeComm.size_, pmeRunMode, mtop, *inputrec);
|
|
1601
|
+
|
|
1602
|
+
gmx_omp_nthreads_init(mdlog,
|
|
1603
|
+
cr,
|
|
1604
|
+
hwinfo_->hardwareTopology->maxThreads(),
|
|
1605
|
+
physicalNodeComm.size_,
|
|
1606
|
+
hw_opt.nthreads_omp,
|
|
1607
|
+
hw_opt.nthreads_omp_pme,
|
|
1608
|
+
!thisRankHasDuty(cr, DUTY_PP));
|
|
1609
|
+
|
|
1610
|
+
const bool bEnableFPE = gmxShouldEnableFPExceptions();
|
|
1611
|
+
// FIXME - reconcile with gmx_feenableexcept() call from CommandLineModuleManager::run()
|
|
1612
|
+
if (bEnableFPE)
|
|
1613
|
+
{
|
|
1614
|
+
gmx_feenableexcept();
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
/* Now that we know the setup is consistent, check for efficiency */
|
|
1618
|
+
check_resource_division_efficiency(hwinfo_, gpuTaskAssignments.thisRankHasAnyGpuTask(), cr, mdlog);
|
|
1619
|
+
|
|
1620
|
+
/* getting number of PP/PME threads on this MPI / tMPI rank.
|
|
1621
|
+
PME: env variable should be read only on one node to make sure it is
|
|
1622
|
+
identical everywhere;
|
|
1623
|
+
*/
|
|
1624
|
+
const int numThreadsOnThisRank = thisRankHasDuty(cr, DUTY_PP)
|
|
1625
|
+
? gmx_omp_nthreads_get(ModuleMultiThread::Nonbonded)
|
|
1626
|
+
: gmx_omp_nthreads_get(ModuleMultiThread::Pme);
|
|
1627
|
+
checkHardwareOversubscription(
|
|
1628
|
+
numThreadsOnThisRank, cr->nodeid, *hwinfo_->hardwareTopology, physicalNodeComm, mdlog);
|
|
1629
|
+
|
|
1630
|
+
// Enable Peer access between GPUs where available
|
|
1631
|
+
// Only for DD, only master PP rank needs to perform setup, and only if thread MPI plus
|
|
1632
|
+
// any of the GPU communication features are active.
|
|
1633
|
+
if (haveDDAtomOrdering(*cr) && MASTER(cr) && thisRankHasDuty(cr, DUTY_PP) && GMX_THREAD_MPI
|
|
1634
|
+
&& (runScheduleWork.simulationWork.useGpuHaloExchange
|
|
1635
|
+
|| runScheduleWork.simulationWork.useGpuPmePpCommunication))
|
|
1636
|
+
{
|
|
1637
|
+
setupGpuDevicePeerAccess(gpuTaskAssignments.deviceIdsAssigned(), mdlog);
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
if (hw_opt.threadAffinity != ThreadAffinity::Off)
|
|
1641
|
+
{
|
|
1642
|
+
/* Before setting affinity, check whether the affinity has changed
|
|
1643
|
+
* - which indicates that probably the OpenMP library has changed it
|
|
1644
|
+
* since we first checked).
|
|
1645
|
+
*/
|
|
1646
|
+
gmx_check_thread_affinity_set(mdlog, &hw_opt, hwinfo_->hardwareTopology->maxThreads(), TRUE);
|
|
1647
|
+
|
|
1648
|
+
int numThreadsOnThisNode, intraNodeThreadOffset;
|
|
1649
|
+
analyzeThreadsOnThisNode(
|
|
1650
|
+
physicalNodeComm, numThreadsOnThisRank, &numThreadsOnThisNode, &intraNodeThreadOffset);
|
|
1651
|
+
|
|
1652
|
+
/* Set the CPU affinity */
|
|
1653
|
+
gmx_set_thread_affinity(mdlog,
|
|
1654
|
+
cr,
|
|
1655
|
+
&hw_opt,
|
|
1656
|
+
*hwinfo_->hardwareTopology,
|
|
1657
|
+
numThreadsOnThisRank,
|
|
1658
|
+
numThreadsOnThisNode,
|
|
1659
|
+
intraNodeThreadOffset,
|
|
1660
|
+
nullptr);
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
if (mdrunOptions.timingOptions.resetStep > -1)
|
|
1664
|
+
{
|
|
1665
|
+
GMX_LOG(mdlog.info)
|
|
1666
|
+
.asParagraph()
|
|
1667
|
+
.appendText(
|
|
1668
|
+
"The -resetstep functionality is deprecated, and may be removed in a "
|
|
1669
|
+
"future version.");
|
|
1670
|
+
}
|
|
1671
|
+
std::unique_ptr<gmx_wallcycle> wcycle =
|
|
1672
|
+
wallcycle_init(fplog, mdrunOptions.timingOptions.resetStep, cr);
|
|
1673
|
+
|
|
1674
|
+
if (PAR(cr))
|
|
1675
|
+
{
|
|
1676
|
+
/* Master synchronizes its value of reset_counters with all nodes
|
|
1677
|
+
* including PME only nodes */
|
|
1678
|
+
int64_t reset_counters = wcycle_get_reset_counters(wcycle.get());
|
|
1679
|
+
gmx_bcast(sizeof(reset_counters), &reset_counters, cr->mpi_comm_mysim);
|
|
1680
|
+
wcycle_set_reset_counters(wcycle.get(), reset_counters);
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
// Membrane embedding must be initialized before we call init_forcerec()
|
|
1684
|
+
membedHolder.initializeMembed(fplog,
|
|
1685
|
+
filenames.size(),
|
|
1686
|
+
filenames.data(),
|
|
1687
|
+
&mtop,
|
|
1688
|
+
inputrec.get(),
|
|
1689
|
+
globalState.get(),
|
|
1690
|
+
cr,
|
|
1691
|
+
&mdrunOptions.checkpointOptions.period);
|
|
1692
|
+
|
|
1693
|
+
const bool thisRankHasPmeGpuTask = gpuTaskAssignments.thisRankHasPmeGpuTask();
|
|
1694
|
+
std::unique_ptr<BoxDeformation> deform;
|
|
1695
|
+
std::unique_ptr<MDAtoms> mdAtoms;
|
|
1696
|
+
std::unique_ptr<VirtualSitesHandler> vsite;
|
|
1697
|
+
|
|
1698
|
+
t_nrnb nrnb;
|
|
1699
|
+
if (thisRankHasDuty(cr, DUTY_PP))
|
|
1700
|
+
{
|
|
1701
|
+
setupNotifier.notify(*cr);
|
|
1702
|
+
setupNotifier.notify(&atomSets);
|
|
1703
|
+
setupNotifier.notify(mtop);
|
|
1704
|
+
setupNotifier.notify(inputrec->pbcType);
|
|
1705
|
+
setupNotifier.notify(SimulationTimeStep{ inputrec->delta_t });
|
|
1706
|
+
/* Initiate forcerecord */
|
|
1707
|
+
fr = std::make_unique<t_forcerec>();
|
|
1708
|
+
fr->forceProviders = mdModules_->initForceProviders();
|
|
1709
|
+
init_forcerec(fplog,
|
|
1710
|
+
mdlog,
|
|
1711
|
+
runScheduleWork.simulationWork,
|
|
1712
|
+
fr.get(),
|
|
1713
|
+
*inputrec,
|
|
1714
|
+
mtop,
|
|
1715
|
+
cr,
|
|
1716
|
+
box,
|
|
1717
|
+
opt2fn("-table", filenames.size(), filenames.data()),
|
|
1718
|
+
opt2fn("-tablep", filenames.size(), filenames.data()),
|
|
1719
|
+
opt2fns("-tableb", filenames.size(), filenames.data()),
|
|
1720
|
+
pforce);
|
|
1721
|
+
// Dirty hack, for fixing disres and orires should be made mdmodules
|
|
1722
|
+
fr->fcdata->disres = disresdata;
|
|
1723
|
+
if (gmx_mtop_ftype_count(mtop, F_ORIRES) > 0)
|
|
1724
|
+
{
|
|
1725
|
+
fr->fcdata->orires = std::make_unique<t_oriresdata>(
|
|
1726
|
+
fplog, mtop, *inputrec, ms, globalState.get(), &atomSets);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
deform = prepareBoxDeformation(globalState != nullptr ? globalState->box : box,
|
|
1730
|
+
MASTER(cr) ? DDRole::Master : DDRole::Agent,
|
|
1731
|
+
PAR(cr) ? NumRanks::Multiple : NumRanks::Single,
|
|
1732
|
+
cr->mpi_comm_mygroup,
|
|
1733
|
+
*inputrec);
|
|
1734
|
+
|
|
1735
|
+
// Save a handle to device stream manager to use elsewhere in the code
|
|
1736
|
+
// TODO: Forcerec is not a correct place to store it.
|
|
1737
|
+
fr->deviceStreamManager = deviceStreamManager.get();
|
|
1738
|
+
|
|
1739
|
+
if (runScheduleWork.simulationWork.useGpuPmePpCommunication && !thisRankHasDuty(cr, DUTY_PME))
|
|
1740
|
+
{
|
|
1741
|
+
GMX_RELEASE_ASSERT(
|
|
1742
|
+
deviceStreamManager != nullptr,
|
|
1743
|
+
"GPU device stream manager should be valid in order to use PME-PP direct "
|
|
1744
|
+
"communications.");
|
|
1745
|
+
GMX_RELEASE_ASSERT(
|
|
1746
|
+
deviceStreamManager->streamIsValid(DeviceStreamType::PmePpTransfer),
|
|
1747
|
+
"GPU PP-PME stream should be valid in order to use GPU PME-PP direct "
|
|
1748
|
+
"communications.");
|
|
1749
|
+
fr->pmePpCommGpu = std::make_unique<gmx::PmePpCommGpu>(
|
|
1750
|
+
cr->mpi_comm_mysim,
|
|
1751
|
+
cr->dd->pme_nodeid,
|
|
1752
|
+
&cr->dd->pmeForceReceiveBuffer,
|
|
1753
|
+
deviceStreamManager->context(),
|
|
1754
|
+
deviceStreamManager->stream(DeviceStreamType::PmePpTransfer));
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
fr->nbv = Nbnxm::init_nb_verlet(mdlog,
|
|
1758
|
+
*inputrec,
|
|
1759
|
+
*fr,
|
|
1760
|
+
cr,
|
|
1761
|
+
*hwinfo_,
|
|
1762
|
+
runScheduleWork.simulationWork.useGpuNonbonded,
|
|
1763
|
+
deviceStreamManager.get(),
|
|
1764
|
+
mtop,
|
|
1765
|
+
box,
|
|
1766
|
+
wcycle.get());
|
|
1767
|
+
// TODO: Move the logic below to a GPU bonded builder
|
|
1768
|
+
if (runScheduleWork.simulationWork.useGpuBonded)
|
|
1769
|
+
{
|
|
1770
|
+
GMX_RELEASE_ASSERT(deviceStreamManager != nullptr,
|
|
1771
|
+
"GPU device stream manager should be valid in order to use GPU "
|
|
1772
|
+
"version of bonded forces.");
|
|
1773
|
+
fr->listedForcesGpu = std::make_unique<ListedForcesGpu>(
|
|
1774
|
+
mtop.ffparams,
|
|
1775
|
+
fr->ic->epsfac * fr->fudgeQQ,
|
|
1776
|
+
deviceStreamManager->context(),
|
|
1777
|
+
deviceStreamManager->bondedStream(havePPDomainDecomposition(cr)),
|
|
1778
|
+
wcycle.get());
|
|
1779
|
+
}
|
|
1780
|
+
fr->longRangeNonbondeds = std::make_unique<CpuPpLongRangeNonbondeds>(fr->n_tpi,
|
|
1781
|
+
fr->ic->ewaldcoeff_q,
|
|
1782
|
+
fr->ic->epsilon_r,
|
|
1783
|
+
fr->qsum,
|
|
1784
|
+
fr->ic->eeltype,
|
|
1785
|
+
fr->ic->vdwtype,
|
|
1786
|
+
*inputrec,
|
|
1787
|
+
&nrnb,
|
|
1788
|
+
wcycle.get(),
|
|
1789
|
+
fplog);
|
|
1790
|
+
|
|
1791
|
+
/* Initialize the mdAtoms structure.
|
|
1792
|
+
* mdAtoms is not filled with atom data,
|
|
1793
|
+
* as this can not be done now with domain decomposition.
|
|
1794
|
+
*/
|
|
1795
|
+
mdAtoms = makeMDAtoms(fplog, mtop, *inputrec, thisRankHasPmeGpuTask);
|
|
1796
|
+
if (globalState && thisRankHasPmeGpuTask)
|
|
1797
|
+
{
|
|
1798
|
+
// The pinning of coordinates in the global state object works, because we only use
|
|
1799
|
+
// PME on GPU without DD or on a separate PME rank, and because the local state pointer
|
|
1800
|
+
// points to the global state object without DD.
|
|
1801
|
+
// FIXME: MD and EM separately set up the local state - this should happen in the same
|
|
1802
|
+
// function, which should also perform the pinning.
|
|
1803
|
+
changePinningPolicy(&globalState->x, pme_get_pinning_policy());
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
/* Initialize the virtual site communication */
|
|
1807
|
+
vsite = makeVirtualSitesHandler(
|
|
1808
|
+
mtop, cr, fr->pbcType, updateGroups.updateGroupingPerMoleculeType());
|
|
1809
|
+
|
|
1810
|
+
calc_shifts(box, fr->shift_vec);
|
|
1811
|
+
|
|
1812
|
+
/* With periodic molecules the charge groups should be whole at start up
|
|
1813
|
+
* and the virtual sites should not be far from their proper positions.
|
|
1814
|
+
*/
|
|
1815
|
+
if (!inputrec->bContinuation && MASTER(cr)
|
|
1816
|
+
&& !(inputrec->pbcType != PbcType::No && inputrec->bPeriodicMols))
|
|
1817
|
+
{
|
|
1818
|
+
/* Make molecules whole at start of run */
|
|
1819
|
+
if (fr->pbcType != PbcType::No)
|
|
1820
|
+
{
|
|
1821
|
+
do_pbc_first_mtop(fplog, inputrec->pbcType, box, &mtop, globalState->x.rvec_array());
|
|
1822
|
+
}
|
|
1823
|
+
if (vsite)
|
|
1824
|
+
{
|
|
1825
|
+
/* Correct initial vsite positions are required
|
|
1826
|
+
* for the initial distribution in the domain decomposition
|
|
1827
|
+
* and for the initial shell prediction.
|
|
1828
|
+
*/
|
|
1829
|
+
constructVirtualSitesGlobal(mtop, globalState->x);
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
// Make the DD reverse topology, now that any vsites that are present are available
|
|
1833
|
+
if (haveDDAtomOrdering(*cr))
|
|
1834
|
+
{
|
|
1835
|
+
dd_make_reverse_top(fplog, cr->dd, mtop, vsite.get(), *inputrec, domdecOptions.ddBondedChecking);
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
if (EEL_PME(fr->ic->eeltype) || EVDW_PME(fr->ic->vdwtype))
|
|
1839
|
+
{
|
|
1840
|
+
ewaldcoeff_q = fr->ic->ewaldcoeff_q;
|
|
1841
|
+
ewaldcoeff_lj = fr->ic->ewaldcoeff_lj;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
else
|
|
1845
|
+
{
|
|
1846
|
+
/* This is a PME only node */
|
|
1847
|
+
|
|
1848
|
+
GMX_ASSERT(globalState == nullptr,
|
|
1849
|
+
"We don't need the state on a PME only rank and expect it to be unitialized");
|
|
1850
|
+
|
|
1851
|
+
ewaldcoeff_q = calc_ewaldcoeff_q(inputrec->rcoulomb, inputrec->ewald_rtol);
|
|
1852
|
+
ewaldcoeff_lj = calc_ewaldcoeff_lj(inputrec->rvdw, inputrec->ewald_rtol_lj);
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
gmx_pme_t* sepPmeData = nullptr;
|
|
1856
|
+
// This reference hides the fact that PME data is owned by runner on PME-only ranks and by forcerec on other ranks
|
|
1857
|
+
GMX_ASSERT(thisRankHasDuty(cr, DUTY_PP) == (fr != nullptr),
|
|
1858
|
+
"Double-checking that only PME-only ranks have no forcerec");
|
|
1859
|
+
gmx_pme_t*& pmedata = fr ? fr->pmedata : sepPmeData;
|
|
1860
|
+
|
|
1861
|
+
// TODO should live in ewald module once its testing is improved
|
|
1862
|
+
//
|
|
1863
|
+
// Later, this program could contain kernels that might be later
|
|
1864
|
+
// re-used as auto-tuning progresses, or subsequent simulations
|
|
1865
|
+
// are invoked.
|
|
1866
|
+
PmeGpuProgramStorage pmeGpuProgram;
|
|
1867
|
+
if (thisRankHasPmeGpuTask)
|
|
1868
|
+
{
|
|
1869
|
+
GMX_RELEASE_ASSERT(
|
|
1870
|
+
(deviceStreamManager != nullptr),
|
|
1871
|
+
"GPU device stream manager should be initialized in order to use GPU for PME.");
|
|
1872
|
+
GMX_RELEASE_ASSERT((deviceInfo != nullptr),
|
|
1873
|
+
"GPU device should be initialized in order to use GPU for PME.");
|
|
1874
|
+
pmeGpuProgram = buildPmeGpuProgram(deviceStreamManager->context());
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
/* Initiate PME if necessary,
|
|
1878
|
+
* either on all nodes or on dedicated PME nodes only. */
|
|
1879
|
+
if (EEL_PME(inputrec->coulombtype) || EVDW_PME(inputrec->vdwtype))
|
|
1880
|
+
{
|
|
1881
|
+
if (mdAtoms && mdAtoms->mdatoms())
|
|
1882
|
+
{
|
|
1883
|
+
nChargePerturbed = mdAtoms->mdatoms()->nChargePerturbed;
|
|
1884
|
+
if (EVDW_PME(inputrec->vdwtype))
|
|
1885
|
+
{
|
|
1886
|
+
nTypePerturbed = mdAtoms->mdatoms()->nTypePerturbed;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
if (cr->npmenodes > 0)
|
|
1890
|
+
{
|
|
1891
|
+
/* The PME only nodes need to know nChargePerturbed(FEP on Q) and nTypePerturbed(FEP on LJ)*/
|
|
1892
|
+
gmx_bcast(sizeof(nChargePerturbed), &nChargePerturbed, cr->mpi_comm_mysim);
|
|
1893
|
+
gmx_bcast(sizeof(nTypePerturbed), &nTypePerturbed, cr->mpi_comm_mysim);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
if (thisRankHasDuty(cr, DUTY_PME))
|
|
1897
|
+
{
|
|
1898
|
+
try
|
|
1899
|
+
{
|
|
1900
|
+
// TODO: This should be in the builder.
|
|
1901
|
+
GMX_RELEASE_ASSERT(!runScheduleWork.simulationWork.useGpuPme
|
|
1902
|
+
|| (deviceStreamManager != nullptr),
|
|
1903
|
+
"Device stream manager should be valid in order to use GPU "
|
|
1904
|
+
"version of PME.");
|
|
1905
|
+
GMX_RELEASE_ASSERT(
|
|
1906
|
+
!runScheduleWork.simulationWork.useGpuPme
|
|
1907
|
+
|| deviceStreamManager->streamIsValid(DeviceStreamType::Pme),
|
|
1908
|
+
"GPU PME stream should be valid in order to use GPU version of PME.");
|
|
1909
|
+
|
|
1910
|
+
const DeviceContext* deviceContext = runScheduleWork.simulationWork.useGpuPme
|
|
1911
|
+
? &deviceStreamManager->context()
|
|
1912
|
+
: nullptr;
|
|
1913
|
+
const DeviceStream* pmeStream =
|
|
1914
|
+
runScheduleWork.simulationWork.useGpuPme
|
|
1915
|
+
? &deviceStreamManager->stream(DeviceStreamType::Pme)
|
|
1916
|
+
: nullptr;
|
|
1917
|
+
|
|
1918
|
+
const t_inputrec* ir = inputrec.get();
|
|
1919
|
+
/* For each atom we allow a relative (cut-off) error of up to ewald_rtol.
|
|
1920
|
+
* Thus we can also tolerate an error of an order of magnitude less due to
|
|
1921
|
+
* atoms being slightly outside the halo extent. This will only cause a fraction
|
|
1922
|
+
* of the charge to be missing on the grid. So we pass ewald_rtol as the allowed
|
|
1923
|
+
* chance per atom (ChanceTarget::Atom) to be outside the halo extent.
|
|
1924
|
+
*/
|
|
1925
|
+
const real haloExtentForAtomDisplacement =
|
|
1926
|
+
updateGroups.maxUpdateGroupRadius()
|
|
1927
|
+
+ minCellSizeForAtomDisplacement(mtop,
|
|
1928
|
+
*ir,
|
|
1929
|
+
updateGroups.updateGroupingPerMoleculeType(),
|
|
1930
|
+
ir->ewald_rtol,
|
|
1931
|
+
ChanceTarget::Atom);
|
|
1932
|
+
pmedata = gmx_pme_init(cr,
|
|
1933
|
+
getNumPmeDomains(cr->dd),
|
|
1934
|
+
ir,
|
|
1935
|
+
box,
|
|
1936
|
+
haloExtentForAtomDisplacement,
|
|
1937
|
+
nChargePerturbed != 0,
|
|
1938
|
+
nTypePerturbed != 0,
|
|
1939
|
+
mdrunOptions.reproducible,
|
|
1940
|
+
ewaldcoeff_q,
|
|
1941
|
+
ewaldcoeff_lj,
|
|
1942
|
+
gmx_omp_nthreads_get(ModuleMultiThread::Pme),
|
|
1943
|
+
pmeRunMode,
|
|
1944
|
+
nullptr,
|
|
1945
|
+
deviceContext,
|
|
1946
|
+
pmeStream,
|
|
1947
|
+
pmeGpuProgram.get(),
|
|
1948
|
+
mdlog);
|
|
1949
|
+
}
|
|
1950
|
+
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
|
|
1955
|
+
if (EI_DYNAMICS(inputrec->eI))
|
|
1956
|
+
{
|
|
1957
|
+
/* Turn on signal handling on all nodes */
|
|
1958
|
+
/*
|
|
1959
|
+
* (A user signal from the PME nodes (if any)
|
|
1960
|
+
* is communicated to the PP nodes.
|
|
1961
|
+
*/
|
|
1962
|
+
signal_handler_install();
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
pull_t* pull_work = nullptr;
|
|
1966
|
+
if (thisRankHasDuty(cr, DUTY_PP))
|
|
1967
|
+
{
|
|
1968
|
+
/* Assumes uniform use of the number of OpenMP threads */
|
|
1969
|
+
walltime_accounting = walltime_accounting_init(gmx_omp_nthreads_get(ModuleMultiThread::Default));
|
|
1970
|
+
|
|
1971
|
+
if (inputrec->bPull)
|
|
1972
|
+
{
|
|
1973
|
+
/* Initialize pull code */
|
|
1974
|
+
pull_work = init_pull(fplog,
|
|
1975
|
+
inputrec->pull.get(),
|
|
1976
|
+
inputrec.get(),
|
|
1977
|
+
mtop,
|
|
1978
|
+
cr,
|
|
1979
|
+
&atomSets,
|
|
1980
|
+
inputrec->fepvals->init_lambda);
|
|
1981
|
+
if (inputrec->pull->bXOutAverage || inputrec->pull->bFOutAverage)
|
|
1982
|
+
{
|
|
1983
|
+
initPullHistory(pull_work, &observablesHistory);
|
|
1984
|
+
}
|
|
1985
|
+
if (EI_DYNAMICS(inputrec->eI) && MASTER(cr))
|
|
1986
|
+
{
|
|
1987
|
+
init_pull_output_files(pull_work, filenames.size(), filenames.data(), oenv, startingBehavior);
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
std::unique_ptr<EnforcedRotation> enforcedRotation;
|
|
1992
|
+
if (inputrec->bRot)
|
|
1993
|
+
{
|
|
1994
|
+
/* Initialize enforced rotation code */
|
|
1995
|
+
enforcedRotation = init_rot(fplog,
|
|
1996
|
+
inputrec.get(),
|
|
1997
|
+
filenames.size(),
|
|
1998
|
+
filenames.data(),
|
|
1999
|
+
cr,
|
|
2000
|
+
&atomSets,
|
|
2001
|
+
globalState.get(),
|
|
2002
|
+
mtop,
|
|
2003
|
+
oenv,
|
|
2004
|
+
mdrunOptions,
|
|
2005
|
+
startingBehavior);
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
t_swap* swap = nullptr;
|
|
2009
|
+
if (inputrec->eSwapCoords != SwapType::No)
|
|
2010
|
+
{
|
|
2011
|
+
/* Initialize ion swapping code */
|
|
2012
|
+
swap = init_swapcoords(fplog,
|
|
2013
|
+
inputrec.get(),
|
|
2014
|
+
opt2fn_master("-swap", filenames.size(), filenames.data(), cr),
|
|
2015
|
+
mtop,
|
|
2016
|
+
globalState.get(),
|
|
2017
|
+
&observablesHistory,
|
|
2018
|
+
cr,
|
|
2019
|
+
&atomSets,
|
|
2020
|
+
oenv,
|
|
2021
|
+
mdrunOptions,
|
|
2022
|
+
startingBehavior);
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
/* Let makeConstraints know whether we have essential dynamics constraints. */
|
|
2026
|
+
auto constr = makeConstraints(mtop,
|
|
2027
|
+
*inputrec,
|
|
2028
|
+
pull_work,
|
|
2029
|
+
doEssentialDynamics,
|
|
2030
|
+
fplog,
|
|
2031
|
+
cr,
|
|
2032
|
+
updateGroups.useUpdateGroups(),
|
|
2033
|
+
ms,
|
|
2034
|
+
&nrnb,
|
|
2035
|
+
wcycle.get(),
|
|
2036
|
+
fr->bMolPBC,
|
|
2037
|
+
PAR(cr) ? &observablesReducerBuilder : nullptr);
|
|
2038
|
+
|
|
2039
|
+
/* Energy terms and groups */
|
|
2040
|
+
gmx_enerdata_t enerd(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].size(),
|
|
2041
|
+
inputrec->fepvals->n_lambda);
|
|
2042
|
+
|
|
2043
|
+
// cos acceleration is only supported by md, but older tpr
|
|
2044
|
+
// files might still combine it with other integrators
|
|
2045
|
+
GMX_RELEASE_ASSERT(inputrec->cos_accel == 0.0 || inputrec->eI == IntegrationAlgorithm::MD,
|
|
2046
|
+
"cos_acceleration is only supported by integrator=md");
|
|
2047
|
+
|
|
2048
|
+
/* Kinetic energy data */
|
|
2049
|
+
gmx_ekindata_t ekind(inputrec->opts.ngtc,
|
|
2050
|
+
inputrec->cos_accel,
|
|
2051
|
+
gmx_omp_nthreads_get(ModuleMultiThread::Update));
|
|
2052
|
+
|
|
2053
|
+
/* Set up interactive MD (IMD) */
|
|
2054
|
+
auto imdSession = makeImdSession(inputrec.get(),
|
|
2055
|
+
cr,
|
|
2056
|
+
wcycle.get(),
|
|
2057
|
+
&enerd,
|
|
2058
|
+
ms,
|
|
2059
|
+
mtop,
|
|
2060
|
+
mdlog,
|
|
2061
|
+
MASTER(cr) ? globalState->x : gmx::ArrayRef<gmx::RVec>(),
|
|
2062
|
+
filenames.size(),
|
|
2063
|
+
filenames.data(),
|
|
2064
|
+
oenv,
|
|
2065
|
+
mdrunOptions.imdOptions,
|
|
2066
|
+
startingBehavior);
|
|
2067
|
+
|
|
2068
|
+
if (haveDDAtomOrdering(*cr))
|
|
2069
|
+
{
|
|
2070
|
+
GMX_RELEASE_ASSERT(fr, "fr was NULL while cr->duty was DUTY_PP");
|
|
2071
|
+
/* This call is not included in init_domain_decomposition
|
|
2072
|
+
* because fr->atomInfoForEachMoleculeBlock is set later.
|
|
2073
|
+
*/
|
|
2074
|
+
makeBondedLinks(cr->dd, mtop, fr->atomInfoForEachMoleculeBlock);
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
if (runScheduleWork.simulationWork.useGpuFBufferOps)
|
|
2078
|
+
{
|
|
2079
|
+
fr->gpuForceReduction[gmx::AtomLocality::Local] = std::make_unique<gmx::GpuForceReduction>(
|
|
2080
|
+
deviceStreamManager->context(),
|
|
2081
|
+
deviceStreamManager->stream(gmx::DeviceStreamType::NonBondedLocal),
|
|
2082
|
+
wcycle.get());
|
|
2083
|
+
fr->gpuForceReduction[gmx::AtomLocality::NonLocal] = std::make_unique<gmx::GpuForceReduction>(
|
|
2084
|
+
deviceStreamManager->context(),
|
|
2085
|
+
deviceStreamManager->stream(gmx::DeviceStreamType::NonBondedNonLocal),
|
|
2086
|
+
wcycle.get());
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
std::unique_ptr<gmx::StatePropagatorDataGpu> stateGpu;
|
|
2090
|
+
if (gpusWereDetected && gmx::needStateGpu(runScheduleWork.simulationWork))
|
|
2091
|
+
{
|
|
2092
|
+
GpuApiCallBehavior transferKind =
|
|
2093
|
+
(inputrec->eI == IntegrationAlgorithm::MD && !doRerun && !useModularSimulator)
|
|
2094
|
+
? GpuApiCallBehavior::Async
|
|
2095
|
+
: GpuApiCallBehavior::Sync;
|
|
2096
|
+
GMX_RELEASE_ASSERT(deviceStreamManager != nullptr,
|
|
2097
|
+
"GPU device stream manager should be initialized to use GPU.");
|
|
2098
|
+
stateGpu = std::make_unique<gmx::StatePropagatorDataGpu>(
|
|
2099
|
+
*deviceStreamManager, transferKind, pme_gpu_get_block_size(fr->pmedata), wcycle.get());
|
|
2100
|
+
fr->stateGpu = stateGpu.get();
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
GMX_ASSERT(stopHandlerBuilder_, "Runner must provide StopHandlerBuilder to simulator.");
|
|
2104
|
+
SimulatorBuilder simulatorBuilder;
|
|
2105
|
+
|
|
2106
|
+
simulatorBuilder.add(SimulatorStateData(
|
|
2107
|
+
globalState.get(), localState, &observablesHistory, &enerd, &ekind));
|
|
2108
|
+
simulatorBuilder.add(std::move(membedHolder));
|
|
2109
|
+
simulatorBuilder.add(std::move(stopHandlerBuilder_));
|
|
2110
|
+
simulatorBuilder.add(SimulatorConfig(mdrunOptions, startingBehavior, &runScheduleWork));
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
simulatorBuilder.add(SimulatorEnv(fplog, cr, ms, mdlog, oenv, &observablesReducerBuilder));
|
|
2114
|
+
simulatorBuilder.add(Profiling(&nrnb, walltime_accounting, wcycle.get()));
|
|
2115
|
+
simulatorBuilder.add(ConstraintsParam(
|
|
2116
|
+
constr.get(), enforcedRotation ? enforcedRotation->getLegacyEnfrot() : nullptr, vsite.get()));
|
|
2117
|
+
// TODO: Separate `fr` to a separate add, and make the `build` handle the coupling sensibly.
|
|
2118
|
+
simulatorBuilder.add(LegacyInput(
|
|
2119
|
+
static_cast<int>(filenames.size()), filenames.data(), inputrec.get(), fr.get()));
|
|
2120
|
+
simulatorBuilder.add(ReplicaExchangeParameters(replExParams));
|
|
2121
|
+
simulatorBuilder.add(InteractiveMD(imdSession.get()));
|
|
2122
|
+
simulatorBuilder.add(SimulatorModules(mdModules_->outputProvider(), mdModules_->notifiers()));
|
|
2123
|
+
simulatorBuilder.add(CenterOfMassPulling(pull_work));
|
|
2124
|
+
// Todo move to an MDModule
|
|
2125
|
+
simulatorBuilder.add(IonSwapping(swap));
|
|
2126
|
+
simulatorBuilder.add(TopologyData(mtop, &localTopology, mdAtoms.get()));
|
|
2127
|
+
simulatorBuilder.add(BoxDeformationHandle(deform.get()));
|
|
2128
|
+
simulatorBuilder.add(std::move(modularSimulatorCheckpointData));
|
|
2129
|
+
|
|
2130
|
+
/* PLUMED */
|
|
2131
|
+
if(plumedswitch){
|
|
2132
|
+
if(useModularSimulator) gmx_fatal(FARGS, "PLUMED is not yet compatible with GROMACS new modular simulator");
|
|
2133
|
+
/* detect plumed API version */
|
|
2134
|
+
int pversion=0;
|
|
2135
|
+
plumed_cmd(plumedmain,"getApiVersion",&pversion);
|
|
2136
|
+
if(pversion>5) {
|
|
2137
|
+
int nth = gmx_omp_nthreads_get(ModuleMultiThread::Default);
|
|
2138
|
+
plumed_cmd(plumedmain,"setNumOMPthreads",&nth);
|
|
2139
|
+
}
|
|
2140
|
+
/* set GPU device id */
|
|
2141
|
+
if(pversion>9) {
|
|
2142
|
+
plumed_cmd(plumedmain,"setGpuDeviceId", &deviceId);
|
|
2143
|
+
}
|
|
2144
|
+
if(useGpuForUpdate) {
|
|
2145
|
+
GMX_LOG(mdlog.warning)
|
|
2146
|
+
.asParagraph()
|
|
2147
|
+
.appendTextFormatted(
|
|
2148
|
+
"This simulation is resident on GPU (-update gpu)\n"
|
|
2149
|
+
"but also runs PLUMED (-plumed ). Unless plumed actions are performed\n"
|
|
2150
|
+
"only on neighbour list search and/or file writing steps, this will lead to WRONG RESULTS.\n"
|
|
2151
|
+
"Stop it and run it again with -update cpu.\n");
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
/* END PLUMED */
|
|
2155
|
+
|
|
2156
|
+
// build and run simulator object based on user-input
|
|
2157
|
+
auto simulator = simulatorBuilder.build(useModularSimulator);
|
|
2158
|
+
simulator->run();
|
|
2159
|
+
|
|
2160
|
+
if (fr->pmePpCommGpu)
|
|
2161
|
+
{
|
|
2162
|
+
// destroy object since it is no longer required. (This needs to be done while the GPU context still exists.)
|
|
2163
|
+
fr->pmePpCommGpu.reset();
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
if (inputrec->bPull)
|
|
2167
|
+
{
|
|
2168
|
+
finish_pull(pull_work);
|
|
2169
|
+
}
|
|
2170
|
+
finish_swapcoords(swap);
|
|
2171
|
+
}
|
|
2172
|
+
else
|
|
2173
|
+
{
|
|
2174
|
+
GMX_RELEASE_ASSERT(pmedata, "pmedata was NULL while cr->duty was not DUTY_PP");
|
|
2175
|
+
/* do PME only */
|
|
2176
|
+
walltime_accounting = walltime_accounting_init(gmx_omp_nthreads_get(ModuleMultiThread::Pme));
|
|
2177
|
+
gmx_pmeonly(pmedata,
|
|
2178
|
+
cr,
|
|
2179
|
+
&nrnb,
|
|
2180
|
+
wcycle.get(),
|
|
2181
|
+
walltime_accounting,
|
|
2182
|
+
inputrec.get(),
|
|
2183
|
+
pmeRunMode,
|
|
2184
|
+
runScheduleWork.simulationWork.useGpuPmePpCommunication,
|
|
2185
|
+
deviceStreamManager.get());
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
wallcycle_stop(wcycle.get(), WallCycleCounter::Run);
|
|
2189
|
+
|
|
2190
|
+
/* Finish up, write some stuff
|
|
2191
|
+
* if rerunMD, don't write last frame again
|
|
2192
|
+
*/
|
|
2193
|
+
finish_run(fplog,
|
|
2194
|
+
mdlog,
|
|
2195
|
+
cr,
|
|
2196
|
+
*inputrec,
|
|
2197
|
+
&nrnb,
|
|
2198
|
+
wcycle.get(),
|
|
2199
|
+
walltime_accounting,
|
|
2200
|
+
fr ? fr->nbv.get() : nullptr,
|
|
2201
|
+
pmedata,
|
|
2202
|
+
EI_DYNAMICS(inputrec->eI) && !isMultiSim(ms));
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
deviceStreamManager.reset(nullptr);
|
|
2206
|
+
// Free PME data
|
|
2207
|
+
if (pmedata)
|
|
2208
|
+
{
|
|
2209
|
+
gmx_pme_destroy(pmedata);
|
|
2210
|
+
pmedata = nullptr;
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
// FIXME: this is only here to manually unpin mdAtoms->chargeA_ and state->x,
|
|
2214
|
+
// before we destroy the GPU context(s)
|
|
2215
|
+
// Pinned buffers are associated with contexts in CUDA.
|
|
2216
|
+
// As soon as we destroy GPU contexts after mdrunner() exits, these lines should go.
|
|
2217
|
+
mdAtoms.reset(nullptr);
|
|
2218
|
+
globalState.reset(nullptr);
|
|
2219
|
+
localStateInstance.reset(nullptr);
|
|
2220
|
+
mdModules_.reset(nullptr); // destruct force providers here as they might also use the GPU
|
|
2221
|
+
fr.reset(nullptr); // destruct forcerec before gpu
|
|
2222
|
+
// TODO convert to C++ so we can get rid of these frees
|
|
2223
|
+
sfree(disresdata);
|
|
2224
|
+
|
|
2225
|
+
if (!hwinfo_->deviceInfoList.empty())
|
|
2226
|
+
{
|
|
2227
|
+
/* stop the GPU profiler (only CUDA) */
|
|
2228
|
+
stopGpuProfiler();
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
/* With tMPI we need to wait for all ranks to finish deallocation before
|
|
2232
|
+
* destroying the CUDA context as some tMPI ranks may be sharing
|
|
2233
|
+
* GPU and context.
|
|
2234
|
+
*
|
|
2235
|
+
* This is not a concern in OpenCL where we use one context per rank.
|
|
2236
|
+
*
|
|
2237
|
+
* Note: it is safe to not call the barrier on the ranks which do not use GPU,
|
|
2238
|
+
* but it is easier and more futureproof to call it on the whole node.
|
|
2239
|
+
*
|
|
2240
|
+
* Note that this function needs to be called even if GPUs are not used
|
|
2241
|
+
* in this run because the PME ranks have no knowledge of whether GPUs
|
|
2242
|
+
* are used or not, but all ranks need to enter the barrier below.
|
|
2243
|
+
* \todo Remove this physical node barrier after making sure
|
|
2244
|
+
* that it's not needed anymore (with a shared GPU run).
|
|
2245
|
+
*/
|
|
2246
|
+
if (GMX_THREAD_MPI)
|
|
2247
|
+
{
|
|
2248
|
+
physicalNodeComm.barrier();
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
const bool haveDetectedOrForcedCudaAwareMpi =
|
|
2252
|
+
(gmx::checkMpiCudaAwareSupport() == gmx::GpuAwareMpiStatus::Supported
|
|
2253
|
+
|| gmx::checkMpiCudaAwareSupport() == gmx::GpuAwareMpiStatus::Forced);
|
|
2254
|
+
if (!haveDetectedOrForcedCudaAwareMpi)
|
|
2255
|
+
{
|
|
2256
|
+
// Don't reset GPU in case of GPU-AWARE MPI
|
|
2257
|
+
// UCX creates GPU buffers which are cleaned-up as part of MPI_Finalize()
|
|
2258
|
+
// resetting the device before MPI_Finalize() results in crashes inside UCX
|
|
2259
|
+
// This can also cause issues in tests that invoke mdrunner() multiple
|
|
2260
|
+
// times in the same process; ref #3952.
|
|
2261
|
+
releaseDevice(deviceInfo);
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
/* Does what it says */
|
|
2265
|
+
print_date_and_time(fplog, cr->nodeid, "Finished mdrun", gmx_gettime());
|
|
2266
|
+
walltime_accounting_destroy(walltime_accounting);
|
|
2267
|
+
|
|
2268
|
+
/* PLUMED */
|
|
2269
|
+
if(plumedswitch){
|
|
2270
|
+
plumed_finalize(plumedmain);
|
|
2271
|
+
}
|
|
2272
|
+
/* END PLUMED */
|
|
2273
|
+
|
|
2274
|
+
// Ensure log file content is written
|
|
2275
|
+
if (logFileHandle)
|
|
2276
|
+
{
|
|
2277
|
+
gmx_fio_flush(logFileHandle);
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
/* Reset FPEs (important for unit tests) by disabling them. Assumes no
|
|
2281
|
+
* exceptions were enabled before function was called. */
|
|
2282
|
+
if (bEnableFPE)
|
|
2283
|
+
{
|
|
2284
|
+
gmx_fedisableexcept();
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
auto rc = static_cast<int>(gmx_get_stop_condition());
|
|
2288
|
+
|
|
2289
|
+
#if GMX_THREAD_MPI
|
|
2290
|
+
/* we need to join all threads. The sub-threads join when they
|
|
2291
|
+
exit this function, but the master thread needs to be told to
|
|
2292
|
+
wait for that. */
|
|
2293
|
+
if (MASTER(cr))
|
|
2294
|
+
{
|
|
2295
|
+
tMPI_Finalize();
|
|
2296
|
+
}
|
|
2297
|
+
#endif
|
|
2298
|
+
return rc;
|
|
2299
|
+
} // namespace gmx
|
|
2300
|
+
|
|
2301
|
+
Mdrunner::~Mdrunner()
|
|
2302
|
+
{
|
|
2303
|
+
// Clean up of the Manager.
|
|
2304
|
+
// This will end up getting called on every thread-MPI rank, which is unnecessary,
|
|
2305
|
+
// but okay as long as threads synchronize some time before adding or accessing
|
|
2306
|
+
// a new set of restraints.
|
|
2307
|
+
if (restraintManager_)
|
|
2308
|
+
{
|
|
2309
|
+
restraintManager_->clear();
|
|
2310
|
+
GMX_ASSERT(restraintManager_->countRestraints() == 0,
|
|
2311
|
+
"restraints added during runner life time should be cleared at runner "
|
|
2312
|
+
"destruction.");
|
|
2313
|
+
}
|
|
2314
|
+
};
|
|
2315
|
+
|
|
2316
|
+
void Mdrunner::addPotential(std::shared_ptr<gmx::IRestraintPotential> puller, const std::string& name)
|
|
2317
|
+
{
|
|
2318
|
+
GMX_ASSERT(restraintManager_, "Mdrunner must have a restraint manager.");
|
|
2319
|
+
// Not sure if this should be logged through the md logger or something else,
|
|
2320
|
+
// but it is helpful to have some sort of INFO level message sent somewhere.
|
|
2321
|
+
// std::cout << "Registering restraint named " << name << std::endl;
|
|
2322
|
+
|
|
2323
|
+
// When multiple restraints are used, it may be wasteful to register them separately.
|
|
2324
|
+
// Maybe instead register an entire Restraint Manager as a force provider.
|
|
2325
|
+
restraintManager_->addToSpec(std::move(puller), name);
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
Mdrunner::Mdrunner(std::unique_ptr<MDModules> mdModules) : mdModules_(std::move(mdModules)) {}
|
|
2329
|
+
|
|
2330
|
+
Mdrunner::Mdrunner(Mdrunner&&) noexcept = default;
|
|
2331
|
+
|
|
2332
|
+
//NOLINTNEXTLINE(performance-noexcept-move-constructor) working around GCC bug 58265 in CentOS 7
|
|
2333
|
+
Mdrunner& Mdrunner::operator=(Mdrunner&& /*handle*/) noexcept(BUGFREE_NOEXCEPT_STRING) = default;
|
|
2334
|
+
|
|
2335
|
+
class Mdrunner::BuilderImplementation
|
|
2336
|
+
{
|
|
2337
|
+
public:
|
|
2338
|
+
BuilderImplementation() = delete;
|
|
2339
|
+
BuilderImplementation(std::unique_ptr<MDModules> mdModules, compat::not_null<SimulationContext*> context);
|
|
2340
|
+
~BuilderImplementation();
|
|
2341
|
+
|
|
2342
|
+
BuilderImplementation& setExtraMdrunOptions(const MdrunOptions& options,
|
|
2343
|
+
real forceWarningThreshold,
|
|
2344
|
+
StartingBehavior startingBehavior);
|
|
2345
|
+
|
|
2346
|
+
void addHardwareDetectionResult(const gmx_hw_info_t* hwinfo);
|
|
2347
|
+
|
|
2348
|
+
void addDomdec(const DomdecOptions& options);
|
|
2349
|
+
|
|
2350
|
+
void addInput(SimulationInputHandle inputHolder);
|
|
2351
|
+
|
|
2352
|
+
void addVerletList(int nstlist);
|
|
2353
|
+
|
|
2354
|
+
void addReplicaExchange(const ReplicaExchangeParameters& params);
|
|
2355
|
+
|
|
2356
|
+
void addNonBonded(const char* nbpu_opt);
|
|
2357
|
+
|
|
2358
|
+
void addPME(const char* pme_opt_, const char* pme_fft_opt_);
|
|
2359
|
+
|
|
2360
|
+
void addBondedTaskAssignment(const char* bonded_opt);
|
|
2361
|
+
|
|
2362
|
+
void addUpdateTaskAssignment(const char* update_opt);
|
|
2363
|
+
|
|
2364
|
+
void addHardwareOptions(const gmx_hw_opt_t& hardwareOptions);
|
|
2365
|
+
|
|
2366
|
+
void addFilenames(ArrayRef<const t_filenm> filenames);
|
|
2367
|
+
|
|
2368
|
+
void addOutputEnvironment(gmx_output_env_t* outputEnvironment);
|
|
2369
|
+
|
|
2370
|
+
void addLogFile(t_fileio* logFileHandle);
|
|
2371
|
+
|
|
2372
|
+
void addStopHandlerBuilder(std::unique_ptr<StopHandlerBuilder> builder);
|
|
2373
|
+
|
|
2374
|
+
Mdrunner build();
|
|
2375
|
+
|
|
2376
|
+
private:
|
|
2377
|
+
// Default parameters copied from runner.h
|
|
2378
|
+
// \todo Clarify source(s) of default parameters.
|
|
2379
|
+
|
|
2380
|
+
const char* nbpu_opt_ = nullptr;
|
|
2381
|
+
const char* pme_opt_ = nullptr;
|
|
2382
|
+
const char* pme_fft_opt_ = nullptr;
|
|
2383
|
+
const char* bonded_opt_ = nullptr;
|
|
2384
|
+
const char* update_opt_ = nullptr;
|
|
2385
|
+
|
|
2386
|
+
MdrunOptions mdrunOptions_;
|
|
2387
|
+
|
|
2388
|
+
DomdecOptions domdecOptions_;
|
|
2389
|
+
|
|
2390
|
+
ReplicaExchangeParameters replicaExchangeParameters_;
|
|
2391
|
+
|
|
2392
|
+
//! Command-line override for the duration of a neighbor list with the Verlet scheme.
|
|
2393
|
+
int nstlist_ = 0;
|
|
2394
|
+
|
|
2395
|
+
//! World communicator, used for hardware detection and task assignment
|
|
2396
|
+
MPI_Comm libraryWorldCommunicator_ = MPI_COMM_NULL;
|
|
2397
|
+
|
|
2398
|
+
//! Multisim communicator handle.
|
|
2399
|
+
gmx_multisim_t* multiSimulation_;
|
|
2400
|
+
|
|
2401
|
+
//! mdrun communicator
|
|
2402
|
+
MPI_Comm simulationCommunicator_ = MPI_COMM_NULL;
|
|
2403
|
+
|
|
2404
|
+
//! Print a warning if any force is larger than this (in kJ/mol nm).
|
|
2405
|
+
real forceWarningThreshold_ = -1;
|
|
2406
|
+
|
|
2407
|
+
//! Whether the simulation will start afresh, or restart with/without appending.
|
|
2408
|
+
StartingBehavior startingBehavior_ = StartingBehavior::NewSimulation;
|
|
2409
|
+
|
|
2410
|
+
//! The modules that comprise the functionality of mdrun.
|
|
2411
|
+
std::unique_ptr<MDModules> mdModules_;
|
|
2412
|
+
|
|
2413
|
+
//! Detected hardware.
|
|
2414
|
+
const gmx_hw_info_t* hwinfo_ = nullptr;
|
|
2415
|
+
|
|
2416
|
+
//! \brief Parallelism information.
|
|
2417
|
+
gmx_hw_opt_t hardwareOptions_;
|
|
2418
|
+
|
|
2419
|
+
//! filename options for simulation.
|
|
2420
|
+
ArrayRef<const t_filenm> filenames_;
|
|
2421
|
+
|
|
2422
|
+
/*! \brief Handle to output environment.
|
|
2423
|
+
*
|
|
2424
|
+
* \todo gmx_output_env_t needs lifetime management.
|
|
2425
|
+
*/
|
|
2426
|
+
gmx_output_env_t* outputEnvironment_ = nullptr;
|
|
2427
|
+
|
|
2428
|
+
/*! \brief Non-owning handle to MD log file.
|
|
2429
|
+
*
|
|
2430
|
+
* \todo Context should own output facilities for client.
|
|
2431
|
+
* \todo Improve log file handle management.
|
|
2432
|
+
* \internal
|
|
2433
|
+
* Code managing the FILE* relies on the ability to set it to
|
|
2434
|
+
* nullptr to check whether the filehandle is valid.
|
|
2435
|
+
*/
|
|
2436
|
+
t_fileio* logFileHandle_ = nullptr;
|
|
2437
|
+
|
|
2438
|
+
/*!
|
|
2439
|
+
* \brief Builder for simulation stop signal handler.
|
|
2440
|
+
*/
|
|
2441
|
+
std::unique_ptr<StopHandlerBuilder> stopHandlerBuilder_ = nullptr;
|
|
2442
|
+
|
|
2443
|
+
/*!
|
|
2444
|
+
* \brief Sources for initial simulation state.
|
|
2445
|
+
*
|
|
2446
|
+
* See issue #3652 for near-term refinements to the SimulationInput interface.
|
|
2447
|
+
*
|
|
2448
|
+
* See issue #3379 for broader discussion on API aspects of simulation inputs and outputs.
|
|
2449
|
+
*/
|
|
2450
|
+
SimulationInputHandle inputHolder_;
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
Mdrunner::BuilderImplementation::BuilderImplementation(std::unique_ptr<MDModules> mdModules,
|
|
2454
|
+
compat::not_null<SimulationContext*> context) :
|
|
2455
|
+
mdModules_(std::move(mdModules))
|
|
2456
|
+
{
|
|
2457
|
+
libraryWorldCommunicator_ = context->libraryWorldCommunicator_;
|
|
2458
|
+
simulationCommunicator_ = context->simulationCommunicator_;
|
|
2459
|
+
multiSimulation_ = context->multiSimulation_.get();
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
Mdrunner::BuilderImplementation::~BuilderImplementation() = default;
|
|
2463
|
+
|
|
2464
|
+
Mdrunner::BuilderImplementation&
|
|
2465
|
+
Mdrunner::BuilderImplementation::setExtraMdrunOptions(const MdrunOptions& options,
|
|
2466
|
+
const real forceWarningThreshold,
|
|
2467
|
+
const StartingBehavior startingBehavior)
|
|
2468
|
+
{
|
|
2469
|
+
mdrunOptions_ = options;
|
|
2470
|
+
forceWarningThreshold_ = forceWarningThreshold;
|
|
2471
|
+
startingBehavior_ = startingBehavior;
|
|
2472
|
+
return *this;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
void Mdrunner::BuilderImplementation::addDomdec(const DomdecOptions& options)
|
|
2476
|
+
{
|
|
2477
|
+
domdecOptions_ = options;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
void Mdrunner::BuilderImplementation::addVerletList(int nstlist)
|
|
2481
|
+
{
|
|
2482
|
+
nstlist_ = nstlist;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
void Mdrunner::BuilderImplementation::addReplicaExchange(const ReplicaExchangeParameters& params)
|
|
2486
|
+
{
|
|
2487
|
+
replicaExchangeParameters_ = params;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
Mdrunner Mdrunner::BuilderImplementation::build()
|
|
2491
|
+
{
|
|
2492
|
+
auto newRunner = Mdrunner(std::move(mdModules_));
|
|
2493
|
+
|
|
2494
|
+
newRunner.mdrunOptions = mdrunOptions_;
|
|
2495
|
+
newRunner.pforce = forceWarningThreshold_;
|
|
2496
|
+
newRunner.startingBehavior = startingBehavior_;
|
|
2497
|
+
newRunner.domdecOptions = domdecOptions_;
|
|
2498
|
+
|
|
2499
|
+
// \todo determine an invariant to check or confirm that all gmx_hw_opt_t objects are valid
|
|
2500
|
+
newRunner.hw_opt = hardwareOptions_;
|
|
2501
|
+
|
|
2502
|
+
// No invariant to check. This parameter exists to optionally override other behavior.
|
|
2503
|
+
newRunner.nstlist_cmdline = nstlist_;
|
|
2504
|
+
|
|
2505
|
+
newRunner.replExParams = replicaExchangeParameters_;
|
|
2506
|
+
|
|
2507
|
+
newRunner.filenames = filenames_;
|
|
2508
|
+
|
|
2509
|
+
newRunner.libraryWorldCommunicator = libraryWorldCommunicator_;
|
|
2510
|
+
|
|
2511
|
+
newRunner.simulationCommunicator = simulationCommunicator_;
|
|
2512
|
+
|
|
2513
|
+
// nullptr is a valid value for the multisim handle
|
|
2514
|
+
newRunner.ms = multiSimulation_;
|
|
2515
|
+
|
|
2516
|
+
if (hwinfo_)
|
|
2517
|
+
{
|
|
2518
|
+
newRunner.hwinfo_ = hwinfo_;
|
|
2519
|
+
}
|
|
2520
|
+
else
|
|
2521
|
+
{
|
|
2522
|
+
GMX_THROW(gmx::APIError(
|
|
2523
|
+
"MdrunnerBuilder::addHardwareDetectionResult() is required before build()"));
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
if (inputHolder_)
|
|
2527
|
+
{
|
|
2528
|
+
newRunner.inputHolder_ = std::move(inputHolder_);
|
|
2529
|
+
}
|
|
2530
|
+
else
|
|
2531
|
+
{
|
|
2532
|
+
GMX_THROW(gmx::APIError("MdrunnerBuilder::addInput() is required before build()."));
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
// \todo Clarify ownership and lifetime management for gmx_output_env_t
|
|
2536
|
+
// \todo Update sanity checking when output environment has clearly specified invariants.
|
|
2537
|
+
// Initialization and default values for oenv are not well specified in the current version.
|
|
2538
|
+
if (outputEnvironment_)
|
|
2539
|
+
{
|
|
2540
|
+
newRunner.oenv = outputEnvironment_;
|
|
2541
|
+
}
|
|
2542
|
+
else
|
|
2543
|
+
{
|
|
2544
|
+
GMX_THROW(gmx::APIError(
|
|
2545
|
+
"MdrunnerBuilder::addOutputEnvironment() is required before build()"));
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
newRunner.logFileHandle = logFileHandle_;
|
|
2549
|
+
|
|
2550
|
+
if (nbpu_opt_)
|
|
2551
|
+
{
|
|
2552
|
+
newRunner.nbpu_opt = nbpu_opt_;
|
|
2553
|
+
}
|
|
2554
|
+
else
|
|
2555
|
+
{
|
|
2556
|
+
GMX_THROW(gmx::APIError("MdrunnerBuilder::addNonBonded() is required before build()"));
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
if (pme_opt_ && pme_fft_opt_)
|
|
2560
|
+
{
|
|
2561
|
+
newRunner.pme_opt = pme_opt_;
|
|
2562
|
+
newRunner.pme_fft_opt = pme_fft_opt_;
|
|
2563
|
+
}
|
|
2564
|
+
else
|
|
2565
|
+
{
|
|
2566
|
+
GMX_THROW(gmx::APIError("MdrunnerBuilder::addElectrostatics() is required before build()"));
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
if (bonded_opt_)
|
|
2570
|
+
{
|
|
2571
|
+
newRunner.bonded_opt = bonded_opt_;
|
|
2572
|
+
}
|
|
2573
|
+
else
|
|
2574
|
+
{
|
|
2575
|
+
GMX_THROW(gmx::APIError(
|
|
2576
|
+
"MdrunnerBuilder::addBondedTaskAssignment() is required before build()"));
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
if (update_opt_)
|
|
2580
|
+
{
|
|
2581
|
+
newRunner.update_opt = update_opt_;
|
|
2582
|
+
}
|
|
2583
|
+
else
|
|
2584
|
+
{
|
|
2585
|
+
GMX_THROW(gmx::APIError(
|
|
2586
|
+
"MdrunnerBuilder::addUpdateTaskAssignment() is required before build() "));
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
newRunner.restraintManager_ = std::make_unique<gmx::RestraintManager>();
|
|
2591
|
+
|
|
2592
|
+
if (stopHandlerBuilder_)
|
|
2593
|
+
{
|
|
2594
|
+
newRunner.stopHandlerBuilder_ = std::move(stopHandlerBuilder_);
|
|
2595
|
+
}
|
|
2596
|
+
else
|
|
2597
|
+
{
|
|
2598
|
+
newRunner.stopHandlerBuilder_ = std::make_unique<StopHandlerBuilder>();
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
return newRunner;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
void Mdrunner::BuilderImplementation::addHardwareDetectionResult(const gmx_hw_info_t* hwinfo)
|
|
2605
|
+
{
|
|
2606
|
+
hwinfo_ = hwinfo;
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
void Mdrunner::BuilderImplementation::addNonBonded(const char* nbpu_opt)
|
|
2610
|
+
{
|
|
2611
|
+
nbpu_opt_ = nbpu_opt;
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
void Mdrunner::BuilderImplementation::addPME(const char* pme_opt, const char* pme_fft_opt)
|
|
2615
|
+
{
|
|
2616
|
+
pme_opt_ = pme_opt;
|
|
2617
|
+
pme_fft_opt_ = pme_fft_opt;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
void Mdrunner::BuilderImplementation::addBondedTaskAssignment(const char* bonded_opt)
|
|
2621
|
+
{
|
|
2622
|
+
bonded_opt_ = bonded_opt;
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
void Mdrunner::BuilderImplementation::addUpdateTaskAssignment(const char* update_opt)
|
|
2626
|
+
{
|
|
2627
|
+
update_opt_ = update_opt;
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
void Mdrunner::BuilderImplementation::addHardwareOptions(const gmx_hw_opt_t& hardwareOptions)
|
|
2631
|
+
{
|
|
2632
|
+
hardwareOptions_ = hardwareOptions;
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
void Mdrunner::BuilderImplementation::addFilenames(ArrayRef<const t_filenm> filenames)
|
|
2636
|
+
{
|
|
2637
|
+
filenames_ = filenames;
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
void Mdrunner::BuilderImplementation::addOutputEnvironment(gmx_output_env_t* outputEnvironment)
|
|
2641
|
+
{
|
|
2642
|
+
outputEnvironment_ = outputEnvironment;
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
void Mdrunner::BuilderImplementation::addLogFile(t_fileio* logFileHandle)
|
|
2646
|
+
{
|
|
2647
|
+
logFileHandle_ = logFileHandle;
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
void Mdrunner::BuilderImplementation::addStopHandlerBuilder(std::unique_ptr<StopHandlerBuilder> builder)
|
|
2651
|
+
{
|
|
2652
|
+
stopHandlerBuilder_ = std::move(builder);
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
void Mdrunner::BuilderImplementation::addInput(SimulationInputHandle inputHolder)
|
|
2656
|
+
{
|
|
2657
|
+
inputHolder_ = std::move(inputHolder);
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
MdrunnerBuilder::MdrunnerBuilder(std::unique_ptr<MDModules> mdModules,
|
|
2661
|
+
compat::not_null<SimulationContext*> context) :
|
|
2662
|
+
impl_{ std::make_unique<Mdrunner::BuilderImplementation>(std::move(mdModules), context) }
|
|
2663
|
+
{
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
MdrunnerBuilder::~MdrunnerBuilder() = default;
|
|
2667
|
+
|
|
2668
|
+
MdrunnerBuilder& MdrunnerBuilder::addHardwareDetectionResult(const gmx_hw_info_t* hwinfo)
|
|
2669
|
+
{
|
|
2670
|
+
impl_->addHardwareDetectionResult(hwinfo);
|
|
2671
|
+
return *this;
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
MdrunnerBuilder& MdrunnerBuilder::addSimulationMethod(const MdrunOptions& options,
|
|
2675
|
+
real forceWarningThreshold,
|
|
2676
|
+
const StartingBehavior startingBehavior)
|
|
2677
|
+
{
|
|
2678
|
+
impl_->setExtraMdrunOptions(options, forceWarningThreshold, startingBehavior);
|
|
2679
|
+
return *this;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
MdrunnerBuilder& MdrunnerBuilder::addDomainDecomposition(const DomdecOptions& options)
|
|
2683
|
+
{
|
|
2684
|
+
impl_->addDomdec(options);
|
|
2685
|
+
return *this;
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
MdrunnerBuilder& MdrunnerBuilder::addNeighborList(int nstlist)
|
|
2689
|
+
{
|
|
2690
|
+
impl_->addVerletList(nstlist);
|
|
2691
|
+
return *this;
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
MdrunnerBuilder& MdrunnerBuilder::addReplicaExchange(const ReplicaExchangeParameters& params)
|
|
2695
|
+
{
|
|
2696
|
+
impl_->addReplicaExchange(params);
|
|
2697
|
+
return *this;
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
MdrunnerBuilder& MdrunnerBuilder::addNonBonded(const char* nbpu_opt)
|
|
2701
|
+
{
|
|
2702
|
+
impl_->addNonBonded(nbpu_opt);
|
|
2703
|
+
return *this;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
MdrunnerBuilder& MdrunnerBuilder::addElectrostatics(const char* pme_opt, const char* pme_fft_opt)
|
|
2707
|
+
{
|
|
2708
|
+
// The builder method may become more general in the future, but in this version,
|
|
2709
|
+
// parameters for PME electrostatics are both required and the only parameters
|
|
2710
|
+
// available.
|
|
2711
|
+
if (pme_opt && pme_fft_opt)
|
|
2712
|
+
{
|
|
2713
|
+
impl_->addPME(pme_opt, pme_fft_opt);
|
|
2714
|
+
}
|
|
2715
|
+
else
|
|
2716
|
+
{
|
|
2717
|
+
GMX_THROW(
|
|
2718
|
+
gmx::InvalidInputError("addElectrostatics() arguments must be non-null pointers."));
|
|
2719
|
+
}
|
|
2720
|
+
return *this;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
MdrunnerBuilder& MdrunnerBuilder::addBondedTaskAssignment(const char* bonded_opt)
|
|
2724
|
+
{
|
|
2725
|
+
impl_->addBondedTaskAssignment(bonded_opt);
|
|
2726
|
+
return *this;
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
MdrunnerBuilder& MdrunnerBuilder::addUpdateTaskAssignment(const char* update_opt)
|
|
2730
|
+
{
|
|
2731
|
+
impl_->addUpdateTaskAssignment(update_opt);
|
|
2732
|
+
return *this;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
Mdrunner MdrunnerBuilder::build()
|
|
2736
|
+
{
|
|
2737
|
+
return impl_->build();
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
MdrunnerBuilder& MdrunnerBuilder::addHardwareOptions(const gmx_hw_opt_t& hardwareOptions)
|
|
2741
|
+
{
|
|
2742
|
+
impl_->addHardwareOptions(hardwareOptions);
|
|
2743
|
+
return *this;
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
MdrunnerBuilder& MdrunnerBuilder::addFilenames(ArrayRef<const t_filenm> filenames)
|
|
2747
|
+
{
|
|
2748
|
+
impl_->addFilenames(filenames);
|
|
2749
|
+
return *this;
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
MdrunnerBuilder& MdrunnerBuilder::addOutputEnvironment(gmx_output_env_t* outputEnvironment)
|
|
2753
|
+
{
|
|
2754
|
+
impl_->addOutputEnvironment(outputEnvironment);
|
|
2755
|
+
return *this;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
MdrunnerBuilder& MdrunnerBuilder::addLogFile(t_fileio* logFileHandle)
|
|
2759
|
+
{
|
|
2760
|
+
impl_->addLogFile(logFileHandle);
|
|
2761
|
+
return *this;
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
MdrunnerBuilder& MdrunnerBuilder::addStopHandlerBuilder(std::unique_ptr<StopHandlerBuilder> builder)
|
|
2765
|
+
{
|
|
2766
|
+
impl_->addStopHandlerBuilder(std::move(builder));
|
|
2767
|
+
return *this;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
MdrunnerBuilder& MdrunnerBuilder::addInput(SimulationInputHandle input)
|
|
2771
|
+
{
|
|
2772
|
+
impl_->addInput(std::move(input));
|
|
2773
|
+
return *this;
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
MdrunnerBuilder::MdrunnerBuilder(MdrunnerBuilder&&) noexcept = default;
|
|
2777
|
+
|
|
2778
|
+
MdrunnerBuilder& MdrunnerBuilder::operator=(MdrunnerBuilder&&) noexcept = default;
|
|
2779
|
+
|
|
2780
|
+
} // namespace gmx
|