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

Generated on Wed Jun 20 01:17:16 2018 for NAMD by  doxygen 1.4.7