NAMD
ComputeSMDCUDA.h
Go to the documentation of this file.
1 #ifndef SMDCUDA_H
2 #define SMDCUDA_H
3 
4 #if defined NAMD_CUDA
5 #include <cuda.h>
6 #endif
7 
8 #include <vector>
9 #include "PatchMap.h"
10 #include "AtomMap.h"
11 #include "Lattice.h"
12 #include "CudaUtils.h"
13 #include "HipDefines.h"
14 #if defined NAMD_CUDA || defined NAMD_HIP
15 #ifdef NODEGROUP_FORCE_REGISTER
16 class ComputeSMDCUDA{
17  public:
18  ComputeSMDCUDA(
19  std::vector<HomePatch*> &patchList,
20  double springConstant,
21  double transverseSpringConstant,
22  double velocity,
23  double3 direction,
24  int outputFrequency,
25  int firsttimestep,
26  const char* filename,
27  bool isMasterDevice,
28  int numAtoms,
29  int numDevices,
30  int deviceIndex,
31  bool mGpuOn);
32 
33  ~ComputeSMDCUDA();
34  void outputCOM(std::string);
35  void dump(std::string, const int step, const int numAtoms, const double*, const double*, const double*, const float*);
36  void updateAtoms(
37  std::vector<AtomMap*> &atomMapsList,
38  std::vector<CudaLocalRecord> &localRecords,
39  const int* h_globalToLocalID);
40  void computeCOMMGpu(
41  const Lattice lat,
42  const float * d_mass,
43  const double* d_pos_x,
44  const double* d_pos_y,
45  const double* d_pos_z,
46  const char3* d_transform,
47  cudaStream_t stream
48  );
49  void outputStep(const int timeStep, double3* curCOM, double3* extForce);
50  void doForce(
51  const int timeStep,
52  const Lattice &lat,
53  bool doEnergy,
54  const float* d_mass,
55  const double* d_pos_x,
56  const double* d_pos_y,
57  const double* d_pos_z,
58  const char3* d_transform,
59  double* f_normal_x,
60  double* f_normal_y,
61  double* f_normal_z,
62  cudaTensor* d_extVirial,
63  double* h_extEnergy,
64  double3* h_extForce,
65  cudaTensor* h_extVirial,
66  cudaStream_t stream
67  );
68 
69  void initPeerCOM(double3** d_peerPoolCOM, cudaStream_t stream);
70 
71 private:
72  double springConstant;
73  double transverseSpringConstant;
74  double velocity;
75  double inv_group_mass;
76  double3 direction;
77  double3 origCOM;
78  double3* curCOM;
79  double3* d_curCOM;
80  int numDevices;
81  int deviceIndex;
82  std::vector<HomePatch*> *patchList;
83  std::vector<int> smdAtomsGlobalIndex;
84  std::vector<int> smdAtomsSOAIndex;
85  std::map<int,int> smdAtomsSOAtoGlobalLocalMap;
86  int* d_smdAtomsSOAIndex;
87 
88  // JM: SMD needs to handle IO, so I need to have a pointer to the file somehow
89  int firstTimeStep;
90  const char* filename;
91  int outputFrequency;
92  int numAtoms;
93  int numSMDAtoms;
94  bool isMasterDevice;
95  bool mGpuOn;
96  unsigned int* d_tbcatomic;
97  double3* d_peerCOM;
98  double3* h_peerCOM;
99  void parseAtoms();
100 };
101 #endif // NODEGROUP_FORCE_REGISTER
102 
103 #endif // NAMD_CUDA
104 
105 #endif // SMDCUDA_H