NAMD
NamdTypes.h
Go to the documentation of this file.
1 
7 #ifndef NAMDTYPES_H
8 
9 #define NAMDTYPES_H
10 
11 #include "common.h"
12 #include "Vector.h"
13 #ifndef __CUDACC__
14 #include "ResizeArray.h"
15 #endif
16 
17 class Patch;
18 class Compute;
19 
20 typedef Vector Position;
21 typedef Vector Velocity;
22 
23 //#ifdef ARCH_POWERPC
24 //typedef AlignVector Force;
25 //#else
26 typedef Vector Force;
27 //#endif
28 
29 typedef int AtomID;
30 typedef int AtomType;
31 typedef float Mass;
32 typedef float Charge;
33 
34 typedef double Coordinate;
35 
36 struct Transform
37 {
38  signed char i,j,k;
39  Transform(void) { i=0; j=0; k=0; }
40 };
41 
42 /*
43  * 1. "position" field in this structure is very important since it
44  * needs to be sent to every patch after every timestep.
45  * 2. Anything that is static (value is decided before computation)
46  * or only changes after atom migration should be put into the CompAtomExt structure
47  * 3. This data structure is 32-byte long which is particularly optimized for some machines
48  * (including BG/L) for better cache and message performance. Therefore, changes
49  * to this structure should be cautioned for the sake of performance.
50  */
51 
52 struct CompAtom {
55  short vdwType;
56  unsigned char partition;
57  unsigned int nonbondedGroupSize : 3;
58  unsigned int hydrogenGroupSize : 4; // could be 3 if unsigned
59  unsigned int isWater : 1; // 0 = particle is not in water, 1 = is in water
60 };
61 
62 #ifdef NAMD_KNL
63 struct CompAtomFlt {
64  FloatVector position;
65  int32 vdwType;
66 };
67 #endif
68 
69 //CompAtomExt is now needed even in normal case
70 //for changing the packed msg type related to
71 //ProxyPatch into varsize msg type where
72 // two types of proxy msgs (originally, the msg
73 // for the step where atoms migrate (ProxyAllMsg),
74 // and the msg for normal steps (ProxyDataMsg))
75 // are declared as the same class (ProxyDataMsg).
76 // Note that in normal case, the class is needed
77 // just for passing the compilation, but not involved
78 // in the actual force calculation.
79 // --Chao Mei
80 
81 typedef int SigIndex;
82 typedef int AtomSigID;
83 typedef int ExclSigID;
84 
85 struct CompAtomExt {
86  #if defined(NAMD_CUDA) || defined(NAMD_MIC) || defined(NAMD_AVXTILES)
87  int sortOrder; // used to reorder atoms for CUDA
88  #endif
89  #ifdef MEM_OPT_VERSION
90  int id;
91  ExclSigID exclId;
92  int sigId : 30; // AtomSigID sigId;
93  #else
94  int id : 30; // minimum for 100M atoms is 28 signed, 27 unsigned
95  #endif
96  unsigned int atomFixed : 1;
97  unsigned int groupFixed : 1;
98 };
99 
103  double recipMass;
109  union{
111 #ifdef MEM_OPT_VERSION
112  int hydVal;
113 #endif
114  };
119 
120 #ifdef MEM_OPT_VERSION
121  int outputRank;
122 #endif
123 
124 #ifdef MEM_OPT_VERSION
125  //a HACK to re-sort FullAtom list used in Parallel IO
126  //When every home patch processor receives its atoms list for a patch,
127  //the atoms inside this patch may not sorted according to hydList value
128  //To save space, use anonymous union data structure to share the space
129  //of "langevinParam" to store "hydList" from an InputAtom and then sort the
130  //atom list. The "langevinParam" value is not initialized until home
131  //patch creation -Chao Mei
132  int operator < (const FullAtom &a) const {
133  return hydVal < a.hydVal;
134  }
135 #endif
136 };
137 
138 //InputAtom is used to contain the info of the atoms
139 //loaded into input processors.
141  bool isValid;
142  short isGP;
143  short isMP;
144  int hydList;
145  int GPID;
146  int MPID;
147 
148  int operator < (const InputAtom &a) const{
149  return hydList < a.hydList;
150  }
151 };
152 
153 struct CudaAtom {
154  float x,y,z,q;
155 };
156 
157 struct CudaForce {
158  float x, y, z;
159 };
160 
161 #ifndef __CUDACC__
165 #ifdef NAMD_KNL
166 typedef ResizeArray<CompAtomFlt> CompAtomFltList;
167 #endif
174 
178 typedef float GBReal;
181 
182 typedef int PatchID;
183 typedef int ComputeID;
184 typedef int NodeID;
185 
188 
190 
191 // See AtomMap
192 struct LocalID
193 {
195  int index;
196 };
197 
199 
200 struct ExtForce {
201  int replace;
203  ExtForce() : replace(0) {;}
204 };
205 
206 
207 // DMK - Atom Sort
208 #if NAMD_ComputeNonbonded_SortAtoms != 0
209 
210  typedef struct __sort_entry {
211  int index; // Index of atom in CompAtom array
212  BigReal sortValue; // Distance of PAp from P0 (see calculation code)
213  } SortEntry;
214 
215 #endif
216 
217 //This class represents a tree node of proxy spanning tree
218 //All pes in this array have the same "nodeID". In other words,
219 //all those pes are in the same physical node.
220 //This is a structure for adapting NAMD to multicore processors
222  int nodeID;
223  int *peIDs;
224  int numPes;
225 
227  nodeID = -1;
228  peIDs = NULL;
229  numPes = 0;
230  }
231  proxyTreeNode(int nid, int numPes_, int *pes){
232  nodeID = nid;
233  numPes = numPes_;
234  peIDs = new int[numPes];
235  memcpy(peIDs, pes, sizeof(int)*numPes);
236  }
237 
238  inline proxyTreeNode(const proxyTreeNode &n){
239  nodeID = n.nodeID;
240  numPes = n.numPes;
241  if(numPes==0) {
242  peIDs = NULL;
243  }else{
244  peIDs = new int[n.numPes];
245  memcpy(peIDs, n.peIDs, sizeof(int)*numPes);
246  }
247  }
249  nodeID = n.nodeID;
250  numPes = n.numPes;
251  delete [] peIDs;
252  if(numPes==0) {
253  peIDs = NULL;
254  return (*this);
255  }
256  peIDs = new int[n.numPes];
257  memcpy(peIDs, n.peIDs, sizeof(int)*numPes);
258  return (*this);
259  }
261  delete [] peIDs;
262  }
263 };
264 
266 #endif // __CUDACC__
267 
268 
269 //
270 // When defined, use NVTX to record CPU activity into CUDA profiling run.
271 //
272 #undef PUSH_RANGE
273 #undef POP_RANGE
274 #undef RANGE
275 
276 #if defined(NAMD_CUDA) && defined(NAMD_USE_NVTX)
277 
278 #include <nvToolsExt.h>
279 
280 // C++ note: declaring const variables implies static (internal) linkage,
281 // and you have to explicitly specify "extern" to get external linkage.
282 const uint32_t NAMD_nvtx_colors[] = {
283  0x0000ff00,
284  0x000000ff,
285  0x00ffff00,
286  0x00ff00ff,
287  0x0000ffff,
288  0x00ff0000,
289  0x00ffffff,
290 };
291 const int NAMD_nvtx_colors_len = sizeof(NAMD_nvtx_colors)/sizeof(uint32_t);
292 
293 // start recording an event
294 #define PUSH_RANGE(name,cid) \
295  do { \
296  int color_id = cid; \
297  color_id = color_id % NAMD_nvtx_colors_len; \
298  nvtxEventAttributes_t eventAttrib = {0}; \
299  eventAttrib.version = NVTX_VERSION; \
300  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; \
301  eventAttrib.colorType = NVTX_COLOR_ARGB; \
302  eventAttrib.color = NAMD_nvtx_colors[color_id]; \
303  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; \
304  eventAttrib.message.ascii = name; \
305  nvtxRangePushEx(&eventAttrib); \
306  } while(0) // must terminate with semi-colon
307 
308 // stop recording an event
309 #define POP_RANGE \
310  nvtxRangePop()
311  // must terminate with semi-colon
312 
313 // embed event recording in class to automatically pop when destroyed
314 class NAMD_NVTX_Tracer {
315  public:
316  NAMD_NVTX_Tracer(const char *name, int cid = 0) { PUSH_RANGE(name, cid); }
317  ~NAMD_NVTX_Tracer() { POP_RANGE; }
318 };
319 
320 // include cid as part of the name
321 // call RANGE at beginning of function to push event recording
322 // destructor is automatically called on return to pop event recording
323 #define RANGE(name,cid) \
324  NAMD_NVTX_Tracer namd_nvtx_tracer##cid(name,cid)
325  // must terminate with semi-colon
326 
327 #else
328 
329 //
330 // Otherwise the NVTX profiling macros become no-ops.
331 //
332 #define PUSH_RANGE(name,cid) do { } while(0) // must terminate with semi-colon
333 #define POP_RANGE do { } while(0) // must terminate with semi-colon
334 #define RANGE(namd,cid) do { } while(0) // must terminate with semi-colon
335 
336 #endif // NAMD_CUDA && NAMD_USE_NVTX
337 
338 
339 #endif /* NAMDTYPES_H */
340 
ResizeArray< GBReal > GBRealList
Definition: NamdTypes.h:179
unsigned char partition
Definition: NamdTypes.h:56
Real langevinParam
Definition: NamdTypes.h:110
int hydList
Definition: NamdTypes.h:144
signed char j
Definition: NamdTypes.h:38
float q
Definition: NamdTypes.h:154
ResizeArray< Real > RealList
Definition: NamdTypes.h:177
signed char i
Definition: NamdTypes.h:38
int sortOrder
Definition: NamdTypes.h:87
unsigned int hydrogenGroupSize
Definition: NamdTypes.h:58
short int32
Definition: dumpdcd.c:24
int ComputeID
Definition: NamdTypes.h:183
int AtomID
Definition: NamdTypes.h:29
int index
Definition: NamdTypes.h:211
unsigned int atomFixed
Definition: NamdTypes.h:96
ResizeArray< CudaAtom > CudaAtomList
Definition: NamdTypes.h:162
Vector Force
Definition: NamdTypes.h:26
Position fixedPosition
Definition: NamdTypes.h:102
proxyTreeNode & operator=(const proxyTreeNode &n)
Definition: NamdTypes.h:248
ResizeArray< PatchID > PatchIDList
Definition: NamdTypes.h:186
Definition: Vector.h:64
float z
Definition: NamdTypes.h:154
Definition: NamdTypes.h:210
float Real
Definition: common.h:107
float x
Definition: NamdTypes.h:158
float x
Definition: NamdTypes.h:154
Position position
Definition: NamdTypes.h:53
int replace
Definition: NamdTypes.h:201
int ExclSigID
Definition: NamdTypes.h:83
Velocity velocity
Definition: NamdTypes.h:101
unsigned int groupFixed
Definition: NamdTypes.h:97
int AtomSigID
Definition: NamdTypes.h:82
short isGP
Definition: NamdTypes.h:142
Transform(void)
Definition: NamdTypes.h:39
Definition: Patch.h:35
unsigned int isWater
Definition: NamdTypes.h:59
int operator<(const InputAtom &a) const
Definition: NamdTypes.h:148
ResizeArray< Force > ForceList
Definition: NamdTypes.h:172
Charge charge
Definition: NamdTypes.h:54
ResizeArray< Velocity > VelocityList
Definition: NamdTypes.h:171
signed char k
Definition: NamdTypes.h:38
ResizeArray< Position > PositionList
Definition: NamdTypes.h:170
ResizeArray< BigReal > BigRealList
Definition: NamdTypes.h:176
proxyTreeNode(const proxyTreeNode &n)
Definition: NamdTypes.h:238
int index
Definition: NamdTypes.h:195
bool isValid
Definition: NamdTypes.h:141
double Coordinate
Definition: NamdTypes.h:34
BigReal sortValue
Definition: NamdTypes.h:212
ResizeArray< FullAtom > FullAtomList
Definition: NamdTypes.h:168
short isMP
Definition: NamdTypes.h:143
ResizeArray< Transform > TransformList
Definition: NamdTypes.h:173
Vector Position
Definition: NamdTypes.h:18
struct __sort_entry SortEntry
float z
Definition: NamdTypes.h:158
int PatchID
Definition: NamdTypes.h:182
Force force
Definition: NamdTypes.h:202
PatchID pid
Definition: NamdTypes.h:194
bool operator<(const intpair &lhs, const intpair &rhs)
Definition: ComputeGlobal.h:29
ResizeArray< Compute * > ComputeList
Definition: NamdTypes.h:189
ResizeArray< AtomID > AtomIDList
Definition: NamdTypes.h:175
int AtomType
Definition: NamdTypes.h:30
ExtForce()
Definition: NamdTypes.h:203
int migrationGroupSize
Definition: NamdTypes.h:117
int32 status
Definition: NamdTypes.h:115
float y
Definition: NamdTypes.h:154
ResizeArray< proxyTreeNode > proxyTreeNodeList
Definition: NamdTypes.h:265
Vector Velocity
Definition: NamdTypes.h:21
Real rigidBondLength
Definition: NamdTypes.h:118
#define PUSH_RANGE(name, cid)
Definition: NamdTypes.h:332
int SigIndex
Definition: NamdTypes.h:81
proxyTreeNode(int nid, int numPes_, int *pes)
Definition: NamdTypes.h:231
short vdwType
Definition: NamdTypes.h:55
ResizeArray< CompAtom > CompAtomList
Definition: NamdTypes.h:163
ResizeArray< CompAtomExt > CompAtomExtList
Definition: NamdTypes.h:164
Mass mass
Definition: NamdTypes.h:108
int MPID
Definition: NamdTypes.h:146
ResizeArray< Patch * > PatchList
Definition: NamdTypes.h:187
float Mass
Definition: ComputeGBIS.inl:20
float y
Definition: NamdTypes.h:158
ResizeArray< int > IntList
Definition: NamdTypes.h:180
unsigned int nonbondedGroupSize
Definition: NamdTypes.h:57
double recipMass
Definition: NamdTypes.h:103
int NodeID
Definition: NamdTypes.h:184
float Charge
Definition: NamdTypes.h:32
int GPID
Definition: NamdTypes.h:145
ResizeArray< InputAtom > InputAtomList
Definition: NamdTypes.h:169
double BigReal
Definition: common.h:112
Transform transform
Definition: NamdTypes.h:116
float GBReal
Definition: ComputeGBIS.inl:17
ResizeArray< NodeID > NodeIDList
Definition: NamdTypes.h:198
#define POP_RANGE
Definition: NamdTypes.h:333