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

MigrateAtomsMsg.C

Go to the documentation of this file.
00001 
00007 /*
00008    Methods are primarily for pack(ing) and unpack(ing) messages for Charm.
00009 */
00010 
00011 #include "InfoStream.h"
00012 #include "Migration.h"
00013 #include "MigrateAtomsMsg.h"
00014 #include "NamdTypes.h"
00015 // #define DEBUGM
00016 #define MIN_DEBUG_LEVEL 3
00017 #include "Debug.h"
00018 
00019 #include "PatchMgr.decl.h"
00020 #include "PatchMap.h"
00021 #include "HomePatch.h"
00022 #include "packmsg.h"
00023 
00024 
00025 MigrateAtomsMsg::MigrateAtomsMsg(PatchID src, PatchID dest, MigrationList &m) : 
00026       srcPatchID(src), destPatchID(dest), migrationList(m) 
00027 {
00028     fromNodeID = CkMyPe();
00029 }
00030 
00031 
00032 PACK_MSG(MigrateAtomsMsg,
00033   PACK(fromNodeID);
00034   PACK(srcPatchID);
00035   PACK(destPatchID);
00036   PACK_RESIZE(migrationList);
00037 )
00038 
00039 
00040 MigrateAtomsCombinedMsg::MigrateAtomsCombinedMsg(void)
00041 {
00042   fromNodeID = CkMyPe();
00043   totalAtoms = 0;
00044 }
00045 
00046 void MigrateAtomsCombinedMsg::
00047 	add(PatchID source, PatchID destination, MigrationList &m)
00048 {
00049   srcPatchID.add(source);
00050   destPatchID.add(destination);
00051   int n = m.size();
00052   numAtoms.add(n);
00053   totalAtoms += n;
00054   for ( int i = 0; i < n; ++i )
00055   {
00056     migrationList.add(m[i]);
00057   }
00058 }
00059 
00060 
00061 void MigrateAtomsCombinedMsg::distribute(void)
00062 {
00063   int n = srcPatchID.size();
00064   int m = 0;
00065   for ( int i = 0; i < n; ++i )
00066   {
00067     MigrateAtomsMsg *msg = new MigrateAtomsMsg;
00068     msg->fromNodeID = fromNodeID;
00069     msg->srcPatchID = srcPatchID[i];
00070     msg->destPatchID = destPatchID[i];
00071     int l = numAtoms[i];
00072     {
00073       DebugM(3,"Distributing " << l << " atoms to patch " << msg->destPatchID << "\n");
00074       msg->migrationList.resize(l);
00075       for ( int j = 0; j < l; ++j ) msg->migrationList[j] = migrationList[m+j];
00076       m += l;
00077     }
00078     PatchMap::Object()->homePatch(msg->destPatchID)->depositMigration(msg);
00079   }
00080 }
00081 
00082 
00083 PACK_MSG(MigrateAtomsCombinedMsg,
00084   PACK(fromNodeID);
00085   PACK(totalAtoms);
00086   PACK_RESIZE(srcPatchID);
00087   PACK_RESIZE(destPatchID);
00088   PACK_RESIZE(numAtoms);
00089   PACK_RESIZE(migrationList);
00090 )
00091 

Generated on Sun Oct 12 04:08:13 2008 for NAMD by  doxygen 1.3.9.1