NAMD
ComputeGroupRestraintsCUDA.h
Go to the documentation of this file.
1 #ifndef COMPUTE_GROUP_RESTRAINTS_H
2 #define COMPUTE_GROUP_RESTRAINTS_H
3 
4 #ifdef NAMD_CUDA
5 #include <cuda.h>
6 #endif
7 
8 #include <vector>
9 #include "PatchMap.h"
10 #include "AtomMap.h"
11 #include "CudaUtils.h"
12 #include "Lattice.h"
13 #include "GroupRestraintsParam.h"
14 #include "HipDefines.h"
15 
16 #if defined NAMD_CUDA || defined NAMD_HIP
17 
18 #ifdef NODEGROUP_FORCE_REGISTER
19 
22 class GroupRestraintsCUDA {
23 public:
24  GroupRestraintsCUDA(const GroupRestraintParam *param);
25 
26  ~GroupRestraintsCUDA();
27 
29  void updateAtoms(std::vector<AtomMap*> &atomMapsList,
30  std::vector<CudaLocalRecord> &localRecords,
31  const int *h_globalToLocalID);
32 
34  void doForce(
35  const int timeStep,
36  const int doEnergy,
37  const int doVirial,
38  const int doOutput,
39  const Lattice &lat,
40  const char3* d_transform,
41  const float* d_mass,
42  const double* d_pos_x,
43  const double* d_pos_y,
44  const double* d_pos_z,
45  double* d_f_normal_x,
46  double* d_f_normal_y,
47  double* d_f_normal_z,
48  cudaTensor* d_virial,
49  double* h_extEnergy,
50  double3* h_extForce,
51  cudaTensor* h_extVirial,
52  cudaStream_t stream);
53 
54  private:
55  bool calcGroup1COM;
56  bool useDistMagnitude;
57  const char *groupName;
58  int restraintExp;
59  double restraintK;
60  double inv_group1_mass;
61  double inv_group2_mass;
62  double3 resDirection;
63  double3 resCenterVec;
65  double3* h_diffCOM;
66  double3* h_group1COM;
67  double3* h_group2COM;
68  double3* d_group1COM;
69  double3* d_group2COM;
70  double3* h_resForce;
71  double* h_resEnergy;
74  std::vector<HomePatch*> *patchList;
75  std::vector<int> groupAtomsSOAIndex;
76  int* d_groupAtomsSOAIndex;
77  int numRestrainedGroup1;
78  int numRestrainedGroup2;
79  int totalNumRestrained;
80  const GroupRestraintParam *resParam;
82  unsigned int* d_tbcatomic;
84 };
85 
88 class ComputeGroupRestraintsCUDA {
89 public:
90 
91  ComputeGroupRestraintsCUDA(const int ouputFreq,
92  const GroupRestraintList &resList);
93 
94  ~ComputeGroupRestraintsCUDA();
95 
97  void updateAtoms(std::vector<AtomMap*> &atomMapsList,
98  std::vector<CudaLocalRecord> &localRecords,
99  const int *h_globalToLocalID);
100 
102  void doForce(
103  const int timeStep,
104  const int doEnergy,
105  const int doVirial,
106  const Lattice &lat,
107  const char3* d_transform,
108  const float* d_mass,
109  const double* d_pos_x,
110  const double* d_pos_y,
111  const double* d_pos_z,
112  double* d_f_normal_x,
113  double* d_f_normal_y,
114  double* d_f_normal_z,
115  cudaTensor* d_virial,
116  double* h_extEnergy,
117  double3* h_extForce,
118  cudaTensor* h_extVirial,
119  cudaStream_t stream);
120 
121 private:
122  int gResOutputFreq;
124  std::vector<GroupRestraintsCUDA*> restraintsCUDAList;
125 };
126 
127 #endif // NODEGROUP_FORCE_REGISTER
128 
129 #endif // NAMD_CUDA
130 
131 #endif // COMPUTE_GROUP_RESTRAINTS_H