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, int startup=1);
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() const { return numAtoms; }
106 
107  // DMK - Atom Separation (water vs. non-water)
108  #if NAMD_SeparateWaters != 0
109  int getNumWaterAtoms() const { return numWaterAtoms; }
110  #endif
111 
112  int getNumFixedAtoms() const { return numFixedAtoms; } // not updated
113  void setNumFixedAtoms(int numFixed) { numFixedAtoms=numFixed; } // not updated
114  PatchID getPatchID() const { return patchID; }
115  int getNumComputes() const { return positionComputeList.size(); }
116 
118  CompAtom* getCompAtomInfo() {return p.begin(); }
119 #ifdef NAMD_KNL
120  CompAtomFlt* getCompAtomFlt() { return pFlt.begin(); }
121 #endif
122 #ifdef NAMD_AVXTILES
123  AVXTiles* getTiles() { return &tiles; }
124 #endif
126 
129 
130  // DMK - NOTE : Just placing the variables in public for now so only one location, move to protected if this actually helps performance
131  #if defined(NAMD_MIC) // NOTE: Used for submit atoms on arrival
132  pthread_mutex_t mic_atomData_mutex;
133  void* mic_atomData;
134  void* mic_atomData_prev[MIC_MAX_DEVICES_PER_NODE];
135  int mic_atomData_seq;
136  int mic_atomData_deviceSeq[MIC_MAX_DEVICES_PER_NODE];
137  uint64_t mic_atomData_devicePtr[MIC_MAX_DEVICES_PER_NODE];
138  int mic_atomData_allocSize_host;
139  int mic_atomData_allocSize_device[MIC_MAX_DEVICES_PER_NODE];
140  #endif
141 
142 #if defined(NODEGROUP_FORCE_REGISTER)
143  int nbond_compute_position;
144  int bond_compute_position;
145  int slow_compute_position;
146 #endif
147 
148  protected:
149 
151  int numAtoms;
155  // BEGIN LA
157  // END LA
158 
160 
161  // begin gbis
168  // end gbis
169 
170  //LCPO
172 
173  // DMK - Atom Separation (water vs. non-water)
174  #if NAMD_SeparateWaters != 0
175  int numWaterAtoms; // Set numWaters to the number of water atoms at
176  // the lead of the atoms list. If numWaters is
177  // set to -1, this should indicate that
178  // atoms has not been separated yet.
179  #endif
180 
182 #ifdef NAMD_KNL
183  CompAtomFltList pFlt;
184 #endif
185 #ifdef NAMD_AVXTILES
186  AVXTiles tiles;
187 #endif
188 
189 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
190  //1. Those fields are declared for reusing position info
191  //inside the ProxyDataMsg msg at every step so that the
192  //extra copy is avoided.
193  //Regarding the CompAtomExt list inside the msg of ProxyAllMsg type
194  //we cannot avoid the copy in the current scheme because this information
195  //will be lost as the msg will be deleted at the next timestep. But the
196  //overhead is amortized among the steps that atoms don't migrate
197  //2. positionPtrBegin is better to be made 32-byte aligned so we could
198  // have better cache performance in the force calculation part. This
199  // is especially needed for BG/L machine.
200  // --Chao Mei
201  CompAtom *positionPtrBegin;
202  CompAtom *positionPtrEnd;
203 #endif
206 
207  // BEGIN LA
210  // END LA
211 
213 
216 
219 
224  // BEGIN LA
227  // END LA
228 
229  //begin gbis
240  //end gbis
241 
242  //LCPO
245 
248 
249  virtual void boxClosed(int /* box */) = 0;
251 
253 
254 #ifdef NODEAWARE_PROXY_SPANNINGTREE
255  //its own children in proxy tree
256  #ifdef USE_NODEPATCHMGR
257  //the immediate children (in terms of node id) also cotains two parts
258  //as the above variable shows
259  //If this patch has proxies residing on the same node, then the last entry
260  //of "nodeChildren" stores this node id. It is same with that variable
261  //in ProxyPatch
262  //If this proxy resides on node A, then the last entry
263  //of "nodeChildren" has to be A
264  //It is same with that variable in HomePatch
265  int *nodeChildren;
266  int numNodeChild;
267  #endif
268 #endif
269  int *child;
270  int nChild;
271 
272  private:
273 
274  SubmitReduction *reduction;
275 
276 };
277 
278 
279 #endif
280 
ComputePtrList forceComputeList
Definition: Patch.h:247
Box< Patch, GBReal > * registerDEdaSumDeposit(Compute *cid)
Definition: Patch.C:203
Box< Patch, CompAtom > * registerAvgPositionPickup(Compute *cid)
Definition: Patch.C:133
ComputePtrList dHdrPrefixComputeList
Definition: Patch.h:239
int getNumAtoms() const
Definition: Patch.h:105
int firstHoldableCompute
Definition: Patch.h:218
int getNumFixedAtoms() const
Definition: Patch.h:112
int size(void) const
Definition: ResizeArray.h:131
RealList intRad
Definition: Patch.h:162
int computesSortedByPriority
Definition: Patch.h:217
void unregisterAvgPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:139
ComputePtrList dEdaSumComputeList
Definition: Patch.h:237
OwnerBox< Patch, Results > forceBox
Definition: Patch.h:246
ComputePtrList psiSumComputeList
Definition: Patch.h:233
void unregisterPsiSumDeposit(Compute *cid, Box< Patch, GBReal > **const box)
Definition: Patch.C:173
void dHdrPrefixBoxClosed(void)
Definition: Patch.C:392
Lattice & lattice
Definition: Patch.h:127
CompAtom * velocityPtrEnd
Definition: Patch.h:209
SortedArray< Compute * > ComputePtrList
Definition: Patch.h:23
OwnerBox< Patch, Real > bornRadBox
Definition: Patch.h:234
void unregisterForceDeposit(Compute *cid, Box< Patch, Results > **const box)
Definition: Patch.C:238
OwnerBox< Patch, int > lcpoTypeBox
Definition: Patch.h:243
void unregisterDHdrPrefixPickup(Compute *cid, Box< Patch, Real > **const box)
Definition: Patch.C:221
CompAtom * avgPositionPtrEnd
Definition: Patch.h:205
RealList dHdrPrefix
Definition: Patch.h:166
ComputePtrList lcpoTypeComputeList
Definition: Patch.h:244
CompAtomList v
Definition: Patch.h:156
Box< Patch, Real > * registerBornRadPickup(Compute *cid)
Definition: Patch.C:195
GBRealList psiFin
Definition: Patch.h:164
void dEdaSumBoxClosed(void)
Definition: Patch.C:388
Box< Patch, int > * registerLcpoTypePickup(Compute *cid)
Definition: Patch.C:187
CudaAtom * cudaAtomPtr
Definition: Patch.h:212
void forceBoxClosed(void)
Definition: Patch.C:252
ComputePtrList avgPositionComputeList
Definition: Patch.h:223
AtomMapper * atomMapper
Definition: Patch.h:159
GBRealList dEdaSum
Definition: Patch.h:167
Definition: Patch.h:35
Flags flags
Definition: Patch.h:128
Patch(PatchID pd)
Definition: Patch.C:44
Box< Patch, GBReal > * registerPsiSumDeposit(Compute *cid)
Definition: Patch.C:163
CudaAtom * getCudaAtomList()
Definition: Patch.h:125
int boxesOpen
Definition: Patch.h:250
OwnerBox< Patch, CompAtom > avgPositionBox
Definition: Patch.h:222
IntList lcpoType
Definition: Patch.h:171
GBRealList psiSum
Definition: Patch.h:163
void gbisP2Ready()
Definition: Patch.C:598
int numFixedAtoms
Definition: Patch.h:152
Box< Patch, Real > * registerIntRadPickup(Compute *cid)
Definition: Patch.C:178
OwnerBox< Patch, CompAtom > positionBox
Definition: Patch.h:220
CompAtomList p_avg
Definition: Patch.h:154
CompAtomList p
Definition: Patch.h:153
CompAtom * getCompAtomInfo()
Definition: Patch.h:118
int numAtoms
Definition: Patch.h:151
void setNumFixedAtoms(int numFixed)
Definition: Patch.h:113
PatchID getPatchID() const
Definition: Patch.h:114
void lcpoTypeBoxClosed(void)
Definition: Patch.C:399
CompAtom * avgPositionPtrBegin
Definition: Patch.h:204
void gbisP3Ready()
Definition: Patch.C:614
int hasNewAtoms()
Definition: Patch.h:40
OwnerBox< Patch, CompAtom > velocityBox
Definition: Patch.h:225
ComputePtrList intRadComputeList
Definition: Patch.h:231
void unregisterBornRadPickup(Compute *cid, Box< Patch, Real > **const box)
Definition: Patch.C:198
ComputePtrList positionComputeList
Definition: Patch.h:221
OwnerBox< Patch, Real > intRadBox
Definition: Patch.h:230
void unregisterPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:121
OwnerBox< Patch, Real > dHdrPrefixBox
Definition: Patch.h:238
RealList bornRad
Definition: Patch.h:165
iterator begin(void)
Definition: ResizeArray.h:36
const PatchID patchID
Definition: Patch.h:150
int _hasNewAtoms
Definition: Patch.h:252
OwnerBox< Patch, GBReal > dEdaSumBox
Definition: Patch.h:236
void unregisterIntRadPickup(Compute *cid, Box< Patch, Real > **const box)
Definition: Patch.C:181
int getNumComputes() const
Definition: Patch.h:115
Box< Patch, Real > * registerDHdrPrefixPickup(Compute *cid)
Definition: Patch.C:217
int * child
Definition: Patch.h:269
void bornRadBoxClosed(void)
Definition: Patch.C:384
void positionBoxClosed(void)
Definition: Patch.C:246
void unregisterVelocityPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:153
Results results
Definition: Patch.h:215
void avgPositionBoxClosed(void)
Definition: Patch.C:359
ForceList f[Results::maxNumForces]
Definition: Patch.h:214
void velocityBoxClosed(void)
Definition: Patch.C:366
ComputePtrList velocityComputeList
Definition: Patch.h:226
int nChild
Definition: Patch.h:270
int32 PatchID
Definition: NamdTypes.h:277
CompAtomExtList pExt
Definition: Patch.h:181
void positionsReady(int n=0, int startup=1)
Definition: Patch.C:403
void unregisterDEdaSumDeposit(Compute *cid, Box< Patch, GBReal > **const box)
Definition: Patch.C:211
OwnerBox< Patch, GBReal > psiSumBox
Definition: Patch.h:232
void intRadBoxClosed(void)
Definition: Patch.C:380
ComputePtrList bornRadComputeList
Definition: Patch.h:235
void psiSumBoxClosed(void)
Definition: Patch.C:377
Box< Patch, CompAtom > * registerVelocityPickup(Compute *cid)
Definition: Patch.C:147
virtual ~Patch()
Definition: Patch.C:37
void unregisterLcpoTypePickup(Compute *cid, Box< Patch, int > **const box)
Definition: Patch.C:190
virtual void boxClosed(int)=0
Box< Patch, CompAtom > * registerPositionPickup(Compute *cid)
Definition: Patch.C:106
CompAtom * velocityPtrBegin
Definition: Patch.h:208
CompAtomExt * getCompAtomExtInfo()
Definition: Patch.h:117
Box< Patch, Results > * registerForceDeposit(Compute *cid)
Definition: Patch.C:227