NAMD
GlobalMasterServer.h
Go to the documentation of this file.
1 
7 /* A GlobalMasterServer is responsible for keeping track of all
8  of the ComputeGlobalMasters present on the master node. It must
9  relay atom data to them, and pass messages to the nodes on their
10  behalf. */
11 
12 #ifndef GLOBALMASTERSERVER_H
13 #define GLOBALMASTERSERVER_H
14 
15 #include "Lattice.h"
16 
17 class ComputeGlobalConfigMsg;
20 class ComputeMgr;
21 
23  public:
24  /* initializes this to be a GlobalMasterServer that has no
25  masters to serve yet. GlobalMasterServer will wait for
26  <theNumDataSenders> data messages before responding */
27  GlobalMasterServer(ComputeMgr *m, int theNumDataSenders);
28 
29  virtual ~GlobalMasterServer();
30 
31  /* passes atom coordinate data to the GlobalMasters once this has
32  been called by each of the ComputeGlobals, and potentially
33  generates response messages. */
35 
36  /* gives this control over <newClient> */
37  void addClient(GlobalMaster *newClient);
38  private:
39  int forceSendEnabled; // are total forces received?
40  int numDataSenders; // the number of expected messages each cycle
41  int numForceSenders; // the number of expected force messages each cycle
42  int latticeCount; // is lattice received so far this cycle
43  int recvCount; // the number of messages so far this cycle
44  int recvPatchesCount; // the number of patches so far this cycle
45  int firstTime; // used to be compatible with the ComputeGlobals
46  int totalAtomsRequested; // the total number of atoms requested
47  // (initially zero)
48  int totalGroupsRequested; // the total number of groups requested
49  int totalGridObjsRequested; // the total number of grid objects requested
50 
51  /* the receivedAtomIDs and receivedAtomPositions lists give
52  correspond to each other: element i of the receivedAtomIDs is the
53  ID of an atom that has position given by element i of the
54  receivedAtomPositions. The receivedForceIDs and receivedTotalForces
55  lists have similar relationship. This data is built up as messages are
56  received, and cleared after being passed off to the Masters. */
57  AtomIDList receivedAtomIDs;
58  PositionList receivedAtomPositions;
59  PositionList receivedGroupPositions; // the group positions
60  BigRealList receivedGroupMasses; // the group positions
61  ForceList receivedGroupTotalForces;
62  AtomIDList receivedForceIDs;
63  ForceList receivedTotalForces;
64 
66  IntList receivedGridObjIndices;
67 
69  BigRealList receivedGridObjValues;
70 
71  int step; // current timestep received from patches
72  Lattice lattice; // current lattice received from patches
73 
74  /* the compute manager responsible for my message delivery */
75  ComputeMgr *myComputeManager;
76 
77  /* the list of global compute masters that this server is
78  responsible for serving */
79  ResizeArray<GlobalMaster *> clientList;
80 
81  /* passes atom data to the clients and generates responses. The
82  first time we just get the requested atom ids from the clients and
83  send messages to the ComputeGlobals requesting those atoms, so we
84  can have coordinates ready for the first time step. All future
85  times this is called we ask the masters for forces, as well. XXX
86  this is a little weird...why should the first timestep be special?
87  Only because we are dealing with the unwritten rule made by the
88  ComputeGlobals that they must not be sent forces before they are
89  "configured" */
90  int callClients();
91 
92  /* puts all the info requested by the clients into a single list */
93  void resetAtomList(AtomIDList &atomsRequested);
94  void resetForceList(AtomIDList &atomsForced, ForceList &forces,
95  ForceList &groupforces);
96 
97  /* the group list is ugly - it is, as far as I can tell, a list of
98  the atoms in each group, separated by -1s. So if the Masters
99  request groups {1,2,3} and {2,3,4}, <groupsRequested> will be set
100  to the list (1,2,3,-1,2,3,4,-1). The number of groups sent is
101  stored in the variable <numGroups>*/
102  void resetGroupList(AtomIDList &groupsRequested, int *numGroups);
103 
104  void resetGridObjList(IntList &gridObjsRequested);
105  void resetGridObjForceList(BigRealList &gridObjForces);
106 
107  /* stores the version of forces that was found by resetForceList */
108  AtomIDList lastAtomsForced;
109  ForceList lastForces;
110 
111 };
112 
113 #endif
114 
static __thread float4 * forces
void recvData(ComputeGlobalDataMsg *)
void addClient(GlobalMaster *newClient)
GlobalMasterServer(ComputeMgr *m, int theNumDataSenders)