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
a163706b
Commit
a163706b
authored
Jan 13, 2010
by
Peter Eastman
Browse files
cudaThreadExit() was not being called, which caused failures on some platforms
parent
030ef272
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
62 deletions
+76
-62
platforms/cuda/src/kernels/gpu.cpp
platforms/cuda/src/kernels/gpu.cpp
+4
-6
platforms/cuda/tests/TestCudaCustomNonbondedForce.cpp
platforms/cuda/tests/TestCudaCustomNonbondedForce.cpp
+20
-10
platforms/cuda/tests/TestCudaEwald.cpp
platforms/cuda/tests/TestCudaEwald.cpp
+6
-6
platforms/cuda/tests/TestCudaNonbondedForce.cpp
platforms/cuda/tests/TestCudaNonbondedForce.cpp
+46
-40
No files found.
platforms/cuda/src/kernels/gpu.cpp
View file @
a163706b
...
@@ -1692,11 +1692,8 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync)
...
@@ -1692,11 +1692,8 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync)
int
SMMinor
=
0
;
int
SMMinor
=
0
;
// Select which device to use
// Select which device to use
int
currentDevice
;
cudaError_t
status
=
cudaSetDevice
(
device
);
cudaError_t
status
=
cudaGetDevice
(
&
currentDevice
);
RTERROR
(
status
,
"Error setting CUDA device"
)
RTERROR
(
status
,
"Error getting CUDA device"
)
if
(
device
!=
currentDevice
)
cudaSetDevice
(
device
);
// Ignore errors
status
=
cudaGetDevice
(
&
gpu
->
device
);
status
=
cudaGetDevice
(
&
gpu
->
device
);
RTERROR
(
status
,
"Error getting CUDA device"
)
RTERROR
(
status
,
"Error getting CUDA device"
)
status
=
cudaSetDeviceFlags
(
useBlockingSync
?
cudaDeviceBlockingSync
:
cudaDeviceScheduleAuto
);
status
=
cudaSetDeviceFlags
(
useBlockingSync
?
cudaDeviceBlockingSync
:
cudaDeviceScheduleAuto
);
...
@@ -1705,7 +1702,7 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync)
...
@@ -1705,7 +1702,7 @@ void* gpuInit(int numAtoms, unsigned int device, bool useBlockingSync)
// Determine kernel call configuration
// Determine kernel call configuration
cudaDeviceProp
deviceProp
;
cudaDeviceProp
deviceProp
;
cudaGetDeviceProperties
(
&
deviceProp
,
currentD
evice
);
cudaGetDeviceProperties
(
&
deviceProp
,
gpu
->
d
evice
);
// Determine SM version
// Determine SM version
if
(
deviceProp
.
major
==
1
)
if
(
deviceProp
.
major
==
1
)
...
@@ -2089,6 +2086,7 @@ void gpuShutDown(gpuContext gpu)
...
@@ -2089,6 +2086,7 @@ void gpuShutDown(gpuContext gpu)
// Wrap up
// Wrap up
delete
gpu
;
delete
gpu
;
cudaThreadExit
();
return
;
return
;
}
}
...
...
platforms/cuda/tests/TestCudaCustomNonbondedForce.cpp
View file @
a163706b
...
@@ -294,17 +294,27 @@ void testCoulombLennardJones() {
...
@@ -294,17 +294,27 @@ void testCoulombLennardJones() {
customSystem
.
addForce
(
customNonbonded
);
customSystem
.
addForce
(
customNonbonded
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
context1
(
standardSystem
,
integrator1
,
platform
);
double
energy1
,
energy2
;
context1
.
setPositions
(
positions
);
vector
<
Vec3
>
forces1
,
forces2
;
context1
.
setVelocities
(
velocities
);
{
State
state1
=
context1
.
getState
(
State
::
Forces
|
State
::
Energy
);
Context
context
(
standardSystem
,
integrator1
,
platform
);
Context
context2
(
customSystem
,
integrator2
,
platform
);
context
.
setPositions
(
positions
);
context2
.
setPositions
(
positions
);
context
.
setVelocities
(
velocities
);
context2
.
setVelocities
(
velocities
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
energy1
=
state
.
getPotentialEnergy
();
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
1e-4
);
forces1
=
state
.
getForces
();
}
{
Context
context
(
customSystem
,
integrator2
,
platform
);
context
.
setPositions
(
positions
);
context
.
setVelocities
(
velocities
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
energy2
=
state
.
getPotentialEnergy
();
forces2
=
state
.
getForces
();
}
ASSERT_EQUAL_TOL
(
energy1
,
energy2
,
1e-4
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
ASSERT_EQUAL_VEC
(
state1
.
getF
orces
()
[
i
],
state2
.
getF
orces
()
[
i
],
1e-4
);
ASSERT_EQUAL_VEC
(
f
orces
1
[
i
],
f
orces
2
[
i
],
1e-4
);
}
}
}
}
...
...
platforms/cuda/tests/TestCudaEwald.cpp
View file @
a163706b
...
@@ -116,11 +116,11 @@ void testEwaldPME() {
...
@@ -116,11 +116,11 @@ void testEwaldPME() {
Vec3
f
=
cudaState
.
getForces
()[
i
];
Vec3
f
=
cudaState
.
getForces
()[
i
];
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
}
}
Context
cudaContext
2
(
system
,
integrator
,
cuda
);
cudaContext
.
reinitialize
(
);
cudaContext
2
.
setPositions
(
positions
);
cudaContext
.
setPositions
(
positions
);
tol
=
1e-3
;
tol
=
1e-3
;
State
cudaState2
=
cudaContext
2
.
getState
(
State
::
Energy
);
State
cudaState2
=
cudaContext
.
getState
(
State
::
Energy
);
ASSERT_EQUAL_TOL
(
norm
,
(
cudaState2
.
getPotentialEnergy
()
-
cudaState
.
getPotentialEnergy
())
/
delta
,
tol
)
ASSERT_EQUAL_TOL
(
norm
,
(
cudaState2
.
getPotentialEnergy
()
-
cudaState
.
getPotentialEnergy
())
/
delta
,
tol
)
// (3) Check whether the Reference and Cuda platforms agree when using PME
// (3) Check whether the Reference and Cuda platforms agree when using PME
...
@@ -154,11 +154,11 @@ void testEwaldPME() {
...
@@ -154,11 +154,11 @@ void testEwaldPME() {
Vec3
f
=
cudaState
.
getForces
()[
i
];
Vec3
f
=
cudaState
.
getForces
()[
i
];
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
}
}
Context
cudaContext
3
(
system
,
integrator
,
cuda
);
cudaContext
.
reinitialize
(
);
cudaContext
3
.
setPositions
(
positions
);
cudaContext
.
setPositions
(
positions
);
tol
=
1e-3
;
tol
=
1e-3
;
State
cudaState3
=
cudaContext
3
.
getState
(
State
::
Energy
);
State
cudaState3
=
cudaContext
.
getState
(
State
::
Energy
);
ASSERT_EQUAL_TOL
(
norm
,
(
cudaState3
.
getPotentialEnergy
()
-
cudaState
.
getPotentialEnergy
())
/
delta
,
tol
)
ASSERT_EQUAL_TOL
(
norm
,
(
cudaState3
.
getPotentialEnergy
()
-
cudaState
.
getPotentialEnergy
())
/
delta
,
tol
)
}
}
...
...
platforms/cuda/tests/TestCudaNonbondedForce.cpp
View file @
a163706b
...
@@ -143,6 +143,9 @@ void testExclusionsAnd14() {
...
@@ -143,6 +143,9 @@ void testExclusionsAnd14() {
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
// The following is in its own block, because CUDA can't deal with multiple Contexts
// existing on the same thread at the same time.
{
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -162,19 +165,21 @@ void testExclusionsAnd14() {
...
@@ -162,19 +165,21 @@ void testExclusionsAnd14() {
ASSERT_EQUAL_VEC
(
Vec3
(
-
force
,
0
,
0
),
forces
[
0
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
-
force
,
0
,
0
),
forces
[
0
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
force
,
0
,
0
),
forces
[
i
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
force
,
0
,
0
),
forces
[
i
],
TOL
);
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
TOL
);
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
TOL
);
}
// Test Coulomb forces
// Test Coulomb forces
{
nonbonded
->
setParticleParameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
0
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
Context
context
2
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
2
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
state
=
context
2
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces2
=
state
.
getForces
();
const
vector
<
Vec3
>&
forces2
=
state
.
getForces
();
force
=
ONE_4PI_EPS0
*
4
/
(
r
*
r
);
double
force
=
ONE_4PI_EPS0
*
4
/
(
r
*
r
);
energy
=
ONE_4PI_EPS0
*
4
/
r
;
double
energy
=
ONE_4PI_EPS0
*
4
/
r
;
if
(
i
==
3
)
{
if
(
i
==
3
)
{
force
/=
1.2
;
force
/=
1.2
;
energy
/=
1.2
;
energy
/=
1.2
;
...
@@ -187,6 +192,7 @@ void testExclusionsAnd14() {
...
@@ -187,6 +192,7 @@ void testExclusionsAnd14() {
ASSERT_EQUAL_VEC
(
Vec3
(
force
,
0
,
0
),
forces2
[
i
],
TOL
);
ASSERT_EQUAL_VEC
(
Vec3
(
force
,
0
,
0
),
forces2
[
i
],
TOL
);
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
TOL
);
ASSERT_EQUAL_TOL
(
energy
,
state
.
getPotentialEnergy
(),
TOL
);
}
}
}
}
}
void
testCutoff
()
{
void
testCutoff
()
{
...
...
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