00001
00007 #ifndef COMPUTEMAP_H
00008 #define COMPUTEMAP_H
00009
00010 #include "NamdTypes.h"
00011 #include "ProcessorPrivate.h"
00012 #include "ResizeArray.h"
00013
00014 class Compute;
00015 class ComputeMgr;
00016 template<class Type> class ObjectArena;
00017
00018 enum ComputeType
00019 {
00020 computeNonbondedSelfType,
00021 computeNonbondedPairType,
00022 computeNonbondedCUDAType,
00023 computeExclsType,
00024 computeBondsType,
00025 computeAnglesType,
00026 computeDihedralsType,
00027 computeImpropersType,
00028 computeTholeType,
00029 computeAnisoType,
00030 computeCrosstermsType,
00031 computeSelfExclsType,
00032 computeSelfBondsType,
00033 computeSelfAnglesType,
00034 computeSelfDihedralsType,
00035 computeSelfImpropersType,
00036 computeSelfTholeType,
00037 computeSelfAnisoType,
00038 computeSelfCrosstermsType,
00039 #ifdef DPMTA
00040 computeDPMTAType,
00041 #endif
00042 #ifdef DPME
00043 computeDPMEType,
00044 #endif
00045 computePmeType,
00046 optPmeType,
00047 computeEwaldType,
00048 computeFullDirectType,
00049 computeGlobalType,
00050 computeExtType,
00051 computeGBISserType,
00052 computeLCPOType,
00053 computeMsmSerialType,
00054 computeMsmMsaType,
00055 computeMsmType,
00056 computeEFieldType,
00057
00058 computeGridForceType,
00059
00060 computeStirType,
00061 computeSphericalBCType,
00062 computeCylindricalBCType,
00063 computeTclBCType,
00064 computeRestraintsType,
00065 computeConsForceType,
00066 computeConsTorqueType,
00067 computeErrorType
00068 };
00069
00070 class ComputeMap
00071 {
00072 public:
00073 static ComputeMap *Instance();
00074 inline static ComputeMap *Object() { return instance; }
00075
00076 void checkMap();
00077
00078 ~ComputeMap(void);
00079
00080 void registerCompute(ComputeID cid, Compute *c) {
00081 computePtrs[cid] = c;
00082 }
00083
00084
00085
00086 inline int numComputes(void) {
00087 return nComputes;
00088 }
00089
00090
00091 inline int node(ComputeID cid) {
00092 return computeData[cid].node;
00093 }
00094
00095 inline void setNode(ComputeID cid, NodeID node) {
00096 computeData[cid].node = node;
00097 }
00098
00099
00100
00101 inline NodeID newNode(ComputeID cid) {
00102 return (computeData[cid].moveToNode);
00103 }
00104
00105 inline void setNewNode(ComputeID cid, NodeID node) {
00106 computeData[cid].moveToNode = node;
00107 }
00108
00109
00110
00111 int numPids(ComputeID cid);
00112
00113
00114
00115 int pid(ComputeID cid, int i);
00116 int trans(ComputeID cid, int i);
00117
00118
00119 ComputeType type(ComputeID cid);
00120 int partition(ComputeID cid);
00121 int numPartitions(ComputeID cid);
00122
00123 inline void setNumPartitions(ComputeID cid, char numPartitions) {
00124 computeData[cid].numPartitions = numPartitions;
00125 }
00126 inline char newNumPartitions(ComputeID cid) {
00127 return (computeData[cid].newNumPartitions);
00128 }
00129 inline void setNewNumPartitions(ComputeID cid, char numPartitions) {
00130 computeData[cid].newNumPartitions = numPartitions;
00131 }
00132
00133 int allocateCids();
00134
00135
00136
00137
00138 ComputeID storeCompute(int node,int maxPids,ComputeType type,
00139 int partition=-1, int numPartitions=0);
00140
00141
00142
00143 void newPid(ComputeID cid, int pid, int trans = 13);
00144
00145 ComputeID cloneCompute(ComputeID src, int partition);
00146
00147 void printComputeMap(void);
00148 void saveComputeMap(const char *fname);
00149 void loadComputeMap(const char *fname);
00150
00151 Compute *compute(ComputeID cid) { return computePtrs[cid]; };
00152
00153 friend class ComputeMgr;
00154
00155 struct PatchRec
00156 {
00157 PatchID pid;
00158 int trans;
00159
00160 PatchRec() : pid(-1), trans(-1) { ; }
00161 };
00162
00163 enum { numPidsAllocated=8 };
00164
00165 struct ComputeData
00166 {
00167 ComputeData() {
00168 node = -1; moveToNode = -1;
00169 newNumPartitions = 0;
00170 numPids = 0;
00171 }
00172 int node;
00173 int moveToNode;
00174 ComputeType type;
00175 char partition;
00176 char numPartitions;
00177 char newNumPartitions;
00178 char numPids;
00179 PatchRec pids[numPidsAllocated];
00180 };
00181 protected:
00182 friend class WorkDistrib;
00183 void pack(ComputeData *buf);
00184 void unpack(int n, ComputeData *buf);
00185 void initPtrs();
00186 void extendPtrs();
00187
00188 ComputeMap(void);
00189
00190 private:
00191 int nComputes;
00192 ResizeArray<ComputeData> computeData;
00193 Compute **computePtrs;
00194
00195 static ComputeMap *instance;
00196 };
00197
00198 #endif
00199