NAMD
Patch.h
Go to the documentation of this file.
1 
7 #ifndef PATCH_H
8 #define PATCH_H
9 
10 #include "NamdTypes.h"
11 #include "OwnerBox.h"
12 #include "Box.h"
13 #include "UniqueSortedArray.h"
14 #include "Lattice.h"
15 #include "PatchTypes.h"
16 #include "AVXTiles.h"
17 
18 #ifdef NAMD_MIC
19 // defined here to avoid including ComputeNonbondedMICKernel.h
20 #define MIC_MAX_DEVICES_PER_NODE ( 16 )
21 #endif
22 
24 
25 class Compute;
26 class Sequencer;
27 class PatchMap;
28 class AtomMapper;
29 class SubmitReduction;
30 
31 // This the base class of homepatches and proxy patches. It maintains
32 // common functions of these patches. These include managing dependences
33 // between compute (force) objects and the patch and updating atom map.
34 
35 class Patch
36 {
37  public:
38 
39  Patch(PatchID pd);
40  int hasNewAtoms() { return _hasNewAtoms; }
41  virtual ~Patch();
42 
43  // methods for use by Compute objects
46  Box<Patch,CompAtom>**const box);
49  Box<Patch,CompAtom>**const box);
50  // BEGIN LA
53  Box<Patch,CompAtom>**const box);
54  // END LA
55 
56  //begin gbis
58  void unregisterIntRadPickup(Compute *cid, Box<Patch,Real>**const box);
59 
61  void unregisterPsiSumDeposit(Compute *cid, Box<Patch,GBReal>**const box);
62 
64  void unregisterBornRadPickup(Compute *cid, Box<Patch,Real>**const box);
65 
67  void unregisterDEdaSumDeposit(Compute *cid,Box<Patch,GBReal> **const box);
68 
70  void unregisterDHdrPrefixPickup(Compute *cid, Box<Patch,Real>**const box);
71  //end gbis
72 
73  //LCPO
75  void unregisterLcpoTypePickup(Compute *cid, Box<Patch,int>**const box);
76 
78  void unregisterForceDeposit(Compute *cid, Box<Patch,Results> **const box);
79 
80  // methods for use by Sequencer or ProxyManager
81  // void positionsReady(void) { positionsReady(0); }
82  void positionsReady(int n=0);
83 
84  // methods for Box callbacks
85  void positionBoxClosed(void);
86  void forceBoxClosed(void);
87  void avgPositionBoxClosed(void);
88  // BEGIN LA
89  void velocityBoxClosed(void);
90  // END LA
91 
92  //begin gbis
93  void intRadBoxClosed(void);// intrinsic radii
94  void psiSumBoxClosed(void);// sum screening
95  void bornRadBoxClosed(void);// born radius
96  void dEdaSumBoxClosed(void);// sum dEda contributions
97  void dHdrPrefixBoxClosed(void);//dHdr prefix
98  void gbisP2Ready();
99  void gbisP3Ready();
100  //end gbis
101 
102  //LCPO
103  void lcpoTypeBoxClosed(void);
104 
105  int getNumAtoms() { return numAtoms; }
106 
107  // DMK - Atom Separation (water vs. non-water)
108  #if NAMD_SeparateWaters != 0
109  int getNumWaterAtoms() { return numWaterAtoms; }
110  #endif
111 
112  int getNumFixedAtoms() { return numFixedAtoms; } // not updated
113  void setNumFixedAtoms(int numFixed) { numFixedAtoms=numFixed; } // not updated
114  PatchID getPatchID() { return patchID; }
116 
118 #ifdef NAMD_KNL
119  CompAtomFlt* getCompAtomFlt() { return pFlt.begin(); }
120 #endif
121 #ifdef NAMD_AVXTILES
122  AVXTiles* getTiles() { return &tiles; }
123 #endif
125 
128 
129  // DMK - NOTE : Just placing the variables in public for now so only one location, move to protected if this actually helps performance
130  #if defined(NAMD_MIC) // NOTE: Used for submit atoms on arrival
131  pthread_mutex_t mic_atomData_mutex;
132  void* mic_atomData;
133  void* mic_atomData_prev[MIC_MAX_DEVICES_PER_NODE];
134  int mic_atomData_seq;
135  int mic_atomData_deviceSeq[MIC_MAX_DEVICES_PER_NODE];
136  uint64_t mic_atomData_devicePtr[MIC_MAX_DEVICES_PER_NODE];
137  int mic_atomData_allocSize_host;
138  int mic_atomData_allocSize_device[MIC_MAX_DEVICES_PER_NODE];
139  #endif
140 
141  protected:
142 
144  int numAtoms;
148  // BEGIN LA
150  // END LA
151 
153 
154  // begin gbis
161  // end gbis
162 
163  //LCPO
165 
166  // DMK - Atom Separation (water vs. non-water)
167  #if NAMD_SeparateWaters != 0
168  int numWaterAtoms; // Set numWaters to the number of water atoms at
169  // the lead of the atoms list. If numWaters is
170  // set to -1, this should indicate that
171  // atoms has not been separated yet.
172  #endif
173 
175 #ifdef NAMD_KNL
176  CompAtomFltList pFlt;
177 #endif
178 #ifdef NAMD_AVXTILES
179  AVXTiles tiles;
180 #endif
181 
182 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
183  //1. Those fields are declared for reusing position info
184  //inside the ProxyDataMsg msg at every step so that the
185  //extra copy is avoided.
186  //Regarding the CompAtomExt list inside the msg of ProxyAllMsg type
187  //we cannot avoid the copy in the current scheme because this information
188  //will be lost as the msg will be deleted at the next timestep. But the
189  //overhead is amortized among the steps that atoms don't migrate
190  //2. positionPtrBegin is better to be made 32-byte aligned so we could
191  // have better cache performance in the force calculation part. This
192  // is especially needed for BG/L machine.
193  // --Chao Mei
194  CompAtom *positionPtrBegin;
195  CompAtom *positionPtrEnd;
196 #endif
199 
200  // BEGIN LA
203  // END LA
204 
206 
209 
212 
217  // BEGIN LA
220  // END LA
221 
222  //begin gbis
233  //end gbis
234 
235  //LCPO
238 
241 
242  virtual void boxClosed(int /* box */) = 0;
244 
246 
247 #ifdef NODEAWARE_PROXY_SPANNINGTREE
248  //its own children in proxy tree
249  #ifdef USE_NODEPATCHMGR
250  //the immediate children (in terms of node id) also cotains two parts
251  //as the above variable shows
252  //If this patch has proxies residing on the same node, then the last entry
253  //of "nodeChildren" stores this node id. It is same with that variable
254  //in ProxyPatch
255  //If this proxy resides on node A, then the last entry
256  //of "nodeChildren" has to be A
257  //It is same with that variable in HomePatch
258  int *nodeChildren;
259  int numNodeChild;
260  #endif
261 #endif
262  int *child;
263  int nChild;
264 
265  private:
266 
267  SubmitReduction *reduction;
268 
269 };
270 
271 
272 #endif
273 
ComputePtrList forceComputeList
Definition: Patch.h:240
Box< Patch, GBReal > * registerDEdaSumDeposit(Compute *cid)
Definition: Patch.C:204
Box< Patch, CompAtom > * registerAvgPositionPickup(Compute *cid)
Definition: Patch.C:134
ComputePtrList dHdrPrefixComputeList
Definition: Patch.h:232
int firstHoldableCompute
Definition: Patch.h:211
RealList intRad
Definition: Patch.h:155
int computesSortedByPriority
Definition: Patch.h:210
void unregisterAvgPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:140
ComputePtrList dEdaSumComputeList
Definition: Patch.h:230
OwnerBox< Patch, Results > forceBox
Definition: Patch.h:239
ComputePtrList psiSumComputeList
Definition: Patch.h:226
void unregisterPsiSumDeposit(Compute *cid, Box< Patch, GBReal > **const box)
Definition: Patch.C:174
void dHdrPrefixBoxClosed(void)
Definition: Patch.C:391
Lattice & lattice
Definition: Patch.h:126
int getNumFixedAtoms()
Definition: Patch.h:112
CompAtom * velocityPtrEnd
Definition: Patch.h:202
SortedArray< Compute * > ComputePtrList
Definition: Patch.h:23
OwnerBox< Patch, Real > bornRadBox
Definition: Patch.h:227
void unregisterForceDeposit(Compute *cid, Box< Patch, Results > **const box)
Definition: Patch.C:239
OwnerBox< Patch, int > lcpoTypeBox
Definition: Patch.h:236
void unregisterDHdrPrefixPickup(Compute *cid, Box< Patch, Real > **const box)
Definition: Patch.C:222
CompAtom * avgPositionPtrEnd
Definition: Patch.h:198
RealList dHdrPrefix
Definition: Patch.h:159
ComputePtrList lcpoTypeComputeList
Definition: Patch.h:237
void positionsReady(int n=0)
Definition: Patch.C:402
CompAtomList v
Definition: Patch.h:149
Box< Patch, Real > * registerBornRadPickup(Compute *cid)
Definition: Patch.C:196
GBRealList psiFin
Definition: Patch.h:157
void dEdaSumBoxClosed(void)
Definition: Patch.C:387
Box< Patch, int > * registerLcpoTypePickup(Compute *cid)
Definition: Patch.C:188
CudaAtom * cudaAtomPtr
Definition: Patch.h:205
void forceBoxClosed(void)
Definition: Patch.C:253
ComputePtrList avgPositionComputeList
Definition: Patch.h:216
AtomMapper * atomMapper
Definition: Patch.h:152
GBRealList dEdaSum
Definition: Patch.h:160
Definition: Patch.h:35
Flags flags
Definition: Patch.h:127
Patch(PatchID pd)
Definition: Patch.C:45
Box< Patch, GBReal > * registerPsiSumDeposit(Compute *cid)
Definition: Patch.C:164
CudaAtom * getCudaAtomList()
Definition: Patch.h:124
int boxesOpen
Definition: Patch.h:243
OwnerBox< Patch, CompAtom > avgPositionBox
Definition: Patch.h:215
int getNumComputes()
Definition: Patch.h:115
IntList lcpoType
Definition: Patch.h:164
GBRealList psiSum
Definition: Patch.h:156
void gbisP2Ready()
Definition: Patch.C:569
int numFixedAtoms
Definition: Patch.h:145
Box< Patch, Real > * registerIntRadPickup(Compute *cid)
Definition: Patch.C:179
OwnerBox< Patch, CompAtom > positionBox
Definition: Patch.h:213
CompAtomList p_avg
Definition: Patch.h:147
CompAtomList p
Definition: Patch.h:146
int numAtoms
Definition: Patch.h:144
void setNumFixedAtoms(int numFixed)
Definition: Patch.h:113
void lcpoTypeBoxClosed(void)
Definition: Patch.C:398
int PatchID
Definition: NamdTypes.h:182
CompAtom * avgPositionPtrBegin
Definition: Patch.h:197
void gbisP3Ready()
Definition: Patch.C:586
int hasNewAtoms()
Definition: Patch.h:40
OwnerBox< Patch, CompAtom > velocityBox
Definition: Patch.h:218
ComputePtrList intRadComputeList
Definition: Patch.h:224
void unregisterBornRadPickup(Compute *cid, Box< Patch, Real > **const box)
Definition: Patch.C:199
ComputePtrList positionComputeList
Definition: Patch.h:214
OwnerBox< Patch, Real > intRadBox
Definition: Patch.h:223
void unregisterPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:122
PatchID getPatchID()
Definition: Patch.h:114
OwnerBox< Patch, Real > dHdrPrefixBox
Definition: Patch.h:231
RealList bornRad
Definition: Patch.h:158
const PatchID patchID
Definition: Patch.h:143
int _hasNewAtoms
Definition: Patch.h:245
OwnerBox< Patch, GBReal > dEdaSumBox
Definition: Patch.h:229
void unregisterIntRadPickup(Compute *cid, Box< Patch, Real > **const box)
Definition: Patch.C:182
Box< Patch, Real > * registerDHdrPrefixPickup(Compute *cid)
Definition: Patch.C:218
int getNumAtoms()
Definition: Patch.h:105
int * child
Definition: Patch.h:262
void bornRadBoxClosed(void)
Definition: Patch.C:383
void positionBoxClosed(void)
Definition: Patch.C:247
void unregisterVelocityPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:154
Results results
Definition: Patch.h:208
int size(void) const
Definition: ResizeArray.h:127
void avgPositionBoxClosed(void)
Definition: Patch.C:358
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
void velocityBoxClosed(void)
Definition: Patch.C:365
ComputePtrList velocityComputeList
Definition: Patch.h:219
int nChild
Definition: Patch.h:263
CompAtomExtList pExt
Definition: Patch.h:174
void unregisterDEdaSumDeposit(Compute *cid, Box< Patch, GBReal > **const box)
Definition: Patch.C:212
OwnerBox< Patch, GBReal > psiSumBox
Definition: Patch.h:225
void intRadBoxClosed(void)
Definition: Patch.C:379
ComputePtrList bornRadComputeList
Definition: Patch.h:228
void psiSumBoxClosed(void)
Definition: Patch.C:376
Box< Patch, CompAtom > * registerVelocityPickup(Compute *cid)
Definition: Patch.C:148
virtual ~Patch()
Definition: Patch.C:38
void unregisterLcpoTypePickup(Compute *cid, Box< Patch, int > **const box)
Definition: Patch.C:191
virtual void boxClosed(int)=0
Box< Patch, CompAtom > * registerPositionPickup(Compute *cid)
Definition: Patch.C:107
CompAtom * velocityPtrBegin
Definition: Patch.h:201
CompAtomExt * getCompAtomExtInfo()
Definition: Patch.h:117
iterator begin(void)
Definition: ResizeArray.h:36
Box< Patch, Results > * registerForceDeposit(Compute *cid)
Definition: Patch.C:228