NAMD
ComputeConsForceCUDA.h
Go to the documentation of this file.
1 #ifndef COMPUTECONSFORCECUDA_H
2 #define COMPUTECONSFORCECUDA_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 
20 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
21 #ifdef NODEGROUP_FORCE_REGISTER
22 
23 class ComputeConsForceCUDA {
24 public:
25  ComputeConsForceCUDA(
26  std::vector<HomePatch*> &patchList,
27  std::vector<AtomMap*> &atomMapList,
28  bool mGpuOn
29  );
30 
31  void updateConsForceAtoms(
32  std::vector<AtomMap*> &atomMapsLists,
33  std::vector<CudaLocalRecord> &localRecords,
34  const int* h_globalToLocalID
35  );
36 
37  ~ComputeConsForceCUDA();
38 
39  void doForce( const Lattice lat,
40  bool doVirial,
41  double* d_pos_x,
42  double* d_pos_y,
43  double* d_pos_z,
44  double* f_normal_x,
45  double* f_normal_y,
46  double* f_normal_z,
47  char3* d_transform,
48  double3* d_netForce,
49  double3* h_netForce,
50  cudaTensor* d_virial,
51  cudaTensor* h_virial,
52  cudaStream_t stream
53  );
54 private:
55  int nConsForceAtoms;
56  bool mGpuOn;
57  bool resetVirial;
58  std::vector<double3> h_consForce;
59  std::vector<int> h_consForceID;
60  std::vector<int> h_consForceSOA;
61  std::vector<int> consForceLocalAtomsIndex;
62  std::map<int,int> consAtomsIndexMap;
63  int* d_consForceID;
64  int* d_consForceSOA;
65  double3* d_consForce;
66  unsigned int* d_tbcatomic;
68 };
69 
70 #endif
71 #endif
72 #endif