GlobalMasterServer.h

Go to the documentation of this file.
00001 
00007 /* A GlobalMasterServer is responsible for keeping track of all
00008    of the ComputeGlobalMasters present on the master node.  It must
00009    relay atom data to them, and pass messages to the nodes on their
00010    behalf. */
00011 
00012 #ifndef GLOBALMASTERSERVER_H
00013 #define GLOBALMASTERSERVER_H
00014 
00015 #include "Lattice.h"
00016 
00017 class ComputeGlobalConfigMsg;
00018 class ComputeGlobalDataMsg;
00019 class ComputeGlobalResultsMsg;
00020 class ComputeMgr;
00021 
00022 class GlobalMasterServer {
00023  public:
00024   /* initializes this to be a GlobalMasterServer that has no
00025      masters to serve yet.  GlobalMasterServer will wait for
00026      <theNumDataSenders> data messages before responding */
00027   GlobalMasterServer(ComputeMgr *m, int theNumDataSenders);
00028 
00029   virtual ~GlobalMasterServer();
00030 
00031   /* passes atom coordinate data to the GlobalMasters once this has
00032      been called by each of the ComputeGlobals, and potentially
00033      generates response messages. */
00034   void recvData(ComputeGlobalDataMsg *);
00035   
00036   /* gives this control over <newClient> */
00037   void addClient(GlobalMaster *newClient);
00038  private:
00039   int forceSendEnabled; // are total forces received?
00040   int numDataSenders; // the number of expected messages each cycle
00041   int numForceSenders; // the number of expected force messages each cycle
00042   int latticeCount; // is lattice received so far this cycle
00043   int recvCount; // the number of messages so far this cycle
00044   int firstTime; // used to be compatible with the ComputeGlobals
00045   int totalAtomsRequested; // the total number of atoms requested
00046                            // (initially zero)
00047   int totalGroupsRequested; // the total number of groups requested
00048 
00049   /* the receivedAtomIDs and receivedAtomPositions lists give
00050      correspond to each other: element i of the receivedAtomIDs is the
00051      ID of an atom that has position given by element i of the
00052      receivedAtomPositions. The receivedForceIDs and receivedTotalForces
00053      lists have similar relationship. This data is built up as messages are
00054      received, and cleared after being passed off to the Masters. */
00055   AtomIDList receivedAtomIDs;
00056   PositionList receivedAtomPositions;
00057   PositionList receivedGroupPositions; // the group positions
00058   BigRealList receivedGroupMasses; // the group positions
00059   ForceList receivedGroupTotalForces;
00060   AtomIDList receivedForceIDs;
00061   ForceList receivedTotalForces;
00062 
00063   int step;  // current timestep received from patches
00064   Lattice lattice;  // current lattice received from patches
00065 
00066   /* the compute manager responsible for my message delivery */
00067   ComputeMgr *myComputeManager;
00068 
00069   /* the list of global compute masters that this server is
00070      responsible for serving */
00071   ResizeArray<GlobalMaster *> clientList;
00072 
00073   /* passes atom data to the clients and generates responses.  The
00074    first time we just get the requested atom ids from the clients and
00075    send messages to the ComputeGlobals requesting those atoms, so we
00076    can have coordinates ready for the first time step.  All future
00077    times this is called we ask the masters for forces, as well.  XXX
00078    this is a little weird...why should the first timestep be special?
00079    Only because we are dealing with the unwritten rule made by the
00080    ComputeGlobals that they must not be sent forces before they are
00081    "configured" */
00082   int callClients();
00083 
00084   /* puts all the info requested by the clients into a single list */
00085   void resetAtomList(AtomIDList &atomsRequested);
00086   void resetForceList(AtomIDList &atomsForced, ForceList &forces,
00087                       ForceList &groupforces);
00088 
00089   /* the group list is ugly - it is, as far as I can tell, a list of
00090      the atoms in each group, separated by -1s.  So if the Masters
00091      request groups {1,2,3} and {2,3,4}, <groupsRequested> will be set
00092      to the list (1,2,3,-1,2,3,4,-1).  The number of groups sent is
00093      stored in the variable <numGroups>*/
00094   void resetGroupList(AtomIDList &groupsRequested, int *numGroups);
00095 
00096   /* stores the version of forces that was found by resetForceList */
00097   AtomIDList lastAtomsForced;
00098   ForceList lastForces;
00099 
00100 };
00101 
00102 #endif
00103 

Generated on Wed Nov 22 01:17:15 2017 for NAMD by  doxygen 1.4.7