NAMD
ComputeRestraintsCUDA.h
Go to the documentation of this file.
1 #ifndef RESTRAINTSCUDA_H
2 #define RESTRAINTSCUDA_H
3 
4 #ifdef NAMD_CUDA
5 #include <cuda.h>
6 #endif
7 #ifdef NAMD_HIP
8 #include <hip/hip_runtime.h>
9 #endif
10 
11 #include <vector>
12 #include "PatchMap.h"
13 #include "AtomMap.h"
14 #include "Lattice.h"
15 #include "CudaUtils.h"
16 #include "CudaRecord.h"
17 #include "HipDefines.h"
18 
19 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
20 #ifdef NODEGROUP_FORCE_REGISTER
21 
22 class ComputeRestraintsCUDA {
23 
24 public:
25  ComputeRestraintsCUDA(
26  std::vector<HomePatch*> &patchList,
27  std::vector<AtomMap*> &atomMapList,
28  cudaStream_t stream,
29  bool mGpuOn
30  );
31 
32  void updateRestrainedAtoms(
33  std::vector<AtomMap*> &atomMapsLists,
34  std::vector<CudaLocalRecord> &localRecords,
35  const int* h_globalToLocalID
36  );
37 
38  ~ComputeRestraintsCUDA();
39 
40  void doForce(
41  const Lattice *lat,
42  const bool doEnergy,
43  const bool doVirial,
44  const int timeStep,
45  double* d_pos_x,
46  double* d_pos_y,
47  double* d_pos_z,
48  double* f_normal_x,
49  double* f_normal_y,
50  double* f_normal_z,
51  double* d_bcEnergy,
52  double* h_bcEnergy,
53  double3* d_netForce,
54  double3* h_netForce,
55  cudaTensor* d_virial,
56  cudaTensor* h_virial
57  );
58 
59 private:
60 
61  int nConstrainedAtoms;
62  bool mGpuOn;
63  int consExp;
64  bool movConsOn;
65  bool rotConsOn;
66  bool selConsOn;
67  bool spheConsOn;
69  bool consSelectX;
70  bool consSelectY;
71  bool consSelectZ;
72  // double consScaling; // always read latest value from SimParameters
73  double rotVel;
74 
75  double3 rotAxis;
76  double3 rotPivot;
77  double3 moveVel;
78  double3 spheConsCenter;
79 
80  cudaTensor rotationMatrix;
81 
82  // This can be only on the host, since
83  std::vector<int> h_constrainedID;
84  std::vector<int> constrainedLocalAtomsIndex;
85  std::map<int,int> constrainedAtomsIndexMap;
86  std::vector<double> h_k;
87  std::vector<double> h_cons_x;
88  std::vector<double> h_cons_y;
89  std::vector<double> h_cons_z;
91  int* h_constrainedSOA;
92  int* d_constrainedSOA; // Device version of h_constrainedSOA
93  int* d_constrainedID; // Device version of h_constrainedID index
94  double* d_cons_x;
95  double* d_cons_y;
96  double* d_cons_z;
97  double* d_k;
99  unsigned int* d_tbcatomic;
101  cudaStream_t stream;
102 };
103 
104 #endif // NODEGROUP_FORCE_REGISTER
105 #endif // NAMD_CUDA
106 #endif // RESTRAINTSCUDA_H
107