Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

ComputeMap.h

Go to the documentation of this file.
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   computeFmmType,
00054   computeMsmSerialType,
00055   computeMsmMsaType,
00056   computeMsmType,
00057   computeEFieldType,
00058 /* BEGIN gf */
00059   computeGridForceType,
00060 /* END gf */
00061   computeStirType,
00062   computeSphericalBCType,
00063   computeCylindricalBCType,
00064   computeTclBCType,
00065   computeRestraintsType,
00066   computeConsForceType,
00067   computeConsTorqueType,
00068   computeErrorType
00069 };
00070 
00071 class ComputeMap
00072 {
00073 public:
00074   static ComputeMap *Instance();
00075   inline static ComputeMap *Object() { return instance; }
00076 
00077   void checkMap();
00078 
00079   ~ComputeMap(void);
00080 
00081   void registerCompute(ComputeID cid, Compute *c) {
00082     computePtrs[cid] = c;
00083   }
00084 
00085   // numComputes() returns the number of compute objects known
00086   // by the map.
00087   inline int numComputes(void) {
00088     return nComputes;
00089   }
00090 
00091   // node(cid) returns the node where the compute object currently exists.
00092   inline int node(ComputeID cid) {
00093     return computeData[cid].node;
00094   }
00095 
00096   inline void setNode(ComputeID cid, NodeID node) {
00097     computeData[cid].node = node;
00098   }
00099 
00100   // newNode(cid,node) sets up map to tell WorkDistrib to send 
00101   // compute to new node
00102   inline NodeID newNode(ComputeID cid) {
00103     return (computeData[cid].moveToNode);
00104   }
00105 
00106   inline void setNewNode(ComputeID cid, NodeID node) {
00107     computeData[cid].moveToNode = node;
00108   }
00109 
00110   // numPids(cid) returns the number of patch ids which are registered
00111   // with this compute object.
00112   int numPids(ComputeID cid);
00113   
00114   // pid(cid,i) returns the i-th patch id registered
00115   // with the patch.  
00116   int pid(ComputeID cid, int i);
00117   int trans(ComputeID cid, int i);
00118 
00119   // type(cid) returns the compute type of the given ComputeID
00120   ComputeType type(ComputeID cid);
00121   int partition(ComputeID cid);
00122   int numPartitions(ComputeID cid);
00123 
00124   inline void setNumPartitions(ComputeID cid, char numPartitions) {
00125     computeData[cid].numPartitions = numPartitions;
00126   }
00127   inline char newNumPartitions(ComputeID cid) {
00128     return (computeData[cid].newNumPartitions);
00129   }
00130   inline void setNewNumPartitions(ComputeID cid, char numPartitions) {
00131     computeData[cid].newNumPartitions = numPartitions;
00132   }
00133 
00134   int allocateCids();
00135 
00136   // storeCompute(cid,node,maxPids) tells the ComputeMap to store
00137   // information about the indicated patch, and allocate space
00138   // for up to maxPids dependents
00139   ComputeID storeCompute(int node,int maxPids,ComputeType type,
00140                          int partition=-1, int numPartitions=0);
00141 
00142   // newPid(cid,pid) stores the n patch ids associated with
00143   // compute id cid.
00144   void newPid(ComputeID cid, int pid, int trans = 13);
00145 
00146   ComputeID cloneCompute(ComputeID src, int partition);
00147 
00148   void printComputeMap(void);
00149   void saveComputeMap(const char *fname);
00150   void loadComputeMap(const char *fname);
00151 
00152   Compute *compute(ComputeID cid) { return computePtrs[cid]; };
00153 
00154   friend class ComputeMgr;
00155 
00156   struct PatchRec
00157   {
00158     PatchID pid;
00159     int trans;
00160 
00161     PatchRec() : pid(-1), trans(-1) { ; }
00162   };
00163 
00164   enum { numPidsAllocated=8 };
00165 
00166   struct ComputeData
00167   {
00168     ComputeData() { 
00169       node = -1; moveToNode = -1; 
00170       newNumPartitions = 0;
00171       numPids = 0;
00172     }
00173     int node;
00174     int moveToNode;
00175     ComputeType type;
00176     char partition;
00177     char numPartitions;
00178     char newNumPartitions;
00179     char numPids;
00180     PatchRec pids[numPidsAllocated];
00181   };
00182 protected:
00183   friend class WorkDistrib;
00184   void pack(ComputeData *buf);
00185   void unpack(int n, ComputeData *buf);
00186   void initPtrs();
00187   void extendPtrs();
00188 
00189   ComputeMap(void);
00190 
00191 private:
00192   int nComputes;
00193   ResizeArray<ComputeData> computeData;
00194   Compute **computePtrs;
00195 
00196   static ComputeMap *instance;
00197 };
00198 
00199 #endif /* COMPUTEMAP_H */
00200 

Generated on Sun May 26 04:07:45 2013 for NAMD by  doxygen 1.3.9.1