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

PatchMgr.h

Go to the documentation of this file.
00001 
00007 /*****************************************************************************
00008  * $Source: /home/cvs/namd/cvsroot/namd2/src/PatchMgr.h,v $
00009  * $Author: jim $
00010  * $Date: 2012/02/19 22:17:07 $
00011  * $Revision: 1.1027 $
00012  *****************************************************************************/
00013 
00014 #ifndef PATCHMGR_H
00015 #define PATCHMGR_H
00016 
00017 #include "charm++.h"
00018 
00019 #include "NamdTypes.h"
00020 #include "SortedArray.h"
00021 #include "HomePatch.h"
00022 #include "HomePatchList.h"
00023 #include "BOCgroup.h"
00024 #include "Migration.h"
00025 #include "MigrateAtomsMsg.h"
00026 #include "PatchMgr.decl.h"
00027 
00028 #if USE_TOPOMAP 
00029 #include "TopoManager.h"
00030 #endif
00031 
00032 class HomePatch;
00033 
00034 class MovePatchesMsg : public CMessage_MovePatchesMsg {
00035 public:
00036     NodeID  fromNodeID;
00037     PatchID pid;
00038     FullAtomList atom;
00039 
00040     MovePatchesMsg(void) { ; }
00041 
00042     MovePatchesMsg(PatchID n, FullAtomList a) : pid(n), atom(a)
00043     {
00044       fromNodeID = CkMyPe();
00045     }
00046 
00047   // pack and unpack functions
00048   static void* pack(MovePatchesMsg *msg);
00049   static MovePatchesMsg* unpack(void *ptr);
00050 };
00051 
00052 class MoveAtomMsg : public CMessage_MoveAtomMsg {
00053 public:
00054   int atomid;
00055   int moveto;
00056   Vector coord;
00057 };
00058 
00059 class MoveAllByMsg : public CMessage_MoveAllByMsg {
00060 public:
00061   Vector offset;
00062 };
00063 
00064 class SetLatticeMsg : public CMessage_SetLatticeMsg {
00065 public:
00066   Lattice lattice;
00067 };
00068 
00069 // PatchMgr creates and manages homepatches. There exist one instance of 
00070 // PatchMgr on each node (derived from Charm++ Group).  // That is, when a new operator causes creation of one instance on each node. 
00071 // In addition to creation of homepatches, it handles the atom redistribution
00072 // at the end of each cycle (i.e., atoms can move from patch to patch at the
00073 // cycle boundaries).
00074 struct MovePatch 
00075 {
00076     MovePatch(PatchID p=-1, NodeID n=-1) : nodeID(n), pid(p) {};
00077     ~MovePatch() {};
00078 
00079     NodeID nodeID;
00080     PatchID pid;
00081 
00082     int operator<(MovePatch m) {
00083       return ( nodeID < m.nodeID );
00084     }
00085 
00086     int operator==(MovePatch m) {
00087       return ( nodeID == m.nodeID );
00088     }
00089 };
00090 
00091 typedef SortedArray<MovePatch> MovePatchList;
00092 typedef ResizeArrayIter<MovePatch> MovePatchListIter;
00093 
00094 class PatchMgr : public BOCclass
00095 {
00096 
00097 public:
00098   PatchMgr();
00099   ~PatchMgr();
00100 
00101   static PatchMgr* Object() { return CkpvAccess(PatchMgr_instance); }
00102   
00103   void createHomePatch(PatchID pid, FullAtomList a);
00104 
00105   //atomCnt is the number of atoms patch pid has
00106   void preCreateHomePatch(PatchID pid, int atomCnt);
00107 
00108   void movePatch(PatchID, NodeID);
00109   void sendMovePatches();
00110   void recvMovePatches(MovePatchesMsg *msg);
00111 
00112   void sendAtoms(PatchID pid, FullAtomList &a);
00113   void recvAtoms(MovePatchesMsg *msg);
00114 
00115   // void ackMovePatches(AckMovePatchesMsg *msg);
00116 
00117   HomePatch *homePatch(PatchID pid) {
00118      return homePatches.find(HomePatchElem(pid))->patch;
00119   } 
00120 
00121   // void sendMigrationMsg(PatchID, MigrationInfo);
00122   void sendMigrationMsgs(PatchID, MigrationInfo*, int);
00123   // void recvMigrateAtoms(MigrateAtomsMsg *);
00124   void recvMigrateAtomsCombined(MigrateAtomsCombinedMsg *);
00125 
00126   void moveAtom(MoveAtomMsg *msg);
00127   void moveAllBy(MoveAllByMsg *msg);
00128   void setLattice(SetLatticeMsg *msg);
00129 
00130 
00131 private:
00132   friend class PatchMap;
00133   PatchMap *patchMap;
00134 
00135   int numAllPatches;
00136   int numHomePatches;
00137 
00138   // an array of patch pointers residing on this node
00139   HomePatchList homePatches;
00140 
00141   // an array of patches to move off this node
00142   MovePatchList move;
00143   int ackMovePending;
00144 
00145   // data for combining migration messages
00146   MigrateAtomsCombinedMsg ** combineMigrationMsgs;
00147   ResizeArray<int> combineMigrationDestPes;
00148   int migrationCountdown;
00149 
00150 public:
00151   void fillHomePatchAtomList(int patchId, FullAtomList *al){
00152       HomePatch *thisHomePatch = patchMap->homePatch(patchId);
00153       thisHomePatch->setAtomList(al);
00154   }
00155   void setHomePatchFixedAtomNum(int patchId, int numFixed){
00156       HomePatch *thisHomePatch = patchMap->homePatch(patchId);
00157       thisHomePatch->setNumFixedAtoms(numFixed);
00158   }
00159 
00160   void sendOneHomePatch(int patchId, int nodeId);
00161 };
00162 
00163 
00164 
00165 #endif /* PATCHMGR_H */
00166 

Generated on Fri May 25 04:07:16 2012 for NAMD by  doxygen 1.3.9.1