Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
a7a4f3cb
Commit
a7a4f3cb
authored
May 19, 2009
by
Rossen Apostolov
Browse files
Cleaned up Cuda-Ewald
parent
bc8ab357
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
19 deletions
+42
-19
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+1
-0
platforms/cuda/src/kernels/cudatypes.h
platforms/cuda/src/kernels/cudatypes.h
+11
-4
platforms/cuda/src/kernels/gpu.cpp
platforms/cuda/src/kernels/gpu.cpp
+20
-0
platforms/cuda/src/kernels/gputypes.h
platforms/cuda/src/kernels/gputypes.h
+3
-0
platforms/cuda/src/kernels/kCalculateCDLJEwaldReciprocal.h
platforms/cuda/src/kernels/kCalculateCDLJEwaldReciprocal.h
+7
-15
No files found.
platforms/cuda/src/CudaKernels.cpp
View file @
a7a4f3cb
...
@@ -291,6 +291,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
...
@@ -291,6 +291,7 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
Vec3
boxVectors
[
3
];
Vec3
boxVectors
[
3
];
force
.
getPeriodicBoxVectors
(
boxVectors
[
0
],
boxVectors
[
1
],
boxVectors
[
2
]);
force
.
getPeriodicBoxVectors
(
boxVectors
[
0
],
boxVectors
[
1
],
boxVectors
[
2
]);
gpuSetPeriodicBoxSize
(
gpu
,
(
float
)
boxVectors
[
0
][
0
],
(
float
)
boxVectors
[
1
][
1
],
(
float
)
boxVectors
[
2
][
2
]);
gpuSetPeriodicBoxSize
(
gpu
,
(
float
)
boxVectors
[
0
][
0
],
(
float
)
boxVectors
[
1
][
1
],
(
float
)
boxVectors
[
2
][
2
]);
gpuSetEwaldParameters
(
gpu
);
//, (float)alphaEwald, (int)kmax);
method
=
EWALD
;
method
=
EWALD
;
}
}
...
...
platforms/cuda/src/kernels/cudatypes.h
View file @
a7a4f3cb
...
@@ -292,6 +292,13 @@ struct cudaGmxSimulation {
...
@@ -292,6 +292,13 @@ struct cudaGmxSimulation {
float
periodicBoxSizeX
;
// The X dimension of the periodic box
float
periodicBoxSizeX
;
// The X dimension of the periodic box
float
periodicBoxSizeY
;
// The Y dimension of the periodic box
float
periodicBoxSizeY
;
// The Y dimension of the periodic box
float
periodicBoxSizeZ
;
// The Z dimension of the periodic box
float
periodicBoxSizeZ
;
// The Z dimension of the periodic box
float
recipBoxSizeX
;
// The X dimension of the reciprocal box for Ewald summation
float
recipBoxSizeY
;
// The Y dimension of the reciprocal box for Ewald summation
float
recipBoxSizeZ
;
// The Z dimension of the reciprocal box for Ewald summation
float
cellVolume
;
// Ewald parameter alpha (a.k.a. kappa)
float
alphaEwald
;
// Ewald parameter alpha (a.k.a. kappa)
float
factorEwald
;
// - 1 ( 4 * alphaEwald * alphaEwald)
float
kmax
;
// Maximum number of reciprocal vectors
float
reactionFieldK
;
// Constant for reaction field correction
float
reactionFieldK
;
// Constant for reaction field correction
float
probeRadius
;
// SASA probe radius
float
probeRadius
;
// SASA probe radius
float
surfaceAreaFactor
;
// ACE approximation surface area factor
float
surfaceAreaFactor
;
// ACE approximation surface area factor
...
...
platforms/cuda/src/kernels/gpu.cpp
View file @
a7a4f3cb
...
@@ -413,6 +413,26 @@ void gpuSetNonbondedCutoff(gpuContext gpu, float cutoffDistance, float solventDi
...
@@ -413,6 +413,26 @@ void gpuSetNonbondedCutoff(gpuContext gpu, float cutoffDistance, float solventDi
gpu
->
sim
.
reactionFieldK
=
pow
(
cutoffDistance
,
-
3.0
f
)
*
(
solventDielectric
-
1.0
f
)
/
(
2.0
f
*
solventDielectric
+
1.0
f
);
gpu
->
sim
.
reactionFieldK
=
pow
(
cutoffDistance
,
-
3.0
f
)
*
(
solventDielectric
-
1.0
f
)
/
(
2.0
f
*
solventDielectric
+
1.0
f
);
}
}
extern
"C"
void
gpuSetEwaldParameters
(
gpuContext
gpu
)
//, float alphaEwald, int kmax )
{
// hard coded alphaEwald and kmax, no interface yet
float
alpha
=
3.123413
;
float
PI
=
3.14159265358979323846
f
;
float
TWO_PI
=
2.0
*
PI
;
gpu
->
sim
.
recipBoxSizeX
=
TWO_PI
/
gpu
->
sim
.
periodicBoxSizeX
;
gpu
->
sim
.
recipBoxSizeY
=
TWO_PI
/
gpu
->
sim
.
periodicBoxSizeY
;
gpu
->
sim
.
recipBoxSizeZ
=
TWO_PI
/
gpu
->
sim
.
periodicBoxSizeZ
;
gpu
->
sim
.
cellVolume
=
gpu
->
sim
.
periodicBoxSizeX
*
gpu
->
sim
.
periodicBoxSizeY
*
gpu
->
sim
.
periodicBoxSizeZ
;
gpu
->
sim
.
alphaEwald
=
alpha
;
gpu
->
sim
.
factorEwald
=
-
1
/
(
4
*
alpha
*
alpha
);
gpu
->
sim
.
kmax
=
20
+
1
;
}
extern
"C"
extern
"C"
void
gpuSetPeriodicBoxSize
(
gpuContext
gpu
,
float
xsize
,
float
ysize
,
float
zsize
)
void
gpuSetPeriodicBoxSize
(
gpuContext
gpu
,
float
xsize
,
float
ysize
,
float
zsize
)
{
{
...
...
platforms/cuda/src/kernels/gputypes.h
View file @
a7a4f3cb
...
@@ -176,6 +176,9 @@ void gpuSetCoulombParameters(gpuContext gpu, float epsfac, const std::vector<int
...
@@ -176,6 +176,9 @@ void gpuSetCoulombParameters(gpuContext gpu, float epsfac, const std::vector<int
extern
"C"
extern
"C"
void
gpuSetNonbondedCutoff
(
gpuContext
gpu
,
float
cutoffDistance
,
float
solventDielectric
);
void
gpuSetNonbondedCutoff
(
gpuContext
gpu
,
float
cutoffDistance
,
float
solventDielectric
);
extern
"C"
void
gpuSetEwaldParameters
(
gpuContext
gpu
);
//, float alphaEwald, int kmax);
extern
"C"
extern
"C"
void
gpuSetPeriodicBoxSize
(
gpuContext
gpu
,
float
xsize
,
float
ysize
,
float
zsize
);
void
gpuSetPeriodicBoxSize
(
gpuContext
gpu
,
float
xsize
,
float
ysize
,
float
zsize
);
...
...
platforms/cuda/src/kernels/kCalculateCDLJEwaldReciprocal.h
View file @
a7a4f3cb
...
@@ -32,10 +32,7 @@
...
@@ -32,10 +32,7 @@
__global__
void
kCalculateCDLJEwaldReciprocalForces_kernel
()
__global__
void
kCalculateCDLJEwaldReciprocalForces_kernel
()
{
{
float
alphaEwald
=
3
.
123413
;
float
alphaEwald
=
cSim
.
alphaEwald
;
float
PI
=
3
.
14159265358979323846
f
;
float
TWO_PI
=
2
.
0
*
PI
;
float
SQRT_PI
=
sqrt
(
PI
);
float
eps0
=
5.72765E-4
;
float
eps0
=
5.72765E-4
;
int
numRx
=
20
+
1
;
int
numRx
=
20
+
1
;
...
@@ -47,18 +44,13 @@ __global__ void kCalculateCDLJEwaldReciprocalForces_kernel()
...
@@ -47,18 +44,13 @@ __global__ void kCalculateCDLJEwaldReciprocalForces_kernel()
float
kx
,
ky
,
kz
,
k2
,
ek
;
float
kx
,
ky
,
kz
,
k2
,
ek
;
float
Qi
,
Qj
,
SinI
,
SinJ
,
CosI
,
CosJ
;
float
Qi
,
Qj
,
SinI
,
SinJ
,
CosI
,
CosJ
;
float
factorEwald
=
-
1
/
(
4
*
alphaEwald
*
alphaEwald
);
float
V
=
cSim
.
cellVolume
;
float
recipBoxSizeX
=
TWO_PI
/
cSim
.
periodicBoxSizeX
;
float
recipBoxSizeY
=
TWO_PI
/
cSim
.
periodicBoxSizeY
;
float
recipBoxSizeZ
=
TWO_PI
/
cSim
.
periodicBoxSizeZ
;
float
V
=
cSim
.
periodicBoxSizeX
*
cSim
.
periodicBoxSizeY
*
cSim
.
periodicBoxSizeZ
;
float4
apos1
,
apos2
;
float4
apos1
,
apos2
;
unsigned
int
atomID1
=
threadIdx
.
x
+
blockIdx
.
x
*
blockDim
.
x
;
unsigned
int
atomID1
=
threadIdx
.
x
+
blockIdx
.
x
*
blockDim
.
x
;
while
(
atomID1
<
cSim
.
atom
s
)
while
(
atomID1
<
cSim
.
stride
*
cSim
.
outputBuffer
s
)
{
{
apos1
=
cSim
.
pPosq
[
atomID1
];
apos1
=
cSim
.
pPosq
[
atomID1
];
...
@@ -72,18 +64,18 @@ __global__ void kCalculateCDLJEwaldReciprocalForces_kernel()
...
@@ -72,18 +64,18 @@ __global__ void kCalculateCDLJEwaldReciprocalForces_kernel()
for
(
int
rx
=
0
;
rx
<
numRx
;
rx
++
)
{
for
(
int
rx
=
0
;
rx
<
numRx
;
rx
++
)
{
kx
=
rx
*
recipBoxSizeX
;
kx
=
rx
*
cSim
.
recipBoxSizeX
;
for
(
int
ry
=
lowry
;
ry
<
numRy
;
ry
++
)
{
for
(
int
ry
=
lowry
;
ry
<
numRy
;
ry
++
)
{
ky
=
ry
*
recipBoxSizeY
;
ky
=
ry
*
cSim
.
recipBoxSizeY
;
for
(
int
rz
=
lowrz
;
rz
<
numRz
;
rz
++
)
{
for
(
int
rz
=
lowrz
;
rz
<
numRz
;
rz
++
)
{
kz
=
rz
*
recipBoxSizeZ
;
kz
=
rz
*
cSim
.
recipBoxSizeZ
;
k2
=
kx
*
kx
+
ky
*
ky
+
kz
*
kz
;
k2
=
kx
*
kx
+
ky
*
ky
+
kz
*
kz
;
ek
=
exp
(
k2
*
factorEwald
);
ek
=
exp
(
k2
*
cSim
.
factorEwald
);
Qi
=
apos1
.
w
;
Qi
=
apos1
.
w
;
Qj
=
apos2
.
w
;
Qj
=
apos2
.
w
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment