Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

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

Generated on Tue Jun 18 04:07:46 2013 for NAMD by  doxygen 1.3.9.1