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

Patch.h

Go to the documentation of this file.
00001 
00007 #ifndef PATCH_H
00008 #define PATCH_H
00009 
00010 #include "NamdTypes.h"
00011 #include "OwnerBox.h"
00012 #include "Box.h"
00013 #include "UniqueSortedArray.h"
00014 #include "Lattice.h"
00015 #include "PatchTypes.h"
00016 
00017 typedef SortedArray<ComputeID> ComputeIDList;
00018 
00019 class Compute;
00020 class Sequencer;
00021 class PatchMap;
00022 
00023 
00024 // This the base class of homepatches and proxy patches. It maintains
00025 // common functions of these patches. These include managing dependences
00026 // between compute (force) objects and the patch and updating atom map.
00027 
00028 class Patch
00029 {
00030   public:
00031 
00032      Patch(PatchID pd);
00033      int hasNewAtoms() { return _hasNewAtoms; }
00034      virtual ~Patch(void) { };
00035 
00036      // methods for use by Compute objects
00037      Box<Patch,CompAtom>* registerPositionPickup(ComputeID cid, int trans = 13);
00038      void unregisterPositionPickup(ComputeID cid,
00039                                    Box<Patch,CompAtom>**const box);
00040      Box<Patch,CompAtom>* registerAvgPositionPickup(ComputeID cid, int trans = 13);
00041      void unregisterAvgPositionPickup(ComputeID cid,
00042                                    Box<Patch,CompAtom>**const box);
00043      Box<Patch,Results>* registerForceDeposit(ComputeID cid);
00044      void unregisterForceDeposit(ComputeID cid, Box<Patch,Results> **const box);
00045 
00046      // methods for use by Sequencer or ProxyManager
00047      // void positionsReady(void) { positionsReady(0); }
00048      void positionsReady(int n=0);
00049 
00050      // methods for Box callbacks
00051      void positionBoxClosed(void);
00052      void forceBoxClosed(void);
00053      void avgPositionBoxClosed(void);
00054 
00055      int getNumAtoms() { return numAtoms; }
00056 
00057      // DMK - Atom Separation (water vs. non-water)
00058      #if NAMD_SeparateWaters != 0
00059        int getNumWaterAtoms() { return numWaterAtoms; }
00060      #endif
00061 
00062      int getNumFixedAtoms() { return numFixedAtoms; }  // not updated
00063      void setNumFixedAtoms(int numFixed) { numFixedAtoms=numFixed; }  // not updated
00064      PatchID getPatchID() { return patchID; }
00065      int getNumComputes() { return positionComputeList.size(); }
00066 
00067 #ifdef MEM_OPT_VERSION
00068      CompAtomExt* getCompAtomExtInfo() { return pExt.begin(); }
00069 #endif
00070 
00071      Lattice &lattice;
00072      Flags flags;
00073 
00074   protected:
00075 
00076      const PatchID patchID;
00077      int           numAtoms;
00078      int           numFixedAtoms;
00079      CompAtomList  p;
00080      CompAtomList  p_avg;
00081 
00082      // DMK - Atom Separation (water vs. non-water)
00083      #if NAMD_SeparateWaters != 0
00084        int numWaterAtoms;  // Set numWaters to the number of water atoms at
00085                            //   the lead of the atoms list.  If numWaters is
00086                            //   set to -1, this should indicate that
00087                            //   atoms has not been separated yet.
00088      #endif
00089 
00090 #ifdef MEM_OPT_VERSION
00091      CompAtomExtList pExt;
00092 #endif     
00093 
00094 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
00095      //1. Those fields are declared for reusing position info
00096      //inside the ProxyDataMsg msg at every step so that the
00097      //extra copy is avoided.
00098      //Regarding the CompAtomExt list inside the msg of ProxyAllMsg type
00099      //we cannot avoid the copy in the current scheme because this information
00100      //will be lost as the msg will be deleted at the next timestep. But the
00101      //overhead is amortized among the steps that atoms don't migrate
00102      //2. positionPtrBegin is better to be made 32-byte aligned so we could
00103      // have better cache performance in the force calculation part. This
00104      // is especially needed for BG/L machine.
00105      // --Chao Mei
00106      CompAtom      *positionPtrBegin;
00107      CompAtom      *positionPtrEnd;     
00108 #endif
00109      CompAtom      *avgPositionPtrBegin;
00110      CompAtom      *avgPositionPtrEnd;
00111 
00112      ForceList     f[Results::maxNumForces];
00113      Results       results;
00114 
00115      OwnerBox<Patch,CompAtom> positionBox;
00116      ComputeIDList              positionComputeList;
00117      OwnerBox<Patch,CompAtom> avgPositionBox;
00118      ComputeIDList              avgPositionComputeList;
00119      OwnerBox<Patch,Results>    forceBox;
00120      ComputeIDList              forceComputeList;
00121 
00122      virtual void boxClosed(int /* box */) = 0;
00123      int boxesOpen;
00124 
00125      int _hasNewAtoms;
00126 
00127 #ifdef NODEAWARE_PROXY_SPANNINGTREE    
00128     //its own children in proxy tree
00129     int *children;
00130     int numChild;
00131     #ifdef USE_NODEPATCHMGR
00132     //the immediate children (in terms of node id) also cotains two parts
00133     //as the above variable shows
00134     //If this patch has proxies residing on the same node, then the last entry
00135     //of "nodeChildren" stores this node id. It is same with that variable
00136     //in ProxyPatch      
00137     //If this proxy resides on node A, then the last entry
00138     //of "nodeChildren" has to be A
00139     //It is same with that variable in HomePatch
00140     int *nodeChildren;
00141     int numNodeChild;
00142     #endif
00143 #endif
00144 
00145 
00146   private:
00147   
00148 
00149 };
00150 
00151 
00152 #endif
00153 

Generated on Thu Sep 4 04:07:40 2008 for NAMD by  doxygen 1.3.9.1