amoebaCudaKernels.h 10.8 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
3
4
#ifndef __AMOEBA_GPU_TYPES_H__
#define __AMOEBA_GPU_TYPES_H__

/* -------------------------------------------------------------------------- *
5
 *                             OpenMMAmoeba                                   *
Mark Friedrichs's avatar
Mark Friedrichs committed
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
 * -------------------------------------------------------------------------- *
 * 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) 2009 Stanford University and the Authors.           *
 * Authors: Scott Le Grand, Peter Eastman                                     *
 * Contributors:                                                              *
 *                                                                            *
 * This program is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU Lesser General Public License as published   *
 * by the Free Software Foundation, either version 3 of the License, or       *
 * (at your option) any later version.                                        *
 *                                                                            *
 * This program is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU Lesser General Public License for more details.                        *
 *                                                                            *
 * You should have received a copy of the GNU Lesser General Public License   *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
 * -------------------------------------------------------------------------- */

#include "amoebaGpuTypes.h"

#include <string>
#include <vector>

typedef std::vector<std::string> StringVector;
typedef std::vector<StringVector> StringVectorVector;

#define SQRT sqrtf
#define EXP  expf
#define DOT3(u,v) ((u[0])*(v[0]) + (u[1])*(v[1]) + (u[2])*(v[2]))

typedef std::vector<std::vector<double> > VectorOfDoubleVectors;

// local (bond) forces

extern void SetCalculateAmoebaLocalForcesSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaLocalForcesSim(amoebaGpuContext gpu);
extern void kCalculateAmoebaLocalForces(amoebaGpuContext gpu);

// multipole

extern void SetCalculateAmoebaMultipoleForcesSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaMultipoleForcesSim(amoebaGpuContext gpu);
extern void kCalculateAmoebaMultipoleForces(amoebaGpuContext amoebaGpu, bool performGk );

// vdw

extern void SetCalculateAmoebaCudaVdw14_7Sim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaVdw14_7Sim(amoebaGpuContext gpu);
Mark Friedrichs's avatar
Mark Friedrichs committed
60
extern void kCalculateAmoebaVdw14_7Forces(amoebaGpuContext amoebaGpu, int applyCutoff );
Mark Friedrichs's avatar
Mark Friedrichs committed
61
62
63
64
65
66
67

// wca dispersion

extern void SetCalculateAmoebaCudaWcaDispersionSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaWcaDispersionSim(amoebaGpuContext gpu);
extern void kCalculateAmoebaWcaDispersionForces(amoebaGpuContext amoebaGpu );

68
// fixed electric field -- no cutoff
Mark Friedrichs's avatar
Mark Friedrichs committed
69
70
71
72
73

extern void SetCalculateAmoebaCudaFixedEFieldSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaFixedEFieldSim(amoebaGpuContext gpu);
extern void cudaComputeAmoebaFixedEField( amoebaGpuContext gpu);

74
75
76
77
78
// fixed electric field  -- PME
extern void SetCalculateAmoebaCudaPmeFixedEFieldSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaPmeFixedEFieldSim(amoebaGpuContext gpu);
extern void cudaComputeAmoebaPmeFixedEField( amoebaGpuContext gpu);

Mark Friedrichs's avatar
Mark Friedrichs committed
79
80
81
82
83
84
85
86
87
88
89
90
// fixed electric field and Gk

extern void SetCalculateAmoebaCudaFixedEAndGKFieldsSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaFixedEAndGKFieldsSim(amoebaGpuContext gpu);
extern void cudaComputeAmoebaFixedEAndGkFields( amoebaGpuContext gpu);

// mutual induced 

extern void SetCalculateAmoebaCudaMutualInducedFieldSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaMutualInducedFieldSim(amoebaGpuContext gpu);
extern void cudaComputeAmoebaMutualInducedField( amoebaGpuContext gpu);

91
92
93
94
extern void SetCalculateAmoebaCudaPmeMutualInducedFieldSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaPmeMutualInducedFieldSim(amoebaGpuContext gpu);
extern void cudaComputeAmoebaPmeMutualInducedField( amoebaGpuContext gpu);

Mark Friedrichs's avatar
Mark Friedrichs committed
95
96
97
98
99
100
101
// mutual induced and Gk

