NAMD
CudaRecord.h
Go to the documentation of this file.
1 #ifndef CUDARECORD_H
2 #define CUDARECORD_H
3 
4 #ifdef NAMD_CUDA
5 #include <cuda.h>
6 #include <cuda_runtime.h>
7 #endif
8 #ifdef NAMD_HIP
9 #include <hip/hip_runtime.h>
10 #endif
11 
12 #include "HipDefines.h"
13 
14 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
15 struct PatchRecord {
16  int atomStart;
17  int numAtoms;
18  int patchID;
19 };
20 
25  int bufferOffsetNBPad; // Buffer offset with nonbonded padding
26 };
27 // 16 bytes
28 
29 // Cuda Local Record should be 128 bytes so it can be loaded in a single cache line
30 // inline_peers are used to avoid another level of redirection. However, we'll maintain
31 // the array of CudaPeerRecords anyways to handle cases when a HomePatch has more than
32 // 6 proxies. David Clark doesn't think this will happen, but a patch can technically have
33 // 13 proxies given we are only looking 1 patch away and taking adcantage of upstream/downstream
34 // logic
36  static constexpr int num_inline_peer = 5;
37  int patchID;
39  int bufferOffsetNBPad; // Buffer offset with nonbonded padding
40  int numAtoms;
41  int numAtomsNBPad; // Atom count including the nonbonded padding
42  int isProxy; // Indicates if this local record represent a proxy or home patch
43  int numPeerRecord; // The number of CudaPeerRecords corresponding to this patch
45  // These four fields are used during GPU atom migration to keep track
50  // These are used to pad the CudaLocalRecord to 128 bytes and avoid a global memory lookup
52 };
53 
54 static_assert(sizeof(CudaLocalRecord) == 128, "CudaLocalRecord must be 128 bytes");
55 
56 #endif // NAMD_CUDA
57 
58 struct CudaAtom {
59  float x,y,z,q;
60 };
61 
62 struct CudaForce {
63  float x, y, z;
64 };
65 
66 #endif //CUDARECORD_H
float q
Definition: CudaRecord.h:59
int numAtoms
Definition: CudaRecord.h:17
float z
Definition: CudaRecord.h:59
int peerRecordStartIndex
Definition: CudaRecord.h:44
float x
Definition: CudaRecord.h:63
float x
Definition: CudaRecord.h:59
float z
Definition: CudaRecord.h:63
int bufferOffsetNBPad
Definition: CudaRecord.h:25
int numMigrationGroups
Definition: CudaRecord.h:47
float y
Definition: CudaRecord.h:59
static constexpr int num_inline_peer
Definition: CudaRecord.h:36
CudaPeerRecord inline_peers[num_inline_peer]
Definition: CudaRecord.h:51
int bufferOffsetNBPad
Definition: CudaRecord.h:39
float y
Definition: CudaRecord.h:63
int atomStart
Definition: CudaRecord.h:16