Move main.*, splitter.*, gmx_omp_nthreads.* to mdlib
[gromacs.git] / src / gromacs / mdlib / mdrun_signalling.h
blob1531c2a45040b608121a8e22c73e0a0de4270f6b
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2011,2014,2015, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 /*! \libinternal \file
39 * \brief This file declares functions for inter-rank signalling by mdrun
41 * This handles details of responding to termination conditions,
42 * coordinating checkpoints, and coordinating multi-simulations.
44 * \author Berk Hess <hess@kth.se>
45 * \author Mark Abraham <mark.j.abraham@gmail.com>
46 * \inlibraryapi
47 * \ingroup module_mdlib
49 #ifndef GMX_MDLIB_MDRUN_SIGNALLING_H
50 #define GMX_MDLIB_MDRUN_SIGNALLING_H
52 #include "gromacs/mdtypes/inputrec.h"
53 #include "gromacs/utility/real.h"
55 struct t_commrec;
57 namespace gmx
60 template <typename T>
61 class ArrayRef;
65 /*! \brief Simulation conditions to transmit.
67 * Keep in mind that they are transmitted to other ranks through an
68 * MPI_Reduce after casting them to a real (so the signals can be sent
69 * together with other data). This means that the only meaningful
70 * values are positive, negative or zero. */
71 enum {
72 eglsCHKPT, eglsSTOPCOND, eglsRESETCOUNTERS, eglsNR
75 /*! \internal
76 * \brief Object used by mdrun ranks to signal to each other
78 * Note that xlc on BG/Q requires sig to be of size char (see unit tests
79 * of ArrayRef for details). */
80 struct gmx_signalling_t {
81 int nstms; /**< The frequency for inter-simulation communication */
82 signed char sig[eglsNR]; /**< The signal set by this rank in do_md */
83 signed char set[eglsNR]; /**< The communicated signal, equal for all ranks once communication has occurred */
84 real mpiBuffer[eglsNR]; /**< Buffer for communication */
87 /*! \brief Construct a struct gmx_signalling_t */
88 void init_global_signals(struct gmx_signalling_t *gs,
89 const t_commrec *cr,
90 const t_inputrec *ir,
91 int repl_ex_nst);
93 /*! \brief Fill the array of reals in which inter- and
94 * intra-simulation signals will be communicated
95 * with the signal values to be sent. */
96 gmx::ArrayRef<real>
97 prepareSignalBuffer(struct gmx_signalling_t *gs);
99 /*! \brief Handle intra- and inter-simulation signals recieved
101 * If a multi-simulation signal should be handled, communicate between
102 * simulation-master ranks, then propagate from the masters to the
103 * rest of the ranks for each simulation.
105 * Then, set the flags that mdrun will use to respond to the signals
106 * received. */
107 void
108 handleSignals(struct gmx_signalling_t *gs,
109 const t_commrec *cr,
110 bool bInterSimGS);
112 #endif