"platforms/cuda/vscode:/vscode.git/clone" did not exist on "0360c770806f92b59fa1728deadbe40706501c14"
CudaKernels.h 11.5 KB
Newer Older
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
#ifndef OPENMM_CUDAKERNELS_H_
#define OPENMM_CUDAKERNELS_H_

/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
 * Authors: Peter Eastman                                                     *
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

35
#include "CudaPlatform.h"
36
#include "kernels.h"
37
#include "kernels/gpuTypes.h"
38
#include "System.h"
39
40
41
42
43
44
45
46
47

class CudaAndersenThermostat;
class CudaBrownianDynamics;
class CudaStochasticDynamics;
class CudaShakeAlgorithm;
class CudaVerletDynamics;

namespace OpenMM {

48
49
50
51
52
/**
 * This kernel is invoked by StandardMMForceField to calculate the forces acting on the system.
 */
class CudaCalcStandardMMForceFieldKernel : public CalcStandardMMForceFieldKernel {
public:
53
    CudaCalcStandardMMForceFieldKernel(std::string name, const Platform& platform, CudaPlatform::PlatformData& data, System& system) : CalcStandardMMForceFieldKernel(name, platform), data(data), system(system) {
54
55
56
    }
    ~CudaCalcStandardMMForceFieldKernel();
    /**
57
     * Initialize the kernel.
58
     * 
59
60
61
62
63
     * @param system     the System this kernel will be applied to
     * @param force      the StandardMMForceField this kernel will be used for
     * @param exclusions the i'th element lists the indices of all atoms with which the i'th atom should not interact through
     *                   nonbonded forces.  Bonded 1-4 pairs are also included in this list, since they should be omitted from
     *                   the standard nonbonded calculation.
64
     */
65
    void initialize(const System& system, const StandardMMForceField& force, const std::vector<std::set<int> >& exclusions);
66
67
68
    /**
     * Execute the kernel to calculate the forces.
     * 
69
     * @param context    the context in which to execute this kernel
70
     */
71
    void executeForces(OpenMMContextImpl& context);
72
73
74
    /**
     * Execute the kernel to calculate the energy.
     * 
75
     * @param context    the context in which to execute this kernel
76
77
     * @return the potential energy due to the StandardMMForceField
     */
78
    double executeEnergy(OpenMMContextImpl& context);
79
private:
80
    CudaPlatform::PlatformData& data;
81
    int numAtoms, numBonds, numAngles, numPeriodicTorsions, numRBTorsions, num14;
82
    System& system;
83
84
};

85
86
87
88
89
90
91
92
93
/**
 * This kernel is invoked by GBSAOBCForceField to calculate the forces acting on the system.
 */
class CudaCalcGBSAOBCForceFieldKernel : public CalcGBSAOBCForceFieldKernel {
public:
    CudaCalcGBSAOBCForceFieldKernel(std::string name, const Platform& platform, CudaPlatform::PlatformData& data) : CalcGBSAOBCForceFieldKernel(name, platform), data(data) {
    }
    ~CudaCalcGBSAOBCForceFieldKernel();
    /**
94
     * Initialize the kernel.
95
     * 
96
97
     * @param system     the System this kernel will be applied to
     * @param force      the GBSAOBCForceField this kernel will be used for
98
     */
99
    void initialize(const System& system, const GBSAOBCForceField& force);
100
101
102
    /**
     * Execute the kernel to calculate the forces.
     * 
103
     * @param context    the context in which to execute this kernel
104
     */
105
    void executeForces(OpenMMContextImpl& context);
106
107
108
    /**
     * Execute the kernel to calculate the energy.
     * 
109
     * @param context    the context in which to execute this kernel
110
111
     * @return the potential energy due to the GBSAOBCForceField
     */
112
    double executeEnergy(OpenMMContextImpl& context);
113
114
115
private:
    CudaPlatform::PlatformData& data;
};
116
117
118
119
120
121
122
123
124
125
126
//
///**
// * This kernel is invoked by VerletIntegrator to take one time step.
// */
//class CudaIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
//public:
//    CudaIntegrateVerletStepKernel(std::string name, const Platform& platform) : IntegrateVerletStepKernel(name, platform),
//        dynamics(0), shake(0), masses(0), shakeParameters(0), constraintIndices(0) {
//    }
//    ~CudaIntegrateVerletStepKernel();
//    /**
127
//     * Initialize the kernel.
128
//     * 
129
130
//     * @param system     the System this kernel will be applied to
//     * @param integrator the VerletIntegrator this kernel will be used for
131
//     */
132
//    void initialize(const System& system, const VerletIntegrator& integrator);
133
134
135
//    /**
//     * Execute the kernel.
//     * 
136
137
//     * @param context    the context in which to execute this kernel
//     * @param integrator the VerletIntegrator this kernel is being used for
138
//     */
139
//    void execute(OpenMMContextImpl& context, const VerletIntegrator& integrator);
140
141
142
143
144
145
146
147
148
//private:
//    CudaVerletDynamics* dynamics;
//    CudaShakeAlgorithm* shake;
//    RealOpenMM* masses;
//    RealOpenMM** shakeParameters;
//    int** constraintIndices;
//    int numConstraints;
//    double prevStepSize;
//};
149
150
151
152
153
154

/**
 * This kernel is invoked by LangevinIntegrator to take one time step.
 */
class CudaIntegrateLangevinStepKernel : public IntegrateLangevinStepKernel {
public:
155
    CudaIntegrateLangevinStepKernel(std::string name, const Platform& platform, CudaPlatform::PlatformData& data) : IntegrateLangevinStepKernel(name, platform), data(data) {
156
157
158
    }
    ~CudaIntegrateLangevinStepKernel();
    /**
159
     * Initialize the kernel, setting up the atomic masses.
160
     * 
161
162
     * @param system     the System this kernel will be applied to
     * @param integrator the LangevinIntegrator this kernel will be used for
163
     */
164
    void initialize(const System& system, const LangevinIntegrator& integrator);
165
166
167
    /**
     * Execute the kernel.
     * 
168
169
     * @param context    the context in which to execute this kernel
     * @param integrator the LangevinIntegrator this kernel is being used for
170
     */
171
    void execute(OpenMMContextImpl& context, const LangevinIntegrator& integrator);
172
private:
173
    CudaPlatform::PlatformData& data;
174
175
    double prevTemp, prevFriction, prevStepSize;
};
176
177
178
179
180
181
182
183
184
185
186
//
///**
// * This kernel is invoked by BrownianIntegrator to take one time step.
// */
//class CudaIntegrateBrownianStepKernel : public IntegrateBrownianStepKernel {
//public:
//    CudaIntegrateBrownianStepKernel(std::string name, const Platform& platform) : IntegrateBrownianStepKernel(name, platform),
//        dynamics(0), shake(0), masses(0), shakeParameters(0), constraintIndices(0) {
//    }
//    ~CudaIntegrateBrownianStepKernel();
//    /**
187
//     * Initialize the kernel.
188
//     * 
189
190
//     * @param system     the System this kernel will be applied to
//     * @param integrator the BrownianIntegrator this kernel will be used for
191
//     */
192
//    void initialize(const System& system, const BrownianIntegrator& integrator);
193
194
195
//    /**
//     * Execute the kernel.
//     * 
196
197
//     * @param context    the context in which to execute this kernel
//     * @param integrator the BrownianIntegrator this kernel is being used for
198
//     */
199
//    void execute(OpenMMContextImpl& context, const BrownianIntegrator& integrator);
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
//private:
//    CudaBrownianDynamics* dynamics;
//    CudaShakeAlgorithm* shake;
//    RealOpenMM* masses;
//    RealOpenMM** shakeParameters;
//    int** constraintIndices;
//    int numConstraints;
//    double prevTemp, prevFriction, prevStepSize;
//};
//
///**
// * This kernel is invoked by AndersenThermostat at the start of each time step to adjust the atom velocities.
// */
//class CudaApplyAndersenThermostatKernel : public ApplyAndersenThermostatKernel {
//public:
//    CudaApplyAndersenThermostatKernel(std::string name, const Platform& platform) : ApplyAndersenThermostatKernel(name, platform), thermostat(0) {
//    }
//    ~CudaApplyAndersenThermostatKernel();
//    /**
219
//     * Initialize the kernel.
220
//     * 
221
222
//     * @param system     the System this kernel will be applied to
//     * @param thermostat the AndersenThermostat this kernel will be used for
223
//     */
224
//    void initialize(const System& system, const AndersenThermostat& thermostat);
225
226
227
//    /**
//     * Execute the kernel.
//     * 
228
//     * @param context    the context in which to execute this kernel
229
//     */
230
//    void execute(OpenMMContextImpl& context);
231
232
233
234
//private:
//    CudaAndersenThermostat* thermostat;
//    RealOpenMM* masses;
//};
235
236
237
238
239
240
241
242
243

/**
 * This kernel is invoked to calculate the kinetic energy of the system.
 */
class CudaCalcKineticEnergyKernel : public CalcKineticEnergyKernel {
public:
    CudaCalcKineticEnergyKernel(std::string name, const Platform& platform) : CalcKineticEnergyKernel(name, platform) {
    }
    /**
244
     * Initialize the kernel.
245
     * 
246
     * @param system     the System this kernel will be applied to
247
     */
248
    void initialize(const System& system);
249
250
251
    /**
     * Execute the kernel.
     * 
252
     * @param context    the context in which to execute this kernel
253
     */
254
    double execute(OpenMMContextImpl& context);
255
256
257
private:
    std::vector<double> masses;
};
258
259
260
261
262
263
264
265
266
267
268

/**
 * This kernel is invoked to remove center of mass motion from the system.
 */
class CudaRemoveCMMotionKernel : public RemoveCMMotionKernel {
public:
    CudaRemoveCMMotionKernel(std::string name, const Platform& platform, CudaPlatform::PlatformData& data) : RemoveCMMotionKernel(name, platform), data(data) {
    }
    /**
     * Initialize the kernel, setting up the atomic masses.
     * 
269
270
     * @param system     the System this kernel will be applied to
     * @param force      the CMMotionRemover this kernel will be used for
271
     */
272
    void initialize(const System& system, const CMMotionRemover& force);
273
274
275
    /**
     * Execute the kernel.
     * 
276
     * @param context    the context in which to execute this kernel
277
     */
278
    void execute(OpenMMContextImpl& context);
279
280
281
private:
    CudaPlatform::PlatformData& data;
};
282
283
284
285

} // namespace OpenMM

#endif /*OPENMM_CUDAKERNELS_H_*/