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 PACK_MSG(MigrateAtomsMsg,
00026   PACK(fromNodeID);
00027   PACK(srcPatchID);
00028   PACK(destPatchID);
00029   PACK_RESIZE(migrationList);
00030 )
00031 
00032 
00033 MigrateAtomsCombinedMsg::MigrateAtomsCombinedMsg(void)
00034 {
00035   fromNodeID = CkMyPe();
00036   totalAtoms = 0;
00037 }
00038 
00039 void MigrateAtomsCombinedMsg::
00040 	add(PatchID source, PatchID destination, MigrationList &m)
00041 {
00042   srcPatchID.add(source);
00043   destPatchID.add(destination);
00044   int n = m.size();
00045   numAtoms.add(n);
00046   totalAtoms += n;
00047   for ( int i = 0; i < n; ++i )
00048   {
00049     migrationList.add(m[i]);
00050   }
00051 }
00052 
00053 
00054 void MigrateAtomsCombinedMsg::distribute(void)
00055 {
00056   int n = srcPatchID.size();
00057   int m = 0;
00058   for ( int i = 0; i < n; ++i )
00059   {
00060     MigrateAtomsMsg *msg = new MigrateAtomsMsg;
00061     msg->fromNodeID = fromNodeID;
00062     msg->srcPatchID = srcPatchID[i];
00063     msg->destPatchID = destPatchID[i];
00064     int l = numAtoms[i];
00065     {
00066       DebugM(3,"Distributing " << l << " atoms to patch " << msg->destPatchID << "\n");
00067       msg->migrationList.resize(l);
00068       for ( int j = 0; j < l; ++j ) msg->migrationList[j] = migrationList[m+j];
00069       m += l;
00070     }
00071     PatchMap::Object()->homePatch(msg->destPatchID)->depositMigration(msg);
00072   }
00073   if ( m != totalAtoms ) NAMD_bug("MigrateAtomsCombinedMsg::distribute bad atom count");
00074 }
00075 
00076 
00077 PACK_MSG(MigrateAtomsCombinedMsg,
00078   PACK(fromNodeID);
00079   PACK(totalAtoms);
00080   PACK_RESIZE(srcPatchID);
00081   PACK_RESIZE(destPatchID);
00082   PACK_RESIZE(numAtoms);
00083   PACK_RESIZE(migrationList);
00084 )
00085 

Generated on Sat Sep 23 01:17:14 2017 for NAMD by  doxygen 1.4.7