amoebaCudaKernels.h 9.94 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
102
103
104
105
106
107
108
// mutual induced and Gk

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

extern void cudaComputeAmoebaLabFrameMoments( amoebaGpuContext amoebaGpu );
extern void cudaWriteFloat4AndFloat1ArraysToFile( int numberOfAtoms, char* fname, int timestep, int entriesPerAtom1, CUDAStream<float4>* array1, 
                                                  int entriesPerAtom2, CUDAStream<float>* array2 );

extern void SetCalculateAmoebaElectrostaticSim( amoebaGpuContext amoebaGpu );
extern void GetCalculateAmoebaElectrostaticSim( amoebaGpuContext amoebaGpu );
extern void cudaComputeAmoebaElectrostatic( amoebaGpuContext amoebaGpu );

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
115
116
extern void SetCalculateAmoebaCudaMapTorquesSim(amoebaGpuContext gpu);
extern void GetCalculateAmoebaCudaMapTorquesSim(amoebaGpuContext gpu);
extern void cudaComputeAmoebaMapTorques( amoebaGpuContext gpu, CUDAStream<float>* psTorque, CUDAStream<float>* psForce);
extern void cudaComputeAmoebaMapTorquesAndAddTotalForce( amoebaGpuContext gpu, CUDAStream<float>* psTorque, CUDAStream<float>* psForce, CUDAStream<float4>* psOutputForce);
117
extern void cudaComputeAmoebaMapTorquesAndAddTotalForce2( amoebaGpuContext gpu, CUDAStream<float>* psTorque, CUDAStream<float4>* psOutputForce);
Mark Friedrichs's avatar
Mark Friedrichs committed
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

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 );

extern void SetCalculateAmoebaObcGbsaBornSumSim( gpuContext gpu );
extern void GetCalculateAmoebaObcGbsaBornSumSim( gpuContext gpu );
extern void cudaComputeAmoebaBornRadii( amoebaGpuContext amoebaGpu );

// 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 );
extern void cudaWriteFloat1AndFloat1ArraysToFile( int numberOfAtoms, char* fname, std::vector<int>& fileId, int entriesPerAtom1, CUDAStream<float>* array1, 
                                                  int entriesPerAtom2, CUDAStream<float>* array2 );
extern void readFile( std::string fileName, StringVectorVector& fileContents );
 
150
151
152
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, float conversion );
extern void cudaLoadCudaFloat4Array( int numberOfParticles, int entriesPerParticle, CUDAStream<float4>* array, VectorOfDoubleVectors& outputVector, int* order, float conversion );
Mark Friedrichs's avatar
Mark Friedrichs committed
153
extern void cudaWriteVectorOfDoubleVectorsToFile( char* fname, std::vector<int>& fileId, VectorOfDoubleVectors& outputVector );
154
155
extern void initializeCudaFloatArray( int numberOfParticles, int entriesPerParticle, CUDAStream<float>* array, float initValue );

Mark Friedrichs's avatar
Mark Friedrichs committed
156
157
158
159
160
161
162

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 );
extern unsigned int getThreadsPerBlock( amoebaGpuContext amoebaGpu, unsigned int sharedMemoryPerThread );

163
//extern int isNanOrInfinity( double number );
164
165
extern void trackMutualInducedIterations( amoebaGpuContext amoebaGpu, int iteration);

166
167
168
// PME

extern void SetCalculateAmoebaPMESim( amoebaGpuContext amoebaGpu );
169
extern void kCalculateAmoebaPMEFixedMultipoles(amoebaGpuContext amoebaGpu);
170
extern void kCalculateAmoebaPMEInducedDipoleField(amoebaGpuContext amoebaGpu);
171
extern void kCalculateAmoebaPMEInducedDipoleForces(amoebaGpuContext amoebaGpu);
172

Mark Friedrichs's avatar
Mark Friedrichs committed
173
174

extern void SetCalculateAmoebaCudaUtilitiesSim( amoebaGpuContext amoebaGpu );
Mark Friedrichs's avatar
Mark Friedrichs committed
175
176
#endif //__AMOEBA_GPU_TYPES_H__