extern void SetCalculateAmoebaCudaMutualInducedAndGkFieldsSim(amoebaGpuContext amoebaGpu);
extern void GetCalculateAmoebaCudaMutualInducedAndGkFieldsSim(amoebaGpuContext amoebaGpu);
extern void cudaComputeAmoebaMutualInducedAndGkField( amoebaGpuContext gpu);

extern void cudaComputeAmoebaLabFrameMoments( amoebaGpuContext amoebaGpu );
102
extern void cudaWriteFloat4AndFloat1ArraysToFile( int numberOfAtoms, const std::string& fname, int timestep, int entriesPerAtom1, CUDAStream<float4>* array1, 
Mark Friedrichs's avatar
Mark Friedrichs committed
103
104
105
106
                                                  int entriesPerAtom2, CUDAStream<float>* array2 );

extern void SetCalculateAmoebaElectrostaticSim( amoebaGpuContext amoebaGpu );
extern void GetCalculateAmoebaElectrostaticSim( amoebaGpuContext amoebaGpu );
107
extern void cudaComputeAmoebaElectrostatic( amoebaGpuContext amoebaGpu, int addTorqueToForce );
Mark Friedrichs's avatar
Mark Friedrichs committed
108

Mark Friedrichs's avatar
Mark Friedrichs committed
109
110
111
extern void SetCalculateAmoebaPmeDirectElectrostaticSim( amoebaGpuContext amoebaGpu );
extern void GetCalculateAmoebaPmeDirectElectrostaticSim( amoebaGpuContext amoebaGpu );
extern void cudaComputeAmoebaPmeElectrostatic( amoebaGpuContext amoebaGpu );
112

Mark Friedrichs's avatar
Mark Friedrichs committed
113
114
extern void SetCalculateAmoebaCudaMapTorquesSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaMapTorquesSim(amoebaGpuContext gpu);
115
extern void cudaComputeAmoebaMapTorqueAndAddToForce( amoebaGpuContext gpu, CUDAStream<float>* psTorque );
Mark Friedrichs's avatar
Mark Friedrichs committed
116
117
118
119
120
121
122
123
124
125
126

extern void SetCalculateAmoebaKirkwoodSim( amoebaGpuContext amoebaGpu );
extern void GetCalculateAmoebaKirkwoodSim( amoebaGpuContext amoebaGpu );
//extern void cudaComputeAmoebaKirkwood( amoebaGpuContext amoebaGpu );
extern void kCalculateAmoebaKirkwood( amoebaGpuContext amoebaGpu );

extern void SetCalculateAmoebaKirkwoodEDiffSim( amoebaGpuContext amoebaGpu );
extern void GetCalculateAmoebaKirkwoodEDiffSim( amoebaGpuContext amoebaGpu );
//extern void cudaComputeAmoebaKirkwoodEDiff( amoebaGpuContext amoebaGpu );
extern void kCalculateAmoebaKirkwoodEDiff( amoebaGpuContext amoebaGpu );

127
128
129
130
131
132
133
134
135
//extern void SetCalculateAmoebaObcGbsaBornSumSim( gpuContext gpu );
//extern void GetCalculateAmoebaObcGbsaBornSumSim( gpuContext gpu );
//extern void cudaComputeAmoebaBornRadii( amoebaGpuContext amoebaGpu );
extern void kCalculateAmoebaGrycukBornRadii( amoebaGpuContext amoebaGpu );
extern void kReduceGrycukGbsaBornSum( amoebaGpuContext gpu );
extern void SetCalculateAmoebaGrycukSim(amoebaGpuContext amoebaGpu );
extern void GetCalculateAmoebaGrycukSim(amoebaGpuContext amoebaGpu );
extern void kCalculateGrycukGbsaForces2( amoebaGpuContext amoebaGpu );

Mark Friedrichs's avatar
Mark Friedrichs committed
136
137
138
139
140
141
142
143
144
145
146
147
148
149

// OBC -- Part 1
//extern void SetCalculateObcGbsaForces1Sim(gpuContext gpu);
//extern void GetCalculateObcGbsaForces1Sim(gpuContext gpu);
//extern void kCalculateObcGbsaForces1(gpuContext gpu);

extern void SetCalculateAmoebaObcGbsaForces2Sim(amoebaGpuContext amoebaGpu);
extern void GetCalculateAmoebaObcGbsaForces2Sim(amoebaGpuContext amoebaGpu);
extern void kCalculateAmoebaObcGbsaForces2(  amoebaGpuContext amoebaGpu );

extern void  cudaReduceN2ToN( float *N2Array, int N, float *NArray, int includeDiagonal, int offset );
extern float cudaGetSum( int numberOfElements, CUDAStream<float>* array );
extern float cudaGetNorm2( int numberOfElements, CUDAStream<float>* array );
extern int   checkForNansAndInfinities( int numberOfElements, CUDAStream<float>* array );
150
extern void cudaWriteFloat1AndFloat1ArraysToFile( int numberOfAtoms, const std::string& fname, std::vector<int>& fileId, int entriesPerAtom1, CUDAStream<float>* array1, 
Mark Friedrichs's avatar
Mark Friedrichs committed
151
152
153
                                                  int entriesPerAtom2, CUDAStream<float>* array2 );
extern void readFile( std::string fileName, StringVectorVector& fileContents );
 
154
155
extern void cudaLoadCudaFloatArray(  int numberOfParticles, int entriesPerParticle, CUDAStream<float>*  array, VectorOfDoubleVectors& outputVector, int* order, float conversion );
extern void cudaLoadCudaFloat2Array( int numberOfParticles, int entriesPerParticle, CUDAStream<float2>* array, VectorOfDoubleVectors& outputVector, int* order, float conversion );
156
extern void cudaLoadCudaFloat4Array( int numberOfParticles, int entriesPerParticle, CUDAStream<float4>* array, VectorOfDoubleVectors& outputVector, int* order, float conversion );
157
extern void cudaWriteVectorOfDoubleVectorsToFile( const std::string& fname, std::vector<int>& fileId, VectorOfDoubleVectors& outputVector );
158
extern void initializeCudaFloatArray( int numberOfParticles, int entriesPerParticle, CUDAStream<float>* array, float initValue );
Mark Friedrichs's avatar
Mark Friedrichs committed
159
160
161
162
extern void checkForNans( int numberOfParticles, int entriesPerParticle,
                          CUDAStream<float>* array, int* order, int iteration, std::string idString, FILE* log );
extern void checkForNansFloat4( int numberOfParticles, CUDAStream<float4>* array, int* order, int iteration, std::string idString, FILE* log );

163

Mark Friedrichs's avatar
Mark Friedrichs committed
164
165
166
167
168

extern void kClearFloat( amoebaGpuContext amoebaGpu, unsigned int entries, CUDAStream<float>* fieldToClear );
extern void kClearFloat4( amoebaGpuContext amoebaGpu, unsigned int entries, CUDAStream<float4>* fieldToClear );
extern void kClearFields_1( amoebaGpuContext amoebaGpu );
extern void kClearFields_3( amoebaGpuContext amoebaGpu, unsigned int numberToClear );
169
extern void kClearBornSum(gpuContext gpu);
Mark Friedrichs's avatar
Mark Friedrichs committed
170
extern unsigned int getThreadsPerBlock( amoebaGpuContext amoebaGpu, unsigned int sharedMemoryPerThread, unsigned int sharedMemoryPerBlock );
Mark Friedrichs's avatar
Mark Friedrichs committed
171

172
//extern int isNanOrInfinity( double number );
173
extern void trackMutualInducedIterations( amoebaGpuContext amoebaGpu, int iteration);
174
175
extern void zeroCUDAStreamFloat4( CUDAStream<float4>* streamToCopy );
extern void reduceAndCopyCUDAStreamFloat4( CUDAStream<float4>* streamToCopy, CUDAStream<float>*  outputStream, float conversion );
176
extern void reduceAndCopyCUDAStreamFloat( CUDAStream<float>* streamToCopy, CUDAStream<float>*  outputStream, float conversion );
177

178
179
180
// PME

extern void SetCalculateAmoebaPMESim( amoebaGpuContext amoebaGpu );
181
extern void kCalculateAmoebaPMEFixedMultipoles(amoebaGpuContext amoebaGpu);
182
extern void kCalculateAmoebaPMEInducedDipoleField(amoebaGpuContext amoebaGpu);
183
extern void kCalculateAmoebaPMEInducedDipoleForces(amoebaGpuContext amoebaGpu);
184

Mark Friedrichs's avatar
Mark Friedrichs committed
185
extern void SetCalculateAmoebaCudaUtilitiesSim( amoebaGpuContext amoebaGpu );
186
187

double getTimeOfDay( void );
Mark Friedrichs's avatar
Mark Friedrichs committed
188
189
#endif //__AMOEBA_GPU_TYPES_H__