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

PatchMgr Class Reference

#include <PatchMgr.h>

Inheritance diagram for PatchMgr:

BOCclass List of all members.

Public Member Functions

 PatchMgr ()
 ~PatchMgr ()
void createHomePatch (PatchID pid, FullAtomList a)
void preCreateHomePatch (PatchID pid, int atomCnt)
void movePatch (PatchID, NodeID)
void sendMovePatches ()
void recvMovePatches (MovePatchesMsg *msg)
void sendAtoms (PatchID pid, FullAtomList a)
void recvAtoms (MovePatchesMsg *msg)
HomePatchhomePatch (PatchID pid)
void sendMigrationMsg (PatchID, MigrationInfo)
void sendMigrationMsgs (PatchID, MigrationInfo *, int)
void recvMigrateAtoms (MigrateAtomsMsg *)
void recvMigrateAtomsCombined (MigrateAtomsCombinedMsg *)
void moveAtom (MoveAtomMsg *msg)
void moveAllBy (MoveAllByMsg *msg)
void setLattice (SetLatticeMsg *msg)
void fillHomePatchAtomList (int patchId, FullAtomList *al)
void setHomePatchFixedAtomNum (int patchId, int numFixed)
void sendOneHomePatch (int patchId, int nodeId)

Static Public Member Functions

PatchMgrObject ()

Friends

class PatchMap

Constructor & Destructor Documentation

PatchMgr::PatchMgr  ) 
 

Definition at line 37 of file PatchMgr.C.

References iERROR(), iFILE, PatchMap::Instance(), iout, iPE(), and PatchMap::registerPatchMgr().

00038 {
00039     // CkPrintf("[%d] PatchMgr Created\n", CkMyPe());
00040 
00041     // Singleton pattern
00042     if (CkpvAccess(PatchMgr_instance) == NULL) {
00043         CkpvAccess(PatchMgr_instance) = this;
00044     } else {
00045         iout << iFILE << iERROR << iPE 
00046           << "PatchMgr instanced twice on same processor!" << endi;
00047         CkExit();
00048     }
00049 
00050     // Get PatchMap singleton started
00051     patchMap = PatchMap::Instance();
00052     patchMap->registerPatchMgr(this);
00053 
00054     // Message combining initialization
00055     migrationCountdown = 0;
00056     combineMigrationMsgs = new MigrateAtomsCombinedMsg*[CkNumPes()];
00057 }

PatchMgr::~PatchMgr  ) 
 

Definition at line 59 of file PatchMgr.C.

References ResizeArrayIter< T >::begin(), ResizeArrayIter< T >::end(), SortedArray< Elem >::find(), HomePatchListIter, and HomePatchElem::patch.

00060 {
00061     HomePatchListIter hi(homePatches);
00062     for ( hi = hi.begin(); hi != hi.end(); hi++) {
00063       HomePatchElem* elem = homePatches.find(HomePatchElem(hi->pid));
00064       delete elem->patch;
00065     }
00066     delete [] combineMigrationMsgs;
00067 }


Member Function Documentation

void PatchMgr::createHomePatch PatchID  pid,
FullAtomList  a
 

Definition at line 75 of file PatchMgr.C.

References FullAtomList, SortedArray< Elem >::load(), and PatchMap::registerPatch().

Referenced by WorkDistrib::createHomePatches(), and recvMovePatches().

00076 {
00077     HomePatch *patch = new HomePatch(pid, a);
00078     homePatches.load(HomePatchElem(pid, patch));
00079     patchMap->registerPatch(pid, patch);
00080 }

void PatchMgr::fillHomePatchAtomList int  patchId,
FullAtomList al
[inline]
 

Definition at line 150 of file PatchMgr.h.

References FullAtomList, PatchMap::homePatch(), and HomePatch::setAtomList().

Referenced by WorkDistrib::initAndSendHomePatch().

00150                                                            {
00151       HomePatch *thisHomePatch = patchMap->homePatch(patchId);
00152       thisHomePatch->setAtomList(al);
00153   }

HomePatch* PatchMgr::homePatch PatchID  pid  )  [inline]
 

Definition at line 117 of file PatchMgr.h.

References SortedArray< Elem >::find(), and HomePatchElem::patch.

Referenced by sendMovePatches(), and sendOneHomePatch().

00117                                     {
00118      return homePatches.find(HomePatchElem(pid))->patch;
00119   } 

void PatchMgr::moveAllBy MoveAllByMsg msg  ) 
 

Definition at line 254 of file PatchMgr.C.

References Lattice::apply_transform(), HomePatch::atom, ResizeArray< Elem >::begin(), ResizeArray< Elem >::end(), FullAtom::fixedPosition, Patch::getNumAtoms(), Patch::lattice, MoveAllByMsg::offset, HomePatchElem::patch, CompAtom::position, Lattice::reverse_transform(), and FullAtom::transform.

00254                                           {
00255   // loop over homePatches, moving every atom
00256   for (HomePatchElem *elem = homePatches.begin(); elem != homePatches.end(); elem++) {
00257     HomePatch *hp = elem->patch;
00258     for (int i=0; i<hp->getNumAtoms(); i++) {
00259       FullAtom &a = hp->atom[i];
00260       a.fixedPosition = hp->lattice.reverse_transform(a.position,a.transform);
00261       a.fixedPosition += msg->offset;
00262       a.position = hp->lattice.apply_transform(a.fixedPosition,a.transform);
00263     }
00264   }
00265   delete msg;
00266 }

void PatchMgr::moveAtom MoveAtomMsg msg  ) 
 

Definition at line 236 of file PatchMgr.C.

References Lattice::apply_transform(), HomePatch::atom, MoveAtomMsg::atomid, MoveAtomMsg::coord, FullAtom::fixedPosition, PatchMap::homePatch(), LocalID::index, Patch::lattice, AtomMap::localID(), MoveAtomMsg::moveto, AtomMap::Object(), LocalID::pid, CompAtom::position, Lattice::reverse_transform(), and FullAtom::transform.

00236                                         {
00237   LocalID lid = AtomMap::Object()->localID(msg->atomid);
00238   if ( lid.pid != notUsed ) {
00239     HomePatch *hp = patchMap->homePatch(lid.pid);
00240     if ( hp ) {
00241       FullAtom &a = hp->atom[lid.index];
00242       if ( msg->moveto ) {
00243         a.fixedPosition = msg->coord;
00244       } else {
00245         a.fixedPosition = hp->lattice.reverse_transform(a.position,a.transform);
00246         a.fixedPosition += msg->coord;
00247       }
00248       a.position = hp->lattice.apply_transform(a.fixedPosition,a.transform);
00249     }
00250   }
00251   delete msg;
00252 }

void PatchMgr::movePatch PatchID  ,
NodeID 
 

Definition at line 85 of file PatchMgr.C.

References SortedArray< Elem >::load().

Referenced by WorkDistrib::distributeHomePatches().

00086 {
00087     move.load(MovePatch(pid,nodeID));
00088 }

PatchMgr* PatchMgr::Object  )  [inline, static]
 

Definition at line 101 of file PatchMgr.h.

Referenced by HomePatch::doAtomMigration().

00101 { return CkpvAccess(PatchMgr_instance); }

void PatchMgr::preCreateHomePatch PatchID  pid,
int  atomCnt
 

Definition at line 69 of file PatchMgr.C.

References SortedArray< Elem >::load(), and PatchMap::registerPatch().

Referenced by WorkDistrib::preCreateHomePatches().

00069                                                          {
00070     HomePatch *patch = new HomePatch(pid, atomCnt);
00071     homePatches.load(HomePatchElem(pid, patch));
00072     patchMap->registerPatch(pid, patch);
00073 }

void PatchMgr::recvAtoms MovePatchesMsg msg  ) 
 

Definition at line 163 of file PatchMgr.C.

References MovePatchesMsg::atom, PatchMap::homePatch(), MovePatchesMsg::pid, and HomePatch::reinitAtoms().

00163                                             {
00164     patchMap->homePatch(msg->pid)->reinitAtoms(msg->atom);
00165     delete msg;
00166 }

void PatchMgr::recvMigrateAtoms MigrateAtomsMsg  ) 
 

Definition at line 224 of file PatchMgr.C.

References HomePatch::depositMigration(), MigrateAtomsMsg::destPatchID, PatchMap::homePatch(), and PatchMap::Object().

00224                                                      {
00225   //  msg must be deleted by HomePatch::depositMigrationMsg();
00226   PatchMap::Object()->homePatch(msg->destPatchID)->depositMigration(msg);
00227 }

void PatchMgr::recvMigrateAtomsCombined MigrateAtomsCombinedMsg  ) 
 

Definition at line 229 of file PatchMgr.C.

References DebugM, MigrateAtomsCombinedMsg::distribute(), ResizeArray< Elem >::size(), and MigrateAtomsCombinedMsg::srcPatchID.

00230 {
00231   DebugM(3,"Received MigrateAtomsCombinedMsg with " << msg->srcPatchID.size() << " messages.\n");
00232   msg->distribute();
00233   delete msg;
00234 }

void PatchMgr::recvMovePatches MovePatchesMsg msg  ) 
 

Definition at line 134 of file PatchMgr.C.

References MovePatchesMsg::atom, createHomePatch(), and MovePatchesMsg::pid.

00134                                                   {
00135     // Make a new HomePatch
00136     createHomePatch(msg->pid, msg->atom);
00137     delete msg;
00138 
00139     // Tell sending PatchMgr we received MovePatchMsg
00140 //    AckMovePatchesMsg *ackmsg = 
00141 //      new AckMovePatchesMsg;
00142 //    CSendMsgBranch(PatchMgr,ackMovePatches, ackmsg, thisgroup, msg->fromNodeID);
00143 }

void PatchMgr::sendAtoms PatchID  pid,
FullAtomList  a
 

Definition at line 154 of file PatchMgr.C.

References FullAtomList, and PatchMap::node().

Referenced by WorkDistrib::reinitAtoms().

00154                                                     {
00155 
00156       MovePatchesMsg *msg = new MovePatchesMsg(pid, a);
00157 
00158       CProxy_PatchMgr cp(thisgroup);
00159       cp[patchMap->node(pid)].recvAtoms(msg);
00160 
00161 }

void PatchMgr::sendMigrationMsg PatchID  ,
MigrationInfo 
 

Definition at line 171 of file PatchMgr.C.

References MigrationInfo::destNodeID, MigrationInfo::destPatchID, and MigrationInfo::mList.

00171                                                             {
00172   MigrateAtomsMsg *msg = new MigrateAtomsMsg(src,m.destPatchID,m.mList);
00173   CProxy_PatchMgr cp(thisgroup);
00174   cp[m.destNodeID].recvMigrateAtoms(msg);
00175 }

void PatchMgr::sendMigrationMsgs PatchID  ,
MigrationInfo ,
int 
 

Definition at line 179 of file PatchMgr.C.

References MigrateAtomsCombinedMsg::add(), DebugM, MigrationInfo::destNodeID, and PatchMap::numHomePatches().

Referenced by HomePatch::doAtomMigration().

00179                                                                            {
00180 /*
00181   for (int i=0; i < numMsgs; i++) {
00182     PatchMgr::Object()->sendMigrationMsg(src, m[i]);
00183   }
00184 */
00185   if ( ! migrationCountdown )  // (re)initialize
00186   {
00187     // DebugM(3,"migrationCountdown (re)initialize\n");
00188     numHomePatches = patchMap->numHomePatches();
00189     migrationCountdown = numHomePatches;
00190     int numPes = CkNumPes();
00191     for ( int i = 0; i < numPes; ++i ) combineMigrationMsgs[i] = 0;
00192   }
00193   for (int i=0; i < numMsgs; i++) {  // buffer messages
00194     int destNodeID = m[i].destNodeID;
00195     if ( 1 ) // destNodeID != CkMyPe() )
00196     {
00197       if ( ! combineMigrationMsgs[destNodeID] )
00198       {
00199         combineMigrationMsgs[destNodeID] = new MigrateAtomsCombinedMsg();
00200       }
00201       combineMigrationMsgs[destNodeID]->add(src,m[i].destPatchID,m[i].mList);
00202     }
00203     else
00204     {
00205         // for now buffer local messages too
00206     }
00207   }
00208   migrationCountdown -= 1;
00209   // DebugM(3,"migrationCountdown = " << migrationCountdown << "\n");
00210   if ( ! migrationCountdown )  // send out combined messages
00211   {
00212     int numPes = CkNumPes();
00213     for ( int destNodeID = 0; destNodeID < numPes; ++destNodeID )
00214       if ( combineMigrationMsgs[destNodeID] )
00215       {
00216         DebugM(3,"Sending MigrateAtomsCombinedMsg to node " << destNodeID << "\n");
00217         CProxy_PatchMgr cp(thisgroup);
00218         cp[destNodeID].recvMigrateAtomsCombined(combineMigrationMsgs[destNodeID]);
00219       }
00220   }
00221 }

void PatchMgr::sendMovePatches  ) 
 

Definition at line 109 of file PatchMgr.C.

References HomePatch::atom, ResizeArrayIter< T >::begin(), SortedArray< Elem >::del(), ResizeArrayIter< T >::end(), homePatch(), MovePatchListIter, ResizeArray< Elem >::resize(), ResizeArray< Elem >::size(), and PatchMap::unregisterPatch().

Referenced by WorkDistrib::distributeHomePatches().

00110 {
00111     if (! move.size())
00112         return;
00113 
00114     MovePatchListIter m(move);
00115     for ( m = m.begin(); m != m.end(); m++) {
00116       HomePatch *p = homePatch(m->pid);
00117       patchMap->unregisterPatch(m->pid, p);
00118 
00119       MovePatchesMsg *msg = new MovePatchesMsg(m->pid, p->atom);
00120 
00121       // Sending to PatchMgr::recvMovePatches on remote node
00122       CProxy_PatchMgr cp(thisgroup);
00123       cp[m->nodeID].recvMovePatches(msg);
00124 
00125       // Deleting the HomePatchElem will call a destructor for clean up
00126       // but the msg elements are safe since they use a container template
00127       // that uses ref counting.
00128       delete p;
00129       homePatches.del(HomePatchElem(m->pid)); 
00130     }
00131     move.resize(0);
00132 }

void PatchMgr::sendOneHomePatch int  patchId,
int  nodeId
 

Definition at line 90 of file PatchMgr.C.

References HomePatch::atom, SortedArray< Elem >::del(), homePatch(), and PatchMap::unregisterPatch().

Referenced by WorkDistrib::initAndSendHomePatch().

00090                                                       {
00091     HomePatch *p = homePatch(patchId);
00092     patchMap->unregisterPatch(patchId, p);
00093 
00094     MovePatchesMsg *msg = new MovePatchesMsg(patchId, p->atom);
00095 
00096     // Sending to PatchMgr::recvMovePatches on remote node
00097     CProxy_PatchMgr cp(thisgroup);
00098     cp[nodeId].recvMovePatches(msg);
00099 
00100     // Deleting the HomePatchElem will call a destructor for clean up
00101     // but the msg elements are safe since they use a container template
00102     // that uses ref counting.
00103     delete p;
00104     homePatches.del(HomePatchElem(patchId)); 
00105 }

void PatchMgr::setHomePatchFixedAtomNum int  patchId,
int  numFixed
[inline]
 

Definition at line 154 of file PatchMgr.h.

References PatchMap::homePatch(), and Patch::setNumFixedAtoms().

Referenced by WorkDistrib::fillOnePatchAtoms().

00154                                                           {
00155       HomePatch *thisHomePatch = patchMap->homePatch(patchId);
00156       thisHomePatch->setNumFixedAtoms(numFixed);
00157   }

void PatchMgr::setLattice SetLatticeMsg msg  ) 
 

Definition at line 268 of file PatchMgr.C.

References ResizeArray< Elem >::begin(), ResizeArray< Elem >::end(), SimParameters::lattice, SetLatticeMsg::lattice, Patch::lattice, Node::Object(), HomePatchElem::patch, and Node::simParameters.

00268                                             {
00269   // loop over homePatches, setting the lattice to the new value.
00270   for (HomePatchElem *elem = homePatches.begin(); elem != homePatches.end(); elem++) {
00271     HomePatch *hp = elem->patch;
00272     hp->lattice = msg->lattice;
00273   }
00274   // Must also do this for SimParameters in order for pressure profile to work!
00275   Node::Object()->simParameters->lattice = msg->lattice;
00276 }


Friends And Related Function Documentation

friend class PatchMap [friend]
 

Definition at line 132 of file PatchMgr.h.


The documentation for this class was generated from the following files:
Generated on Mon Nov 23 05:00:05 2009 for NAMD by  doxygen 1.3.9.1