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
a770b1b0
Commit
a770b1b0
authored
Jan 15, 2015
by
peastman
Browse files
Merge pull request #783 from peastman/nan
Catch nan coordinates before they can produce a segfault
parents
7bdd4a67
7dc2ff9e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
platforms/cpu/src/CpuKernels.cpp
platforms/cpu/src/CpuKernels.cpp
+11
-2
No files found.
platforms/cpu/src/CpuKernels.cpp
View file @
a770b1b0
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2013-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2013-201
5
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -140,7 +140,7 @@ public:
class
CpuCalcForcesAndEnergyKernel
::
InitForceTask
:
public
ThreadPool
::
Task
{
public:
InitForceTask
(
int
numParticles
,
ContextImpl
&
context
,
CpuPlatform
::
PlatformData
&
data
)
:
numParticles
(
numParticles
),
context
(
context
),
data
(
data
)
{
InitForceTask
(
int
numParticles
,
ContextImpl
&
context
,
CpuPlatform
::
PlatformData
&
data
)
:
numParticles
(
numParticles
),
positionsValid
(
true
),
context
(
context
),
data
(
data
)
{
}
void
execute
(
ThreadPool
&
threads
,
int
threadIndex
)
{
// Convert the positions to single precision and apply periodic boundary conditions
...
...
@@ -166,6 +166,12 @@ public:
posq
[
4
*
i
+
1
]
=
(
float
)
posData
[
i
][
1
];
posq
[
4
*
i
+
2
]
=
(
float
)
posData
[
i
][
2
];
}
// Check for invalid positions.
for
(
int
i
=
4
*
start
;
i
<
4
*
end
;
i
++
)
if
(
posq
[
i
]
!=
posq
[
i
])
positionsValid
=
false
;
// Clear the forces.
...
...
@@ -174,6 +180,7 @@ public:
zero
.
store
(
&
data
.
threadForce
[
threadIndex
][
j
*
4
]);
}
int
numParticles
;
bool
positionsValid
;
ContextImpl
&
context
;
CpuPlatform
::
PlatformData
&
data
;
};
...
...
@@ -198,6 +205,8 @@ void CpuCalcForcesAndEnergyKernel::beginComputation(ContextImpl& context, bool i
InitForceTask
task
(
context
.
getSystem
().
getNumParticles
(),
context
,
data
);
data
.
threads
.
execute
(
task
);
data
.
threads
.
waitForThreads
();
if
(
!
task
.
positionsValid
)
throw
OpenMMException
(
"Particle coordinate is nan"
);
}
double
CpuCalcForcesAndEnergyKernel
::
finishComputation
(
ContextImpl
&
context
,
bool
includeForce
,
bool
includeEnergy
,
int
groups
)
{
...
...
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