NAMD
MigrateAtomsMsg.C
Go to the documentation of this file.
1 
7 /*
8  Methods are primarily for pack(ing) and unpack(ing) messages for Charm.
9 */
10 
11 #include "InfoStream.h"
12 #include "Migration.h"
13 #include "MigrateAtomsMsg.h"
14 #include "NamdTypes.h"
15 // #define DEBUGM
16 #define MIN_DEBUG_LEVEL 3
17 #include "Debug.h"
18 
19 #include "PatchMgr.decl.h"
20 #include "PatchMap.h"
21 #include "HomePatch.h"
22 #include "packmsg.h"
23 
24 
26  PACK(fromNodeID);
27  PACK(srcPatchID);
28  PACK(destPatchID);
29  PACK_RESIZE(migrationList);
30 )
31 
32 
34 {
35  fromNodeID = CkMyPe();
36  totalAtoms = 0;
37 }
38 
40  add(PatchID source, PatchID destination, MigrationList &m)
41 {
42  srcPatchID.add(source);
43  destPatchID.add(destination);
44  int n = m.size();
45  numAtoms.add(n);
46  totalAtoms += n;
47  for ( int i = 0; i < n; ++i )
48  {
49  migrationList.add(m[i]);
50  }
51 }
52 
53 
55 {
56  int n = srcPatchID.size();
57  int m = 0;
58  for ( int i = 0; i < n; ++i )
59  {
61  msg->fromNodeID = fromNodeID;
62  msg->srcPatchID = srcPatchID[i];
63  msg->destPatchID = destPatchID[i];
64  int l = numAtoms[i];
65  {
66  DebugM(3,"Distributing " << l << " atoms to patch " << msg->destPatchID << "\n");
67  msg->migrationList.resize(l);
68  for ( int j = 0; j < l; ++j ) msg->migrationList[j] = migrationList[m+j];
69  m += l;
70  }
72  }
73  if ( m != totalAtoms ) NAMD_bug("MigrateAtomsCombinedMsg::distribute bad atom count");
74 }
75 
76 
78  PACK(fromNodeID);
79  PACK(totalAtoms);
80  PACK_RESIZE(srcPatchID);
81  PACK_RESIZE(destPatchID);
82  PACK_RESIZE(numAtoms);
83  PACK_RESIZE(migrationList);
84 )
85 
void depositMigration(MigrateAtomsMsg *)
Definition: HomePatch.C:3996
ResizeArray< int > numAtoms
ResizeArray< PatchID > destPatchID
static PatchMap * Object()
Definition: PatchMap.h:27
MigrationList migrationList
void add(PatchID source, PatchID destination, MigrationList &m)
#define DebugM(x, y)
Definition: Debug.h:59
#define PACK_MSG(MSGTYPE, MSGDATA)
Definition: packmsg.h:35
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:240
void NAMD_bug(const char *err_msg)
Definition: common.C:123
ResizeArray< PatchID > srcPatchID
int PatchID
Definition: NamdTypes.h:182
int add(const Elem &elem)
Definition: ResizeArray.h:97
#define PACK_RESIZE(DATA)
Definition: packmsg.h:125
void resize(int i)
Definition: ResizeArray.h:84
#define PACK(DATA)
Definition: packmsg.h:123
MigrationList migrationList
int size(void) const
Definition: ResizeArray.h:127