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
00024 class LocalWorkMsg : public CMessage_LocalWorkMsg
00025 {
00026 public:
00027 Compute *compute;
00028 };
00029
00030 enum { maxPatchDepends = 126 };
00031
00032 class PatchMapMsg;
00033 class ComputeMapMsg;
00034 class ComputeMapChangeMsg;
00035
00036 class WorkDistrib : public BOCclass
00037 {
00038 public:
00039 WorkDistrib();
00040 ~WorkDistrib(void);
00041
00042
00043
00044
00045 static void messageEnqueueWork(Compute *);
00046 void enqueueWork(LocalWorkMsg *msg);
00047 void enqueueExcls(LocalWorkMsg *msg);
00048 void enqueueBonds(LocalWorkMsg *msg);
00049 void enqueueAngles(LocalWorkMsg *msg);
00050 void enqueueDihedrals(LocalWorkMsg *msg);
00051 void enqueueImpropers(LocalWorkMsg *msg);
00052 void enqueueThole(LocalWorkMsg *msg);
00053 void enqueueAniso(LocalWorkMsg *msg);
00054 void enqueueCrossterms(LocalWorkMsg *msg);
00055 void enqueuePme(LocalWorkMsg *msg);
00056 void enqueueSelfA1(LocalWorkMsg *msg);
00057 void enqueueSelfA2(LocalWorkMsg *msg);
00058 void enqueueSelfA3(LocalWorkMsg *msg);
00059 void enqueueSelfB1(LocalWorkMsg *msg);
00060 void enqueueSelfB2(LocalWorkMsg *msg);
00061 void enqueueSelfB3(LocalWorkMsg *msg);
00062 void enqueueWorkA1(LocalWorkMsg *msg);
00063 void enqueueWorkA2(LocalWorkMsg *msg);
00064 void enqueueWorkA3(LocalWorkMsg *msg);
00065 void enqueueWorkB1(LocalWorkMsg *msg);
00066 void enqueueWorkB2(LocalWorkMsg *msg);
00067 void enqueueWorkB3(LocalWorkMsg *msg);
00068 void enqueueWorkC(LocalWorkMsg *msg);
00069 void enqueueCUDA(LocalWorkMsg *msg);
00070 void enqueueCUDAP2(LocalWorkMsg *msg);
00071 void enqueueCUDAP3(LocalWorkMsg *msg);
00072
00073 void mapComputes(void);
00074 void sendPatchMap(void);
00075 void sendComputeMap(void);
00076 void saveComputeMapChanges(int,CkGroupID);
00077 void recvComputeMapChanges(ComputeMapChangeMsg *);
00078 void doneSaveComputeMap(CkReductionMsg *);
00079
00080 FullAtomList *createAtomLists(void);
00081 void createHomePatches(void);
00082 void distributeHomePatches(void);
00083
00084 void reinitAtoms(void);
00085 void patchMapInit(void);
00086 void assignNodeToPatch(void);
00087
00088 void savePatchMap(PatchMapMsg *msg);
00089 void saveComputeMap(ComputeMapMsg *msg);
00090 inline void setPatchMapArrived(bool s) {patchMapArrived=s;}
00091
00092 #ifdef MEM_OPT_VERSION
00093 void fillAtomListForOnePatch(int pid, FullAtomList &alist);
00094 void random_velocities_parallel(BigReal Temp,InputAtomList &inAtoms);
00095 #endif
00096
00097 private:
00098 void mapComputeNonbonded(void);
00099 void mapComputeNode(ComputeType);
00100 void mapComputeHomePatches(ComputeType);
00101 void mapComputeHomeTuples(ComputeType);
00102 void mapComputePatch(ComputeType);
00103 void assignPatchesToLowestLoadNode(void);
00104 void assignPatchesRecursiveBisection(void);
00105 void assignPatchesRoundRobin(void);
00106 void assignPatchesSpaceFillingCurve(void);
00107 void assignPatchesBitReversal(void);
00108 int assignPatchesTopoGridRecBisection();
00109
00110 void sortNodesAndAssign(int *assignedNode, int baseNodes = 0);
00111 void velocities_from_PDB(char *filename,
00112 Vector *v, int totalAtoms);
00113 void velocities_from_binfile(char *fname, Vector *vels, int n);
00114 void random_velocities(BigReal Temp, Molecule *structure,
00115 Vector *v, int totalAtoms);
00116 void remove_com_motion(Vector *vel, Molecule *structure, int n);
00117
00118 bool patchMapArrived;
00119 bool computeMapArrived;
00120
00121 int saveComputeMapReturnEP;
00122 CkGroupID saveComputeMapReturnChareID;
00123 };
00124
00125 #endif
00126