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 #ifdef NAMD_MIC
00018 // defined here to avoid including ComputeNonbondedMICKernel.h
00019 #define MIC_MAX_DEVICES_PER_NODE          ( 16 )
00020 #endif
00021 
00022 typedef SortedArray<Compute*> ComputePtrList;
00023 
00024 class Compute;
00025 class Sequencer;
00026 class PatchMap;
00027 class AtomMapper;
00028 class SubmitReduction;
00029 
00030 // This the base class of homepatches and proxy patches. It maintains
00031 // common functions of these patches. These include managing dependences
00032 // between compute (force) objects and the patch and updating atom map.
00033 
00034 class Patch
00035 {
00036   public:
00037 
00038      Patch(PatchID pd);
00039      int hasNewAtoms() { return _hasNewAtoms; }
00040      virtual ~Patch();
00041 
00042      // methods for use by Compute objects
00043      Box<Patch,CompAtom>* registerPositionPickup(Compute *cid);
00044      void unregisterPositionPickup(Compute *cid,
00045                                    Box<Patch,CompAtom>**const box);
00046      Box<Patch,CompAtom>* registerAvgPositionPickup(Compute *cid);
00047      void unregisterAvgPositionPickup(Compute *cid,
00048                                    Box<Patch,CompAtom>**const box);
00049      // BEGIN LA
00050      Box<Patch,CompAtom>* registerVelocityPickup(Compute *cid);
00051      void unregisterVelocityPickup(Compute *cid,
00052                                   Box<Patch,CompAtom>**const box);
00053      // END LA
00054 
00055     //begin gbis
00056     Box<Patch,Real>* registerIntRadPickup(Compute *cid);
00057     void unregisterIntRadPickup(Compute *cid, Box<Patch,Real>**const box);
00058 
00059     Box<Patch,GBReal>* registerPsiSumDeposit(Compute *cid);
00060     void unregisterPsiSumDeposit(Compute *cid, Box<Patch,GBReal>**const box);
00061 
00062     Box<Patch,Real>* registerBornRadPickup(Compute *cid);
00063     void unregisterBornRadPickup(Compute *cid, Box<Patch,Real>**const box);
00064 
00065     Box<Patch,GBReal>* registerDEdaSumDeposit(Compute *cid);
00066     void unregisterDEdaSumDeposit(Compute *cid,Box<Patch,GBReal> **const box);
00067 
00068     Box<Patch,Real>* registerDHdrPrefixPickup(Compute *cid);
00069     void unregisterDHdrPrefixPickup(Compute *cid, Box<Patch,Real>**const box);
00070      //end gbis
00071 
00072     //LCPO
00073     Box<Patch,int>* registerLcpoTypePickup(Compute *cid);
00074     void unregisterLcpoTypePickup(Compute *cid, Box<Patch,int>**const box);
00075 
00076      Box<Patch,Results>* registerForceDeposit(Compute *cid);
00077      void unregisterForceDeposit(Compute *cid, Box<Patch,Results> **const box);
00078 
00079      // methods for use by Sequencer or ProxyManager
00080      // void positionsReady(void) { positionsReady(0); }
00081      void positionsReady(int n=0);
00082 
00083      // methods for Box callbacks
00084      void positionBoxClosed(void);
00085      void forceBoxClosed(void);
00086      void avgPositionBoxClosed(void);
00087      // BEGIN LA
00088      void velocityBoxClosed(void);
00089      // END LA
00090 
00091      //begin gbis
00092      void intRadBoxClosed(void);// intrinsic radii
00093      void psiSumBoxClosed(void);// sum screening 
00094      void bornRadBoxClosed(void);// born radius
00095      void dEdaSumBoxClosed(void);// sum dEda contributions
00096      void dHdrPrefixBoxClosed(void);//dHdr prefix
00097      void gbisP2Ready();
00098      void gbisP3Ready();
00099      //end gbis
00100 
00101      //LCPO
00102      void lcpoTypeBoxClosed(void);
00103 
00104      int getNumAtoms() { return numAtoms; }
00105 
00106      // DMK - Atom Separation (water vs. non-water)
00107      #if NAMD_SeparateWaters != 0
00108        int getNumWaterAtoms() { return numWaterAtoms; }
00109      #endif
00110 
00111      int getNumFixedAtoms() { return numFixedAtoms; }  // not updated
00112      void setNumFixedAtoms(int numFixed) { numFixedAtoms=numFixed; }  // not updated
00113      PatchID getPatchID() { return patchID; }
00114      int getNumComputes() { return positionComputeList.size(); }
00115 
00116      CompAtomExt* getCompAtomExtInfo() { return pExt.begin(); }
00117 #ifdef NAMD_KNL
00118      CompAtomFlt* getCompAtomFlt() { return pFlt.begin(); }
00119 #endif
00120      CudaAtom* getCudaAtomList() { return cudaAtomPtr; }
00121 
00122      Lattice &lattice;
00123      Flags flags;
00124 
00125      // DMK - NOTE : Just placing the variables in public for now so only one location, move to protected if this actually helps performance
00126      #if defined(NAMD_MIC) // NOTE: Used for submit atoms on arrival
00127        pthread_mutex_t mic_atomData_mutex;
00128        void* mic_atomData;
00129        void* mic_atomData_prev[MIC_MAX_DEVICES_PER_NODE];
00130        int mic_atomData_seq;
00131        int mic_atomData_deviceSeq[MIC_MAX_DEVICES_PER_NODE];
00132        uint64_t mic_atomData_devicePtr[MIC_MAX_DEVICES_PER_NODE];
00133        int mic_atomData_allocSize_host;
00134        int mic_atomData_allocSize_device[MIC_MAX_DEVICES_PER_NODE];
00135      #endif
00136 
00137   protected:
00138 
00139      const PatchID patchID;
00140      int           numAtoms;
00141      int           numFixedAtoms;
00142      CompAtomList  p;
00143      CompAtomList  p_avg;
00144      // BEGIN LA
00145      CompAtomList  v;
00146      // END LA
00147 
00148      AtomMapper *atomMapper;
00149 
00150      // begin gbis
00151      RealList intRad;
00152      GBRealList psiSum;
00153      GBRealList psiFin;
00154      RealList bornRad;
00155      RealList dHdrPrefix;
00156      GBRealList dEdaSum;
00157      // end gbis
00158 
00159     //LCPO
00160     IntList lcpoType;
00161 
00162      // DMK - Atom Separation (water vs. non-water)
00163      #if NAMD_SeparateWaters != 0
00164        int numWaterAtoms;  // Set numWaters to the number of water atoms at
00165                            //   the lead of the atoms list.  If numWaters is
00166                            //   set to -1, this should indicate that
00167                            //   atoms has not been separated yet.
00168      #endif
00169 
00170      CompAtomExtList pExt;
00171 #ifdef NAMD_KNL
00172      CompAtomFltList pFlt;
00173 #endif
00174 
00175 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
00176      //1. Those fields are declared for reusing position info
00177      //inside the ProxyDataMsg msg at every step so that the
00178      //extra copy is avoided.
00179      //Regarding the CompAtomExt list inside the msg of ProxyAllMsg type
00180      //we cannot avoid the copy in the current scheme because this information
00181      //will be lost as the msg will be deleted at the next timestep. But the
00182      //overhead is amortized among the steps that atoms don't migrate
00183      //2. positionPtrBegin is better to be made 32-byte aligned so we could
00184      // have better cache performance in the force calculation part. This
00185      // is especially needed for BG/L machine.
00186      // --Chao Mei
00187      CompAtom      *positionPtrBegin;
00188      CompAtom      *positionPtrEnd;     
00189 #endif
00190      CompAtom      *avgPositionPtrBegin;
00191      CompAtom      *avgPositionPtrEnd;
00192 
00193      // BEGIN LA
00194      CompAtom      *velocityPtrBegin;
00195      CompAtom      *velocityPtrEnd;
00196      // END LA
00197 
00198      CudaAtom      *cudaAtomPtr;
00199 
00200      ForceList     f[Results::maxNumForces];
00201      Results       results;
00202 
00203      int computesSortedByPriority;
00204      int firstHoldableCompute;
00205 
00206      OwnerBox<Patch,CompAtom> positionBox;
00207      ComputePtrList              positionComputeList;
00208      OwnerBox<Patch,CompAtom> avgPositionBox;
00209      ComputePtrList              avgPositionComputeList;
00210      // BEGIN LA
00211      OwnerBox<Patch,CompAtom> velocityBox;
00212      ComputePtrList              velocityComputeList;
00213      // END LA
00214 
00215      //begin gbis
00216      OwnerBox<Patch,Real>    intRadBox;
00217      ComputePtrList           intRadComputeList;
00218      OwnerBox<Patch,GBReal>  psiSumBox;
00219      ComputePtrList           psiSumComputeList;
00220      OwnerBox<Patch,Real>    bornRadBox;
00221      ComputePtrList           bornRadComputeList;
00222      OwnerBox<Patch,GBReal>  dEdaSumBox;
00223      ComputePtrList           dEdaSumComputeList;
00224      OwnerBox<Patch,Real>    dHdrPrefixBox;
00225      ComputePtrList           dHdrPrefixComputeList;
00226      //end gbis
00227 
00228     //LCPO
00229      OwnerBox<Patch,int>    lcpoTypeBox;
00230      ComputePtrList          lcpoTypeComputeList;
00231 
00232      OwnerBox<Patch,Results>    forceBox;
00233      ComputePtrList              forceComputeList;
00234 
00235      virtual void boxClosed(int /* box */) = 0;
00236      int boxesOpen;
00237 
00238      int _hasNewAtoms;
00239 
00240 #ifdef NODEAWARE_PROXY_SPANNINGTREE    
00241     //its own children in proxy tree
00242     #ifdef USE_NODEPATCHMGR
00243     //the immediate children (in terms of node id) also cotains two parts
00244     //as the above variable shows
00245     //If this patch has proxies residing on the same node, then the last entry
00246     //of "nodeChildren" stores this node id. It is same with that variable
00247     //in ProxyPatch      
00248     //If this proxy resides on node A, then the last entry
00249     //of "nodeChildren" has to be A
00250     //It is same with that variable in HomePatch
00251     int *nodeChildren;
00252     int numNodeChild;
00253     #endif
00254 #endif
00255         int *child;
00256         int nChild;
00257 
00258   private:
00259 
00260     SubmitReduction *reduction;
00261 
00262 };
00263 
00264 
00265 #endif
00266 

Generated on Fri Sep 22 01:17:14 2017 for NAMD by  doxygen 1.4.7