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 computeCrosstermsType,
00029 computeSelfExclsType,
00030 computeSelfBondsType,
00031 computeSelfAnglesType,
00032 computeSelfDihedralsType,
00033 computeSelfImpropersType,
00034 computeSelfCrosstermsType,
00035 #ifdef DPMTA
00036 computeDPMTAType,
00037 #endif
00038 #ifdef DPME
00039 computeDPMEType,
00040 #endif
00041 computePmeType,
00042 optPmeType,
00043 computeEwaldType,
00044 computeFullDirectType,
00045 computeGlobalType,
00046 computeExtType,
00047 computeEFieldType,
00048
00049 computeGridForceType,
00050
00051 computeStirType,
00052 computeSphericalBCType,
00053 computeCylindricalBCType,
00054 computeTclBCType,
00055 computeRestraintsType,
00056 computeConsForceType,
00057 computeConsTorqueType,
00058 computeErrorType
00059 };
00060
00061 class ComputeMap
00062 {
00063 public:
00064 static ComputeMap *Instance();
00065 inline static ComputeMap *Object() { return CkpvAccess(ComputeMap_instance); }
00066
00067 void checkMap();
00068
00069 ~ComputeMap(void);
00070
00071 void registerCompute(ComputeID cid, Compute *c) {
00072 computeData[cid].compute = c;
00073 computeData[cid].moveToNode = -1;
00074 }
00075
00076
00077
00078 inline int numComputes(void) {
00079 return nComputes;
00080 }
00081
00082
00083
00084 int numPatchBased(void);
00085
00086
00087
00088 int numAtomBased(void);
00089
00090
00091
00092 int isPatchBased(ComputeID cid);
00093
00094
00095
00096 int isAtomBased(ComputeID cid);
00097
00098
00099 inline int node(ComputeID cid) {
00100 return computeData[cid].node;
00101 }
00102
00103 inline void setNode(ComputeID cid, NodeID node) {
00104 computeData[cid].node = node;
00105 }
00106
00107
00108
00109 inline NodeID newNode(ComputeID cid) {
00110 return (computeData[cid].moveToNode);
00111 }
00112
00113 inline void setNewNode(ComputeID cid, NodeID node) {
00114 computeData[cid].moveToNode = node;
00115 }
00116
00117
00118
00119 int numPids(ComputeID cid);
00120
00121
00122
00123 int pid(ComputeID cid, int i);
00124 int trans(ComputeID cid, int i);
00125
00126
00127 ComputeType type(ComputeID cid);
00128 int partition(ComputeID cid);
00129 int numPartitions(ComputeID cid);
00130
00131 int allocateCids();
00132
00133
00134
00135
00136 ComputeID storeCompute(int node,int maxPids,ComputeType type,
00137 int partition=0, int numPartitions=1);
00138
00139
00140
00141 void newPid(ComputeID cid, int pid, int trans = 13);
00142
00143 void printComputeMap(void);
00144
00145 Compute *compute(ComputeID cid) { return (computeData[cid].compute); };
00146
00147 friend class ComputeMgr;
00148
00149 struct PatchRec
00150 {
00151 PatchID pid;
00152 int trans;
00153
00154 PatchRec() : pid(-1), trans(-1) { ; }
00155 };
00156
00157 struct ComputeData
00158 {
00159 ComputeData() {
00160 node = -1; moveToNode = -1;
00161 patchBased = false; numPids = 0; numPidsAllocated = 0;
00162 pids = NULL; compute = NULL;
00163 }
00164 Compute *compute;
00165 int node;
00166 int moveToNode;
00167 ComputeType type;
00168 int partition;
00169 int numPartitions;
00170 int patchBased;
00171 int numPids;
00172 int numPidsAllocated;
00173 PatchRec *pids;
00174 };
00175 protected:
00176 friend class WorkDistrib;
00177 int packSize(void);
00178 void pack(char* buf);
00179 void unpack(char *buf);
00180
00181 ComputeMap(void);
00182
00183 private:
00184 int nPatchBased;
00185 int nAtomBased;
00186 int nComputes;
00187 ResizeArray<ComputeData> computeData;
00188 ObjectArena<PatchRec> *patchArena;
00189 };
00190
00191 #endif
00192