GMX_ASSERT(stopHandlerBuilder_, "Runner must provide StopHandlerBuilder to simulator.");
SimulatorBuilder simulatorBuilder;
+ simulatorBuilder.add(MembedHolder(membed));
simulatorBuilder.add(std::move(stopHandlerBuilder_));
// build and run simulator object based on user-input
useModularSimulator, fplog, cr, ms, mdlog, static_cast<int>(filenames.size()),
filenames.data(), oenv, mdrunOptions, startingBehavior, vsite.get(), constr.get(),
enforcedRotation ? enforcedRotation->getLegacyEnfrot() : nullptr, deform.get(),
- mdModules_->outputProvider(), mdModules_->notifier(), inputrec, imdSession.get(),
- pull_work, swap, &mtop, globalState.get(), &observablesHistory, mdAtoms.get(),
- &nrnb, wcycle, fr, &enerd, &ekind, &runScheduleWork, replExParams, membed,
- walltime_accounting, doRerun);
+ mdModules_->outputProvider(), mdModules_->notifier(), inputrec, imdSession.get(), pull_work,
+ swap, &mtop, globalState.get(), &observablesHistory, mdAtoms.get(), &nrnb, wcycle,
+ fr, &enerd, &ekind, &runScheduleWork, replExParams, walltime_accounting, doRerun);
simulator->run();
if (fr->pmePpCommGpu)
gmx_ekindata_t* ekind,
MdrunScheduleWorkload* runScheduleWork,
const ReplicaExchangeParameters& replExParams,
- gmx_membed_t* membed,
gmx_walltime_accounting* walltime_accounting,
bool doRerun)
{
{
throw APIError("You must add a StopHandlerBuilder before calling build().");
}
+ if (!membedHolder_)
+ {
+ throw APIError("You must add a MembedHolder before calling build().");
+ }
if (useModularSimulator)
{
// NOLINTNEXTLINE(modernize-make-unique): make_unique does not work with private constructor
return std::unique_ptr<ModularSimulator>(new ModularSimulator(
- fplog, cr, ms, mdlog, nfile, fnm, oenv, mdrunOptions, startingBehavior, vsite,
- constr, enforcedRotation, deform, outputProvider, mdModulesNotifier, inputrec,
- imdSession, pull_work, swap, top_global, state_global, observablesHistory, mdAtoms,
- nrnb, wcycle, fr, enerd, ekind, runScheduleWork, replExParams, membed,
+ fplog, cr, ms, mdlog, nfile, fnm, oenv, mdrunOptions, startingBehavior, vsite, constr,
+ enforcedRotation, deform, outputProvider, mdModulesNotifier, inputrec, imdSession,
+ pull_work, swap, top_global, state_global, observablesHistory, mdAtoms, nrnb,
+ wcycle, fr, enerd, ekind, runScheduleWork, replExParams, membedHolder_->membed(),
walltime_accounting, std::move(stopHandlerBuilder_), doRerun));
}
// NOLINTNEXTLINE(modernize-make-unique): make_unique does not work with private constructor
fplog, cr, ms, mdlog, nfile, fnm, oenv, mdrunOptions, startingBehavior, vsite, constr,
enforcedRotation, deform, outputProvider, mdModulesNotifier, inputrec, imdSession,
pull_work, swap, top_global, state_global, observablesHistory, mdAtoms, nrnb, wcycle,
- fr, enerd, ekind, runScheduleWork, replExParams, membed, walltime_accounting,
- std::move(stopHandlerBuilder_), doRerun));
+ fr, enerd, ekind, runScheduleWork, replExParams, membedHolder_->membed(),
+ walltime_accounting, std::move(stopHandlerBuilder_), doRerun));
}
} // namespace gmx
struct gmx_membed_t;
struct gmx_multisim_t;
struct gmx_output_env_t;
-struct gmx_vsite_t;
struct gmx_wallcycle;
struct gmx_walltime_accounting;
struct ObservablesHistory;
class StopHandlerBuilder;
struct MdrunOptions;
+/*! \brief Membed SimulatorBuilder parameter type.
+ *
+ * Does not (yet) encapsulate ownership semantics of resources. Simulator is
+ * not (necessarily) granted ownership of resources. Client is responsible for
+ * maintaining the validity of resources for the life time of the Simulator,
+ * then for cleaning up those resources.
+ */
+class MembedHolder
+{
+public:
+ explicit MembedHolder(gmx_membed_t* membed) : membed_(membed) {}
+
+ gmx_membed_t* membed() { return membed_; }
+
+private:
+ gmx_membed_t* membed_;
+};
+
/*! \libinternal
* \brief Class preparing the creation of Simulator objects
*
class SimulatorBuilder
{
public:
+ void add(MembedHolder&& membedHolder)
+ {
+ membedHolder_ = std::make_unique<MembedHolder>(membedHolder);
+ }
+
void add(std::unique_ptr<StopHandlerBuilder> stopHandlerBuilder)
{
stopHandlerBuilder_ = std::move(stopHandlerBuilder);
*
* \return Unique pointer to a Simulator object
*/
- std::unique_ptr<ISimulator> build(bool useModularSimulator,
- FILE* fplog,
- t_commrec* cr,
- const gmx_multisim_t* ms,
- const MDLogger& mdlog,
- int nfile,
- const t_filenm* fnm,
- const gmx_output_env_t* oenv,
- const MdrunOptions& mdrunOptions,
- StartingBehavior startingBehavior,
- VirtualSitesHandler* vsite,
- Constraints* constr,
- gmx_enfrot* enforcedRotation,
- BoxDeformation* deform,
- IMDOutputProvider* outputProvider,
- const MdModulesNotifier& mdModulesNotifier,
- t_inputrec* inputrec,
- ImdSession* imdSession,
- pull_t* pull_work,
- t_swap* swap,
- gmx_mtop_t* top_global,
-
+ std::unique_ptr<ISimulator> build(bool useModularSimulator,
+ FILE* fplog,
+ t_commrec* cr,
+ const gmx_multisim_t* ms,
+ const MDLogger& mdlog,
+ int nfile,
+ const t_filenm* fnm,
+ const gmx_output_env_t* oenv,
+ const MdrunOptions& mdrunOptions,
+ StartingBehavior startingBehavior,
+ VirtualSitesHandler* vsite,
+ Constraints* constr,
+ gmx_enfrot* enforcedRotation,
+ BoxDeformation* deform,
+ IMDOutputProvider* outputProvider,
+ const MdModulesNotifier& mdModulesNotifier,
+ t_inputrec* inputrec,
+ ImdSession* imdSession,
+ pull_t* pull_work,
+ t_swap* swap,
+ gmx_mtop_t* top_global,
t_state* state_global,
ObservablesHistory* observablesHistory,
MDAtoms* mdAtoms,
gmx_ekindata_t* ekind,
MdrunScheduleWorkload* runScheduleWork,
const ReplicaExchangeParameters& replExParams,
- gmx_membed_t* membed,
gmx_walltime_accounting* walltime_accounting,
bool doRerun);
private:
+ std::unique_ptr<MembedHolder> membedHolder_;
std::unique_ptr<StopHandlerBuilder> stopHandlerBuilder_;
};
+
} // namespace gmx
#endif // GMX_MDRUN_SIMULATORBUILDER_SIMULATORBUILDER_H