Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | 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   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 /* BEGIN gf */
00049   computeGridForceType,
00050 /* END gf */
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   // numComputes() returns the number of compute objects known
00077   // by the map.
00078   inline int numComputes(void) {
00079     return nComputes;
00080   }
00081 
00082   // numPatchBased() returns the number of compute objects
00083   // that are patch-based
00084   int numPatchBased(void);
00085 
00086   // numAtomBased() returns the number of compute objects
00087   // that are atom-based
00088   int numAtomBased(void);
00089 
00090   // isPatchBased(cid) returns true if the compute object
00091   // is patch based.
00092   int isPatchBased(ComputeID cid);
00093 
00094   // isAtomBased(cid) returns true if the compute object
00095   // is atom based.
00096   int isAtomBased(ComputeID cid);
00097 
00098   // node(cid) returns the node where the compute object currently exists.
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   // newNode(cid,node) sets up map to tell WorkDistrib to send 
00108   // compute to new node
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   // numPids(cid) returns the number of patch ids which are registered
00118   // with this compute object.
00119   int numPids(ComputeID cid);
00120   
00121   // pid(cid,i) returns the i-th patch id registered
00122   // with the patch.  
00123   int pid(ComputeID cid, int i);
00124   int trans(ComputeID cid, int i);
00125 
00126   // type(cid) returns the compute type of the given ComputeID
00127   ComputeType type(ComputeID cid);
00128   int partition(ComputeID cid);
00129   int numPartitions(ComputeID cid);
00130 
00131   int allocateCids();
00132 
00133   // storeCompute(cid,node,maxPids) tells the ComputeMap to store
00134   // information about the indicated patch, and allocate space
00135   // for up to maxPids dependents
00136   ComputeID storeCompute(int node,int maxPids,ComputeType type,
00137                          int partition=0, int numPartitions=1);
00138 
00139   // newPid(cid,pid) stores the n patch ids associated with
00140   // compute id cid.
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 /* COMPUTEMAP_H */
00192 

Generated on Mon Nov 23 04:59:19 2009 for NAMD by  doxygen 1.3.9.1