"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "19c403f2c25b37e56bd68911104cab243d0b051e"
Unverified Commit 3d62421b authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fixed freeze when using multiple GPUs (#3668)

parent dd80fb3f
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2019 Stanford University and the Authors. * * Portions copyright (c) 2019-2022 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -555,6 +555,10 @@ public: ...@@ -555,6 +555,10 @@ public:
* Get whether the worker thread has exited. * Get whether the worker thread has exited.
*/ */
bool isFinished(); bool isFinished();
/**
* Get whether the thread invoking this method is the worker thread.
*/
bool isCurrentThread();
/** /**
* Block until all tasks have finished executing and the worker thread is idle. * Block until all tasks have finished executing and the worker thread is idle.
*/ */
......
...@@ -1812,7 +1812,8 @@ public: ...@@ -1812,7 +1812,8 @@ public:
double computeForceAndEnergy(bool includeForces, bool includeEnergy, int groups) { double computeForceAndEnergy(bool includeForces, bool includeEnergy, int groups) {
if ((groups&(1<<force->getForceGroup())) == 0) if ((groups&(1<<force->getForceGroup())) == 0)
return 0; return 0;
cc.getWorkThread().flush(); if (!cc.getWorkThread().isCurrentThread())
cc.getWorkThread().flush();
Vec3 a, b, c; Vec3 a, b, c;
cc.getPeriodicBoxVectors(a, b, c); cc.getPeriodicBoxVectors(a, b, c);
double volume = a[0]*b[1]*c[2]; double volume = a[0]*b[1]*c[2];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2019-2021 Stanford University and the Authors. * * Portions copyright (c) 2019-2022 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -716,6 +716,10 @@ bool ComputeContext::WorkThread::isFinished() { ...@@ -716,6 +716,10 @@ bool ComputeContext::WorkThread::isFinished() {
return finished; return finished;
} }
bool ComputeContext::WorkThread::isCurrentThread() {
return (pthread_self() == thread);
}
void ComputeContext::WorkThread::flush() { void ComputeContext::WorkThread::flush() {
pthread_mutex_lock(&queueLock); pthread_mutex_lock(&queueLock);
while (!waiting) while (!waiting)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment