NAMD
Public Member Functions | Static Public Member Functions | Friends | List of all members
PatchMgr Class Reference

#include <PatchMgr.h>

Inheritance diagram for PatchMgr:

Public Member Functions

 PatchMgr ()
 
 ~PatchMgr ()
 
void createHomePatch (PatchID pid, FullAtomList &a)
 
void movePatch (PatchID, NodeID)
 
void sendMovePatches ()
 
void recvMovePatches (MovePatchesMsg *msg)
 
void sendAtoms (PatchID pid, FullAtomList &a)
 
void recvAtoms (MovePatchesMsg *msg)
 
HomePatchhomePatch (PatchID pid)
 
void sendMigrationMsgs (PatchID, MigrationInfo *, int)
 
void recvMigrateAtomsCombined (MigrateAtomsCombinedMsg *)
 
void moveAtom (MoveAtomMsg *msg)
 
void moveAllBy (MoveAllByMsg *msg)
 
void setLattice (SetLatticeMsg *msg)
 
void sendCheckpointReq (int pid, int remote, const char *key, int task)
 
void recvCheckpointReq (CheckpointAtomsReqMsg *msg)
 
void sendCheckpointLoad (CheckpointAtomsMsg *msg, int dst, int dstpe)
 
void recvCheckpointLoad (CheckpointAtomsMsg *msg)
 
void sendCheckpointStore (CheckpointAtomsMsg *msg, int dst, int dstpe)
 
void recvCheckpointStore (CheckpointAtomsMsg *msg)
 
void sendCheckpointAck (int pid, int dst, int dstpe)
 
void recvCheckpointAck (CheckpointAtomsReqMsg *msg)
 
void sendExchangeReq (int pid, int src)
 
void recvExchangeReq (ExchangeAtomsReqMsg *msg)
 
void sendExchangeMsg (ExchangeAtomsMsg *msg, int dst, int dstpe)
 
void recvExchangeMsg (ExchangeAtomsMsg *msg)
 
void setHomePatchFixedAtomNum (int patchId, int numFixed)
 
void sendOneHomePatch (int patchId, int nodeId)
 

Static Public Member Functions

static PatchMgrObject ()
 

Friends

class PatchMap
 

Detailed Description

Definition at line 145 of file PatchMgr.h.

Constructor & Destructor Documentation

◆ PatchMgr()

PatchMgr::PatchMgr ( )

Definition at line 34 of file PatchMgr.C.

References PatchMap::Instance(), NAMD_bug(), recvCheckpointAck_handler(), recvCheckpointLoad_handler(), recvCheckpointReq_handler(), recvCheckpointStore_handler(), recvExchangeMsg_handler(), recvExchangeReq_handler(), and PatchMap::registerPatchMgr().

35 {
36  // CkPrintf("[%d] PatchMgr Created\n", CkMyPe());
37 
38  // Singleton pattern
39  if (CkpvAccess(PatchMgr_instance) == NULL) {
40  CkpvAccess(PatchMgr_instance) = this;
41  } else {
42  NAMD_bug("PatchMgr instanced twice on same processor!");
43  }
44 
45  // Get PatchMap singleton started
46  patchMap = PatchMap::Instance();
47  patchMap->registerPatchMgr(this);
48 
49  recvCheckpointReq_index = CmiRegisterHandler((CmiHandler)recvCheckpointReq_handler);
50  recvCheckpointLoad_index = CmiRegisterHandler((CmiHandler)recvCheckpointLoad_handler);
51  recvCheckpointStore_index = CmiRegisterHandler((CmiHandler)recvCheckpointStore_handler);
52  recvCheckpointAck_index = CmiRegisterHandler((CmiHandler)recvCheckpointAck_handler);
53 
54  recvExchangeReq_index = CmiRegisterHandler((CmiHandler)recvExchangeReq_handler);
55  recvExchangeMsg_index = CmiRegisterHandler((CmiHandler)recvExchangeMsg_handler);
56 
57  // Message combining initialization
58  migrationCountdown = 0;
59  combineMigrationMsgs = new MigrateAtomsCombinedMsg*[CkNumPes()];
60  int numPes = CkNumPes();
61  for ( int i = 0; i < numPes; ++i ) combineMigrationMsgs[i] = 0;
62 }
void recvCheckpointReq_handler(envelope *env)
Definition: PatchMgr.C:290
void recvExchangeReq_handler(envelope *env)
Definition: PatchMgr.C:402
void NAMD_bug(const char *err_msg)
Definition: common.C:195
void recvCheckpointLoad_handler(envelope *env)
Definition: PatchMgr.C:322
void recvCheckpointAck_handler(envelope *env)
Definition: PatchMgr.C:374
void recvCheckpointStore_handler(envelope *env)
Definition: PatchMgr.C:347
static void registerPatchMgr(PatchMgr *pmgr)
Definition: PatchMap.h:49
static PatchMap * Instance()
Definition: PatchMap.C:32
void recvExchangeMsg_handler(envelope *env)
Definition: PatchMgr.C:430

◆ ~PatchMgr()

PatchMgr::~PatchMgr ( )

Definition at line 64 of file PatchMgr.C.

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

65 {
66  HomePatchListIter hi(homePatches);
67  for ( hi = hi.begin(); hi != hi.end(); hi++) {
68  HomePatchElem* elem = homePatches.find(HomePatchElem(hi->pid));
69  delete elem->patch;
70  }
71  delete [] combineMigrationMsgs;
72 }
HomePatch * patch
Definition: HomePatchList.h:23
Elem * find(const Elem &elem)
Definition: SortedArray.h:94

Member Function Documentation

◆ createHomePatch()

void PatchMgr::createHomePatch ( PatchID  pid,
FullAtomList a 
)

Definition at line 74 of file PatchMgr.C.

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

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

75 {
76  HomePatch *patch = new HomePatch(pid, a);
77  homePatches.load(HomePatchElem(pid, patch));
78  patchMap->registerPatch(pid, patch);
79 }
int load(const Elem &elem)
Definition: SortedArray.h:50
void registerPatch(PatchID pid, HomePatch *pptr)
Definition: PatchMap.C:786

◆ homePatch()

HomePatch* PatchMgr::homePatch ( PatchID  pid)
inline

Definition at line 165 of file PatchMgr.h.

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

Referenced by sendMovePatches(), and sendOneHomePatch().

165  {
166  return homePatches.find(HomePatchElem(pid))->patch;
167  }
HomePatch * patch
Definition: HomePatchList.h:23
Elem * find(const Elem &elem)
Definition: SortedArray.h:94

◆ moveAllBy()

void PatchMgr::moveAllBy ( MoveAllByMsg msg)

Definition at line 246 of file PatchMgr.C.

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

246  {
247  // loop over homePatches, moving every atom
248  for (HomePatchElem *elem = homePatches.begin(); elem != homePatches.end(); elem++) {
249  HomePatch *hp = elem->patch;
250  for (int i=0; i<hp->getNumAtoms(); i++) {
251  FullAtom &a = hp->atom[i];
253  a.fixedPosition += msg->offset;
255  }
256  }
257  delete msg;
258 }
int getNumAtoms() const
Definition: Patch.h:105
NAMD_HOST_DEVICE Position reverse_transform(Position data, const Transform &t) const
Definition: Lattice.h:143
Position fixedPosition
Definition: NamdTypes.h:202
Lattice & lattice
Definition: Patch.h:127
Position position
Definition: NamdTypes.h:77
Vector offset
Definition: PatchMgr.h:62
NAMD_HOST_DEVICE Position apply_transform(Position data, const Transform &t) const
Definition: Lattice.h:137
iterator begin(void)
Definition: ResizeArray.h:36
iterator end(void)
Definition: ResizeArray.h:37
Transform transform
Definition: NamdTypes.h:219

◆ moveAtom()

void PatchMgr::moveAtom ( MoveAtomMsg msg)

Definition at line 228 of file PatchMgr.C.

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

228  {
229  LocalID lid = AtomMap::Object()->localID(msg->atomid);
230  if ( lid.pid != notUsed ) {
231  HomePatch *hp = patchMap->homePatch(lid.pid);
232  if ( hp ) {
233  FullAtom &a = hp->atom[lid.index];
234  if ( msg->moveto ) {
235  a.fixedPosition = msg->coord;
236  } else {
238  a.fixedPosition += msg->coord;
239  }
241  }
242  }
243  delete msg;
244 }
NAMD_HOST_DEVICE Position reverse_transform(Position data, const Transform &t) const
Definition: Lattice.h:143
Position fixedPosition
Definition: NamdTypes.h:202
Lattice & lattice
Definition: Patch.h:127
int atomid
Definition: PatchMgr.h:55
Position position
Definition: NamdTypes.h:77
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
int32 index
Definition: NamdTypes.h:290
NAMD_HOST_DEVICE Position apply_transform(Position data, const Transform &t) const
Definition: Lattice.h:137
LocalID localID(AtomID id)
Definition: AtomMap.h:78
int moveto
Definition: PatchMgr.h:56
PatchID pid
Definition: NamdTypes.h:289
static AtomMap * Object()
Definition: AtomMap.h:37
Vector coord
Definition: PatchMgr.h:57
Transform transform
Definition: NamdTypes.h:219

◆ movePatch()

void PatchMgr::movePatch ( PatchID  pid,
NodeID  nodeID 
)

Definition at line 84 of file PatchMgr.C.

References SortedArray< Elem >::load().

Referenced by WorkDistrib::distributeHomePatches().

85 {
86  move.load(MovePatch(pid,nodeID));
87 }
int load(const Elem &elem)
Definition: SortedArray.h:50

◆ Object()

static PatchMgr* PatchMgr::Object ( )
inlinestatic

◆ recvAtoms()

void PatchMgr::recvAtoms ( MovePatchesMsg msg)

Definition at line 168 of file PatchMgr.C.

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

168  {
169  patchMap->homePatch(msg->pid)->reinitAtoms(msg->atom);
170  delete msg;
171 }
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
FullAtomList atom
Definition: PatchMgr.h:38
PatchID pid
Definition: PatchMgr.h:37

◆ recvCheckpointAck()

void PatchMgr::recvCheckpointAck ( CheckpointAtomsReqMsg msg)

Definition at line 380 of file PatchMgr.C.

References PatchMap::homePatch(), NAMD_bug(), CheckpointAtomsReqMsg::pid, and HomePatch::recvCheckpointAck().

Referenced by recvCheckpointAck_handler().

380  {
381  HomePatch *hp = patchMap->homePatch(msg->pid);
382  if ( ! hp ) NAMD_bug("null HomePatch pointer in PatchMgr::recvCheckpointAck");
383  hp->recvCheckpointAck();
384  delete msg;
385 }
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
void recvCheckpointAck()
Definition: HomePatch.C:5359
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ recvCheckpointLoad()

void PatchMgr::recvCheckpointLoad ( CheckpointAtomsMsg msg)

Definition at line 328 of file PatchMgr.C.

References PatchMap::homePatch(), CheckpointAtomsMsg::pid, and HomePatch::recvCheckpointLoad().

Referenced by recvCheckpointLoad_handler().

328  {
329  HomePatch *hp = patchMap->homePatch(msg->pid);
330  hp->recvCheckpointLoad(msg);
331 }
void recvCheckpointLoad(CheckpointAtomsMsg *msg)
Definition: HomePatch.C:5295
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249

◆ recvCheckpointReq()

void PatchMgr::recvCheckpointReq ( CheckpointAtomsReqMsg msg)

Definition at line 296 of file PatchMgr.C.

References PatchMap::homePatch(), CheckpointAtomsReqMsg::key, NAMD_bug(), PatchMap::node(), CheckpointAtomsReqMsg::pe, CheckpointAtomsReqMsg::pid, HomePatch::recvCheckpointReq(), CheckpointAtomsReqMsg::replica, and CheckpointAtomsReqMsg::task.

Referenced by recvCheckpointReq_handler().

296  {
297  int patchnode = patchMap->node(msg->pid);
298  if ( CkMyPe() != patchnode ) {
299  thisProxy[patchnode].recvCheckpointReq(msg);
300  } else {
301  HomePatch *hp = patchMap->homePatch(msg->pid);
302  if ( ! hp ) NAMD_bug("null HomePatch pointer in PatchMgr::recvCheckpointReq");
303  hp->recvCheckpointReq(msg->task, msg->key, msg->replica, msg->pe);
304  delete msg;
305  }
306 }
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
void recvCheckpointReq(int task, const char *key, int replica, int pe)
Definition: HomePatch.C:5265
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int node(int pid) const
Definition: PatchMap.h:114

◆ recvCheckpointStore()

void PatchMgr::recvCheckpointStore ( CheckpointAtomsMsg msg)

Definition at line 353 of file PatchMgr.C.

References PatchMap::homePatch(), CheckpointAtomsMsg::pid, and HomePatch::recvCheckpointStore().

Referenced by recvCheckpointStore_handler().

353  {
354  HomePatch *hp = patchMap->homePatch(msg->pid);
355  hp->recvCheckpointStore(msg);
356 }
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
void recvCheckpointStore(CheckpointAtomsMsg *msg)
Definition: HomePatch.C:5345

◆ recvExchangeMsg()

void PatchMgr::recvExchangeMsg ( ExchangeAtomsMsg msg)

Definition at line 435 of file PatchMgr.C.

References PatchMap::homePatch(), ExchangeAtomsMsg::pid, and HomePatch::recvExchangeMsg().

Referenced by recvExchangeMsg_handler().

435  {
436  HomePatch *hp = patchMap->homePatch(msg->pid);
437  hp->recvExchangeMsg(msg);
438 }
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
void recvExchangeMsg(ExchangeAtomsMsg *msg)
Definition: HomePatch.C:5396

◆ recvExchangeReq()

void PatchMgr::recvExchangeReq ( ExchangeAtomsReqMsg msg)

Definition at line 407 of file PatchMgr.C.

References ExchangeAtomsReqMsg::dstpe, PatchMap::homePatch(), NAMD_bug(), PatchMap::node(), ExchangeAtomsReqMsg::pid, and HomePatch::recvExchangeReq().

Referenced by recvExchangeReq_handler().

407  {
408  int patchnode = patchMap->node(msg->pid);
409  if ( CkMyPe() != patchnode ) {
410  thisProxy[patchnode].recvExchangeReq(msg);
411  } else {
412  HomePatch *hp = patchMap->homePatch(msg->pid);
413  if ( ! hp ) NAMD_bug("null HomePatch pointer in PatchMgr::recvExchangeReq");
414  hp->recvExchangeReq(msg->dstpe);
415  delete msg;
416  }
417 }
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
void NAMD_bug(const char *err_msg)
Definition: common.C:195
void recvExchangeReq(int req)
Definition: HomePatch.C:5385
int node(int pid) const
Definition: PatchMap.h:114

◆ recvMigrateAtomsCombined()

void PatchMgr::recvMigrateAtomsCombined ( MigrateAtomsCombinedMsg msg)

Definition at line 221 of file PatchMgr.C.

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

222 {
223  DebugM(3,"Received MigrateAtomsCombinedMsg with " << msg->srcPatchID.size() << " messages.\n");
224  msg->distribute();
225  delete msg;
226 }
int size(void) const
Definition: ResizeArray.h:131
#define DebugM(x, y)
Definition: Debug.h:75
ResizeArray< PatchID > srcPatchID

◆ recvMovePatches()

void PatchMgr::recvMovePatches ( MovePatchesMsg msg)

Definition at line 137 of file PatchMgr.C.

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

137  {
138  // Make a new HomePatch
139  createHomePatch(msg->pid, msg->atom);
140  delete msg;
141 
142  // Tell sending PatchMgr we received MovePatchMsg
143 // AckMovePatchesMsg *ackmsg =
144 // new AckMovePatchesMsg;
145 // CSendMsgBranch(PatchMgr,ackMovePatches, ackmsg, thisgroup, msg->fromNodeID);
146 }
void createHomePatch(PatchID pid, FullAtomList &a)
Definition: PatchMgr.C:74
FullAtomList atom
Definition: PatchMgr.h:38
PatchID pid
Definition: PatchMgr.h:37

◆ sendAtoms()

void PatchMgr::sendAtoms ( PatchID  pid,
FullAtomList a 
)

Definition at line 157 of file PatchMgr.C.

References MovePatchesMsg::atom, NAMD_bug(), PatchMap::node(), and ResizeArray< Elem >::shared().

Referenced by WorkDistrib::reinitAtoms().

157  {
158 
159  MovePatchesMsg *msg = new MovePatchesMsg(pid, a);
160 
161  if ( msg->atom.shared() ) NAMD_bug("shared message array in PatchMgr::sendAtoms");
162 
163  CProxy_PatchMgr cp(thisgroup);
164  cp[patchMap->node(pid)].recvAtoms(msg);
165 
166 }
FullAtomList atom
Definition: PatchMgr.h:38
void NAMD_bug(const char *err_msg)
Definition: common.C:195
bool shared() const
Definition: ResizeArray.h:72
int node(int pid) const
Definition: PatchMap.h:114

◆ sendCheckpointAck()

void PatchMgr::sendCheckpointAck ( int  pid,
int  dst,
int  dstpe 
)

Definition at line 360 of file PatchMgr.C.

References CheckpointAtomsReqMsg::pid.

Referenced by HomePatch::recvCheckpointReq(), and HomePatch::recvCheckpointStore().

360  {
362  msg->pid = pid;
363  envelope *env = UsrToEnv(CheckpointAtomsReqMsg::pack(msg));
364  CmiSetHandler(env,recvCheckpointAck_index);
365 #if CMK_HAS_PARTITION
366  CmiInterSyncSendAndFree(dstpe,dst,env->getTotalsize(),(char*)env);
367 #else
368  CmiSyncSendAndFree(dstpe,env->getTotalsize(),(char*)env);
369 #endif
370 }

◆ sendCheckpointLoad()

void PatchMgr::sendCheckpointLoad ( CheckpointAtomsMsg msg,
int  dst,
int  dstpe 
)

Definition at line 310 of file PatchMgr.C.

Referenced by HomePatch::recvCheckpointReq().

310  {
311  envelope *env = UsrToEnv(CheckpointAtomsMsg::pack(msg));
312  CmiSetHandler(env,recvCheckpointLoad_index);
313 #if CMK_HAS_PARTITION
314  CmiInterSyncSendAndFree(dstpe,dst,env->getTotalsize(),(char*)env);
315 #else
316  CmiSyncSendAndFree(dstpe,env->getTotalsize(),(char*)env);
317 #endif
318 }

◆ sendCheckpointReq()

void PatchMgr::sendCheckpointReq ( int  pid,
int  remote,
const char *  key,
int  task 
)

Definition at line 272 of file PatchMgr.C.

References CheckpointAtomsReqMsg::key, CheckpointAtomsReqMsg::pe, CheckpointAtomsReqMsg::pid, CheckpointAtomsReqMsg::replica, and CheckpointAtomsReqMsg::task.

Referenced by HomePatch::exchangeCheckpoint().

272  {
273  CheckpointAtomsReqMsg *msg = new (1+strlen(key),0) CheckpointAtomsReqMsg;
274  msg->pid = pid;
275  msg->pe = CkMyPe();
276  msg->replica = CmiMyPartition();
277  msg->task = task;
278  strcpy(msg->key,key);
279  envelope *env = UsrToEnv(CheckpointAtomsReqMsg::pack(msg));
280  CmiSetHandler(env,recvCheckpointReq_index);
281 #if CMK_HAS_PARTITION
282  CmiInterSyncSendAndFree(CkMyPe(),remote,env->getTotalsize(),(char*)env);
283 #else
284  CmiSyncSendAndFree(CkMyPe(),env->getTotalsize(),(char*)env);
285 #endif
286 }

◆ sendCheckpointStore()

void PatchMgr::sendCheckpointStore ( CheckpointAtomsMsg msg,
int  dst,
int  dstpe 
)

Definition at line 335 of file PatchMgr.C.

Referenced by HomePatch::recvCheckpointLoad().

335  {
336  envelope *env = UsrToEnv(CheckpointAtomsMsg::pack(msg));
337  CmiSetHandler(env,recvCheckpointStore_index);
338 #if CMK_HAS_PARTITION
339  CmiInterSyncSendAndFree(dstpe,dst,env->getTotalsize(),(char*)env);
340 #else
341  CmiSyncSendAndFree(dstpe,env->getTotalsize(),(char*)env);
342 #endif
343 }

◆ sendExchangeMsg()

void PatchMgr::sendExchangeMsg ( ExchangeAtomsMsg msg,
int  dst,
int  dstpe 
)

Definition at line 419 of file PatchMgr.C.

Referenced by HomePatch::recvExchangeReq().

419  {
420  envelope *env = UsrToEnv(ExchangeAtomsMsg::pack(msg));
421  CmiSetHandler(env,recvExchangeMsg_index);
422 #if CMK_HAS_PARTITION
423  CmiInterSyncSendAndFree(dstpe,dst,env->getTotalsize(),(char*)env);
424 #else
425  CmiSyncSendAndFree(dstpe,env->getTotalsize(),(char*)env);
426 #endif
427 }

◆ sendExchangeReq()

void PatchMgr::sendExchangeReq ( int  pid,
int  src 
)

Definition at line 388 of file PatchMgr.C.

References ExchangeAtomsReqMsg::dstpe, and ExchangeAtomsReqMsg::pid.

Referenced by HomePatch::exchangeAtoms().

388  {
390  msg->pid = pid;
391  msg->dstpe = CkMyPe();
392  envelope *env = UsrToEnv(ExchangeAtomsReqMsg::pack(msg));
393  CmiSetHandler(env,recvExchangeReq_index);
394 #if CMK_HAS_PARTITION
395  CmiInterSyncSendAndFree(CkMyPe(),src,env->getTotalsize(),(char*)env);
396 #else
397  CmiSyncSendAndFree(CkMyPe(),env->getTotalsize(),(char*)env);
398 #endif
399 }

◆ sendMigrationMsgs()

void PatchMgr::sendMigrationMsgs ( PatchID  src,
MigrationInfo m,
int  numMsgs 
)

Definition at line 175 of file PatchMgr.C.

References MigrateAtomsCombinedMsg::add(), ResizeArray< Elem >::add(), DebugM, MigrationInfo::destNodeID, PatchMap::numHomePatches(), ResizeArray< Elem >::resize(), and ResizeArray< Elem >::size().

Referenced by HomePatch::doAtomMigration().

175  {
176 /*
177  for (int i=0; i < numMsgs; i++) {
178  PatchMgr::Object()->sendMigrationMsg(src, m[i]);
179  }
180 */
181  // The migration countdown is getting crapped up for some reason.
182  // The migrationCountdown should be zero everytime I need to do a migration step here
183  if ( ! migrationCountdown ) // (re)initialize
184  {
185  // DebugM(3,"migrationCountdown (re)initialize\n");
186  numHomePatches = patchMap->numHomePatches();
187  migrationCountdown = numHomePatches;
188  combineMigrationDestPes.resize(0);
189  }
190  for (int i=0; i < numMsgs; i++) { // buffer messages
191  int destNodeID = m[i].destNodeID;
192  if ( 1 ) // destNodeID != CkMyPe() )
193  {
194  if ( ! combineMigrationMsgs[destNodeID] )
195  {
196  combineMigrationMsgs[destNodeID] = new MigrateAtomsCombinedMsg();
197  combineMigrationDestPes.add(destNodeID);
198  }
199  combineMigrationMsgs[destNodeID]->add(src,m[i].destPatchID,m[i].mList);
200  }
201  else
202  {
203  // for now buffer local messages too
204  }
205  }
206  migrationCountdown -= 1;
207  // DebugM(3,"migrationCountdown = " << migrationCountdown << "\n");
208  if ( ! migrationCountdown ) // send out combined messages
209  {
210  int n = combineMigrationDestPes.size();
211  for ( int i = 0; i < n; ++i ) {
212  int destNodeID = combineMigrationDestPes[i];
213  DebugM(3,"Sending MigrateAtomsCombinedMsg to node " << destNodeID << "\n");
214  CProxy_PatchMgr cp(thisgroup);
215  cp[destNodeID].recvMigrateAtomsCombined(combineMigrationMsgs[destNodeID]);
216  combineMigrationMsgs[destNodeID] = 0;
217  }
218  }
219 }
int size(void) const
Definition: ResizeArray.h:131
void add(PatchID source, PatchID destination, MigrationList &m)
#define DebugM(x, y)
Definition: Debug.h:75
int add(const Elem &elem)
Definition: ResizeArray.h:101
void resize(int i)
Definition: ResizeArray.h:84
NodeID destNodeID
Definition: Migration.h:21
int numHomePatches(void)
Definition: PatchMap.C:432

◆ sendMovePatches()

void PatchMgr::sendMovePatches ( )

Definition at line 110 of file PatchMgr.C.

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

Referenced by WorkDistrib::distributeHomePatches().

