-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCudaPMEForcefield.h
191 lines (156 loc) · 5.35 KB
/
CudaPMEForcefield.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#ifndef CUDAPMEFORCEFIELD_H
#define CUDAPMEFORCEFIELD_H
#include "CudaForcefield.h"
#include "cudaXYZ.h"
#include "hostXYZ.h"
#include "XYZQ.h"
#include "CudaPMEDirectForce.h"
#include "CudaBondedForce.h"
#include "CudaPMERecip.h"
#include "CudaDomdec.h"
#include "CudaDomdecGroups.h"
#include "CudaDomdecRecip.h"
#include "CudaDomdecRecipComm.h"
#include "CudaNeighborList.h"
#include "CudaEnergyVirial.h"
class CudaPMEForcefield : public CudaForcefield {
private:
// Reference coordinates for neighborlist building (size ncoord)
cudaXYZ<double> ref_coord;
// true if neighborlist was updated in this call
bool neighborlist_updated;
// flag for checking heuristic neighborlist update
int *d_heuristic_flag;
int *h_heuristic_flag;
// Cut-offs:
double roff, ron;
// Global charge table
float *glo_q;
// Coordinates in XYZQ format (size ncoord_tot)
XYZQ xyzq;
// Coordinates in XYZQ format (size ncoord_tot)
XYZQ xyzq_copy;
// -----------------
// Neighbor list(s)
// -----------------
CudaNeighborList<32> nlist;
// ------------------------
// Direct non-bonded force
// ------------------------
CudaPMEDirectForce<long long int, float> dir;
// Global vdw types
int *glo_vdwtype;
// -------------
// Bonded force
// -------------
CudaBondedForce<long long int, float> bonded;
// -------------------------------
// Energy and virial
// -------------------------------
CudaEnergyVirial& energyVirial;
// -----------------
// Reciprocal force
// -----------------
double kappa;
CudaDomdecRecip* recip;
CudaDomdecRecipComm& recipComm;
XYZQ recip_xyzq;
int recip_force_len;
float3* recip_force;
// ---------------------
// Domain decomposition
// ---------------------
CudaDomdec& domdec;
CudaDomdecGroups& domdecGroups;
// ---------------------
// Energies and virials
// ---------------------
double energy_bond;
double energy_ureyb;
double energy_angle;
double energy_dihe;
double energy_imdihe;
double energy_cmap;
double sforce[27*3];
double energy_vdw;
double energy_elec;
double energy_excl;
double energy_ewksum;
double energy_ewself;
double vir[9];
// ------------------------------
// Streams for force calculation
// ------------------------------
cudaStream_t direct_stream[2];
cudaStream_t recip_stream;
cudaStream_t in14_stream;
cudaStream_t bonded_stream;
// -----------------------------
// Events for force calculation
// -----------------------------
cudaEvent_t done_direct_event[2];
cudaEvent_t done_recip_event;
cudaEvent_t done_in14_event;
cudaEvent_t done_bonded_event;
cudaEvent_t done_calc_event;
cudaEvent_t done_force_clear_event;
cudaEvent_t xyzq_ready_event[2];
cudaEvent_t recip_coord_ready_event;
cudaEvent_t setup_bond_done_event;
cudaEvent_t setup_nonbond_done_event;
cudaEvent_t setup_14_done_event;
// ------------------------------------------------------------
// Flags for energy terms that are included in the calculation
// NOTE: All true by default
// ------------------------------------------------------------
bool calc_bond;
bool calc_ureyb;
bool calc_angle;
bool calc_dihe;
bool calc_imdihe;
bool calc_cmap;
bool heuristic_check(const cudaXYZ<double>& coord, cudaStream_t stream=0);
void setup_direct_nonbonded(const double roff, const double ron,
const double kappa, const double e14fac,
const int vdw_model, const int elec_model,
const int nvdwparam, const float *h_vdwparam,
const float *h_vdwparam14, const int *h_glo_vdwtype);
void setup_recip_nonbonded(const double kappa,
const int nfftx, const int nffty, const int nfftz,
const int order);
public:
CudaPMEForcefield(CudaDomdec& domdec, CudaDomdecGroups& domdecGroups,
const CudaTopExcl& topExcl,
const int nbondcoef, const float2 *h_bondcoef,
const int nureybcoef, const float2 *h_ureybcoef,
const int nanglecoef, const float2 *h_anglecoef,
const int ndihecoef, const float4 *h_dihecoef,
const int nimdihecoef, const float4 *h_imdihecoef,
const int ncmapcoef, const float2 *h_cmapcoef,
const double roff, const double ron,
const double kappa, const double e14fac,
const int vdw_model, const int elec_model,
const int nvdwparam, const float *h_vdwparam,
const float *h_vdwparam14,
const int* h_glo_vdwtype, const float *h_glo_q,
CudaEnergyVirial& energyVirial,
CudaDomdecRecip* recip, CudaDomdecRecipComm& recipComm);
~CudaPMEForcefield();
void calc(const bool calc_energy, const bool calc_virial,
cudaXYZ<double>& coord, cudaXYZ<double>& prev_step, Force<long long int>& force,
cudaStream_t stream);
void post_calc(const float *global_mass, float *mass, HoloConst *holoconst, cudaStream_t stream);
void stop_calc(cudaStream_t stream) {
cudaCheck(cudaStreamSynchronize(stream));
recipComm.send_stop();
}
void constComm(const int dir, cudaXYZ<double>& coord, cudaStream_t stream);
void assignCoordToNodes(hostXYZ<double>& coord, std::vector<int>& h_loc2glo);
void get_restart_data(cudaXYZ<double>& coord, cudaXYZ<double>& step,
Force<long long int>& force,
double *x, double *y, double *z,
double *dx, double *dy, double *dz,
double *fx, double *fy, double *fz);
void print_energy_virial(int step, const double temp);
};
#endif // CUDAPMEFORCEFIELD_H