WorkDistrib.h

Go to the documentation of this file.
00001 
00007 #ifndef _WORKDISTRIB_H
00008 #define _WORKDISTRIB_H
00009 
00010 #include "charm++.h"
00011 
00012 #include "main.h"
00013 
00014 #include "NamdTypes.h"
00015 #include "BOCgroup.h"
00016 #include "ComputeMap.h"
00017 #include "WorkDistrib.decl.h"
00018 
00019 class Node;
00020 class Compute;
00021 class Molecule;
00022 
00023 // For Compute objects to enqueue themselves when ready to compute
00024 class LocalWorkMsg : public CMessage_LocalWorkMsg
00025 {
00026 public:
00027   Compute *compute;
00028 };
00029 
00030 class FinishWorkMsg : public CMessage_FinishWorkMsg
00031 {
00032 public:
00033   Compute *compute;
00034   int data;
00035 };
00036 
00037 enum { maxPatchDepends = 126 };
00038 
00039 class PatchMapMsg;
00040 class ComputeMapMsg;
00041 class ComputeMapChangeMsg;
00042 
00043 class WorkDistrib : public CBase_WorkDistrib
00044 {
00045 public:
00046   WorkDistrib();
00047   ~WorkDistrib(void);
00048 
00049   // static void messageMovePatchDone();
00050   // void movePatchDone();
00051 
00052   static void messageEnqueueWork(Compute *);
00053   static void messageFinishCUDA(Compute *);
00054   static void messageFinishMIC(Compute *);
00055   void enqueueWork(LocalWorkMsg *msg);
00056   void enqueueExcls(LocalWorkMsg *msg);
00057   void enqueueBonds(LocalWorkMsg *msg);
00058   void enqueueAngles(LocalWorkMsg *msg);
00059   void enqueueDihedrals(LocalWorkMsg *msg);
00060   void enqueueImpropers(LocalWorkMsg *msg);
00061   void enqueueThole(LocalWorkMsg *msg);  // Drude model
00062   void enqueueAniso(LocalWorkMsg *msg);  // Drude model
00063   void enqueueCrossterms(LocalWorkMsg *msg);
00064   // JLai
00065   void enqueueGromacsPair(LocalWorkMsg *msg);
00066   // End of JLai
00067   void enqueuePme(LocalWorkMsg *msg);
00068   void enqueueSelfA1(LocalWorkMsg *msg);
00069   void enqueueSelfA2(LocalWorkMsg *msg);
00070   void enqueueSelfA3(LocalWorkMsg *msg);
00071   void enqueueSelfB1(LocalWorkMsg *msg);
00072   void enqueueSelfB2(LocalWorkMsg *msg);
00073   void enqueueSelfB3(LocalWorkMsg *msg);
00074   void enqueueWorkA1(LocalWorkMsg *msg);
00075   void enqueueWorkA2(LocalWorkMsg *msg);
00076   void enqueueWorkA3(LocalWorkMsg *msg);
00077   void enqueueWorkB1(LocalWorkMsg *msg);
00078   void enqueueWorkB2(LocalWorkMsg *msg);
00079   void enqueueWorkB3(LocalWorkMsg *msg);
00080   void enqueueWorkC(LocalWorkMsg *msg);
00081   void enqueueCUDA(LocalWorkMsg *msg);
00082   void enqueueCUDAP2(LocalWorkMsg *msg);
00083   void enqueueCUDAP3(LocalWorkMsg *msg);
00084   void finishCUDAPatch(FinishWorkMsg *msg);
00085   void finishCUDA(LocalWorkMsg *msg);
00086   void finishCUDAP2(LocalWorkMsg *msg);
00087   void finishCUDAP3(LocalWorkMsg *msg);
00088   void enqueueMIC(LocalWorkMsg *msg);
00089   void finishMIC(LocalWorkMsg *msg);
00090   void enqueueLCPO(LocalWorkMsg *msg);
00091 
00092   void mapComputes(void);
00093   void sendPatchMap(void);
00094   void sendComputeMap(void);
00095   void saveComputeMapChanges(int,CkGroupID);
00096   void recvComputeMapChanges(ComputeMapChangeMsg *);
00097   void doneSaveComputeMap(CkReductionMsg *);
00098 
00099   FullAtomList *createAtomLists(const char *basename=0);
00100   void createHomePatches(void);
00101   void distributeHomePatches(void);
00102 
00103   void reinitAtoms(const char *basename=0);
00104   void patchMapInit(void);
00105   void assignNodeToPatch(void);
00106 
00107   void savePatchMap(PatchMapMsg *msg);
00108   void saveComputeMap(ComputeMapMsg *msg);
00109   inline void setPatchMapArrived(bool s) {patchMapArrived=s;}
00110 
00111 #ifdef MEM_OPT_VERSION
00112   void fillAtomListForOnePatch(int pid, FullAtomList &alist);
00113   void random_velocities_parallel(BigReal Temp,InputAtomList &inAtoms);
00114 #endif
00115 
00116   static int peOrderingInit;           // used during startup
00117   static int *peDiffuseOrdering;       // pes in diffuse order
00118   static int *peDiffuseOrderingIndex;  // index of pe in diffuse order
00119   static int *peCompactOrdering;       // pes in compact order
00120   static int *peCompactOrderingIndex;  // index of pe in compact order
00121 
00122   struct pe_sortop_diffuse {
00123     inline bool operator() (int a, int b) const {
00124       const int *index = WorkDistrib::peDiffuseOrderingIndex;
00125       return ( index[a] < index[b] );
00126     }
00127   };
00128   struct pe_sortop_compact {
00129     inline bool operator() (int a, int b) const {
00130       const int *index = WorkDistrib::peCompactOrderingIndex;
00131       return ( index[a] < index[b] );
00132     }
00133   };
00134 
00135   static void sortPmePes(int *pmepes, int xdim, int ydim);
00136 
00137   static void peOrderingReady();
00138 
00139   // MIC-Specific
00140   static void send_initHostDeviceLDB();
00141   /* entry */ void initHostDeviceLDB();
00142   static void send_contributeHostDeviceLDB(int peSetLen, int * peSet);
00143   /* entry */ void contributeHostDeviceLDB(int peSetLen, int * peSet);
00144   static void send_setDeviceLDBParams(int dt, int hs, int sp1, int pp1, int pp2);
00145   /* entry */ void setDeviceLDBParams(int dt, int hs, int sp1, int pp1, int pp2);
00146 
00147   static void buildNodeAwarePeOrdering(void);
00148 
00149 private:
00150   void mapComputeNonbonded(void);
00151   void mapComputeLCPO(void);
00152   void mapComputeNode(ComputeType);
00153   void mapComputeHomePatches(ComputeType);
00154   void mapComputeHomeTuples(ComputeType);
00155   void mapComputePatch(ComputeType);
00156   void assignPatchesToLowestLoadNode(void);
00157   void assignPatchesRecursiveBisection(void);
00158   void assignPatchesRoundRobin(void);
00159   void assignPatchesSpaceFillingCurve(void);
00160   void assignPatchesBitReversal(void);
00161   int  assignPatchesTopoGridRecBisection();
00162 
00163   void sortNodesAndAssign(int *assignedNode, int baseNodes = 0);
00164   void velocities_from_PDB(const char *filename, 
00165                            Vector *v, int totalAtoms);
00166   void velocities_from_binfile(const char *fname, Vector *vels, int n);
00167   void random_velocities(BigReal Temp, Molecule *structure,
00168                          Vector *v, int totalAtoms);
00169   void remove_com_motion(Vector *vel, Molecule *structure, int n);
00170 
00171   bool patchMapArrived;
00172   bool computeMapArrived;
00173 
00174   int saveComputeMapReturnEP;
00175   CkGroupID saveComputeMapReturnChareID;
00176 };
00177 
00178 #endif /* WORKDISTRIB_H */
00179 

Generated on Tue Sep 26 01:17:15 2017 for NAMD by  doxygen 1.4.7