111 {
112  if (! move.size())
113  return;
114 
115  MovePatchListIter m(move);
116  for ( m = m.begin(); m != m.end(); m++) {
117  HomePatch *p = homePatch(m->pid);
118  patchMap->unregisterPatch(m->pid, p);
119 
120  MovePatchesMsg *msg = new MovePatchesMsg(m->pid, p->atom);
121 
122  // Deleting the HomePatchElem will call a destructor for clean up
123  // but the msg elements are safe since they use a container template
124  // that uses ref counting.
125  delete p;
126  homePatches.del(HomePatchElem(m->pid));
127 
128  if ( msg->atom.shared() ) NAMD_bug("shared message array in PatchMgr::sendMovePatches");
129 
130  // Sending to PatchMgr::recvMovePatches on remote node
131  CProxy_PatchMgr cp(thisgroup);
132  cp[m->nodeID].recvMovePatches(msg);
133  }
134  move.resize(0);
135 }
int size(void) const
Definition: ResizeArray.h:131
FullAtomList atom
Definition: PatchMgr.h:38
void resize(int i)
Definition: ResizeArray.h:84
void unregisterPatch(PatchID pid, HomePatch *pptr)
Definition: PatchMap.C:796
void NAMD_bug(const char *err_msg)
Definition: common.C:195
void del(const Elem &elem)
Definition: SortedArray.h:59
HomePatch * homePatch(PatchID pid)
Definition: PatchMgr.h:165
bool shared() const
Definition: ResizeArray.h:72

◆ sendOneHomePatch()

void PatchMgr::sendOneHomePatch ( int  patchId,
int  nodeId 
)

Definition at line 89 of file PatchMgr.C.

References MovePatchesMsg::atom, SortedArray< Elem >::del(), homePatch(), NAMD_bug(), ResizeArray< Elem >::shared(), and PatchMap::unregisterPatch().

89  {
90  HomePatch *p = homePatch(patchId);
91  patchMap->unregisterPatch(patchId, p);
92 
93  MovePatchesMsg *msg = new MovePatchesMsg(patchId, p->atom);
94 
95  // Deleting the HomePatchElem will call a destructor for clean up
96  // but the msg elements are safe since they use a container template
97  // that uses ref counting.
98  delete p;
99  homePatches.del(HomePatchElem(patchId));
100 
101  if ( msg->atom.shared() ) NAMD_bug("shared message array in PatchMgr::sendOneHomePatch");
102 
103  // Sending to PatchMgr::recvMovePatches on remote node
104  CProxy_PatchMgr cp(thisgroup);
105  cp[nodeId].recvMovePatches(msg);
106 }
FullAtomList atom
Definition: PatchMgr.h:38
void unregisterPatch(PatchID pid, HomePatch *pptr)
Definition: PatchMap.C:796
void NAMD_bug(const char *err_msg)
Definition: common.C:195
void del(const Elem &elem)
Definition: SortedArray.h:59
HomePatch * homePatch(PatchID pid)
Definition: PatchMgr.h:165
bool shared() const
Definition: ResizeArray.h:72

◆ setHomePatchFixedAtomNum()

void PatchMgr::setHomePatchFixedAtomNum ( int  patchId,
int  numFixed 
)

Definition at line 440 of file PatchMgr.C.

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

440  {
441  HomePatch *thisHomePatch = patchMap->homePatch(patchId);
442  thisHomePatch->setNumFixedAtoms(numFixed);
443 }
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
void setNumFixedAtoms(int numFixed)
Definition: Patch.h:113

◆ setLattice()

void PatchMgr::setLattice ( SetLatticeMsg msg)

Definition at line 260 of file PatchMgr.C.

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

260  {
261  // loop over homePatches, setting the lattice to the new value.
262  for (HomePatchElem *elem = homePatches.begin(); elem != homePatches.end(); elem++) {
263  HomePatch *hp = elem->patch;
264  hp->lattice = msg->lattice;
265  }
266  // Must also do this for SimParameters in order for pressure profile to work!
268 }
static Node * Object()
Definition: Node.h:86
Lattice & lattice
Definition: Patch.h:127
SimParameters * simParameters
Definition: Node.h:181
iterator begin(void)
Definition: ResizeArray.h:36
iterator end(void)
Definition: ResizeArray.h:37
Lattice lattice
Definition: PatchMgr.h:67

Friends And Related Function Documentation

◆ PatchMap

friend class PatchMap
friend

Definition at line 193 of file PatchMgr.h.


The documentation for this class was generated from the following files: