Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::Mdrunner Class Reference

#include <gromacs/mdrun/runner.h>

Description

Runner object for supporting setup and execution of mdrun.

This class has responsibility for the lifetime of data structures that exist for the life of the simulation, e.g. for logging and communication.

It is also responsible for initializing data members that e.g. correspond to values potentially set by commmand-line options. Later these will be obtained directly from modules, and the results of command-line option handling returned directly to the modules, rather than propagated to them by data members of this class.

Todo:
Most of the attributes should be declared by specific modules as command-line options. Accordingly, they do not conform to the naming scheme, because that would make for a lot of noise in the diff, only to have it change again when the options move to their modules.
Todo:
Preparing logging and MPI contexts could probably be a higher-level responsibility, so that an Mdrunner would get made without needing to re-initialize these components (as currently happens always for the master rank, and differently for the spawned ranks with thread-MPI).

Public Member Functions

int mdrunner ()
 Driver routine, that calls the different simulation methods. More...
 
void addPotential (std::shared_ptr< IRestraintPotential > restraint, const std::string &name)
 Add a potential to be evaluated during MD integration. More...
 
void spawnThreads (int numThreadsToLaunch)
 Prepare the thread-MPI communicator to have numThreadsToLaunch ranks, by spawning new thread-MPI threads. More...
 
Mdrunner cloneOnSpawnedThread () const
 Initializes a new Mdrunner from the master. More...
 
 Mdrunner (const Mdrunner &)=delete
 Copy not allowed. More...
 
Mdrunneroperator= (const Mdrunner &)=delete
 
 Mdrunner (Mdrunner &&handle) noexcept
 Mdrunner objects can be passed by value via move semantics. More...
 
Mdrunneroperator= (Mdrunner &&handle) noexcept(BUGFREE_NOEXCEPT_STRING)
 

Constructor & Destructor Documentation

gmx::Mdrunner::Mdrunner ( const Mdrunner )
delete

Copy not allowed.

An Mdrunner has unique resources and it is not clear whether any of one of those resources should be duplicated or shared unless the specific use case is known. Either build a fresh runner or use a helper function for clearly indicated behavior. API clarification may allow unambiguous initialization by copy in future versions.

gmx::Mdrunner::Mdrunner ( Mdrunner &&  handle)
defaultnoexcept

Mdrunner objects can be passed by value via move semantics.

Parameters
handlerunner instance to be moved from.

Member Function Documentation

void gmx::Mdrunner::addPotential ( std::shared_ptr< IRestraintPotential restraint,
const std::string &  name 
)

Add a potential to be evaluated during MD integration.

Parameters
restraintMD restraint potential to apply
nameUser-friendly plain-text name to uniquely identify the puller

This implementation attaches an object providing the gmx::IRestraintPotential interface.

Todo:
Mdrunner should fetch such resources from the SimulationContext rather than offering this public interface.
Mdrunner gmx::Mdrunner::cloneOnSpawnedThread ( ) const

Initializes a new Mdrunner from the master.

Run this method in a new thread from a master runner to get additional workers on spawned threads.

Returns
New Mdrunner instance suitable for thread-MPI work on new ranks.
Todo:
clarify (multiple) invariants during MD runner start-up. The runner state before and after launching threads is distinct enough that it should be codified in the invariants of different classes. That would mean that the object returned by this method would be of a different type than the object held by the client up to the point of call, and its name would be changed to "launchOnSpawnedThread" or something not including the word "clone".
int gmx::Mdrunner::mdrunner ( )

Driver routine, that calls the different simulation methods.

Currently, thread-MPI does not spawn threads until during mdrunner() and parallelism is not initialized until some time during this call...

void gmx::Mdrunner::spawnThreads ( int  numThreadsToLaunch)

Prepare the thread-MPI communicator to have numThreadsToLaunch ranks, by spawning new thread-MPI threads.

Called by mdrunner() to start a specific number of threads (including the main thread) for thread-parallel runs. This in turn calls mdrunner() for each thread.


The documentation for this class was generated from the following files: