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
e7d78e5f
Unverified
Commit
e7d78e5f
authored
Sep 05, 2024
by
Peter Eastman
Committed by
GitHub
Sep 05, 2024
Browse files
Merge pull request #4645 from peastman/customcpp
Prevent deadlock using CustomCPPForceImpl with multiple GPUs
parents
3b8df952
da106c00
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
7 deletions
+28
-7
platforms/common/src/CommonKernels.cpp
platforms/common/src/CommonKernels.cpp
+22
-7
platforms/cuda/tests/TestCudaCustomCPPForce.cpp
platforms/cuda/tests/TestCudaCustomCPPForce.cpp
+2
-0
platforms/hip/tests/TestHipCustomCPPForce.cpp
platforms/hip/tests/TestHipCustomCPPForce.cpp
+2
-0
platforms/opencl/tests/TestOpenCLCustomCPPForce.cpp
platforms/opencl/tests/TestOpenCLCustomCPPForce.cpp
+2
-0
No files found.
platforms/common/src/CommonKernels.cpp
View file @
e7d78e5f
...
...
@@ -8245,15 +8245,29 @@ void CommonCalcCustomCPPForceKernel::initialize(const System& system, CustomCPPF
addForcesKernel->addArg(cc.getLongForceBuffer());
addForcesKernel->addArg(cc.getAtomIndexArray());
forceGroupFlag = (1<<force.getOwner().getForceGroup());
if (cc.getNumContexts() == 1) {
cc.addPreComputation(new StartCalculationPreComputation(*this));
cc.addPostComputation(new AddForcesPostComputation(*this));
}
}
double CommonCalcCustomCPPForceKernel::execute(ContextImpl& context, bool includeForces, bool includeEnergy) {
if (cc.getNumContexts() == 1) {
// This method does nothing. The actual calculation is started by the pre-computation, continued on
// the worker thread, and finished by the post-computation.
return 0;
}
// When using multiple GPUs, this method is itself called from the worker thread.
// Submitting additional tasks and waiting for them to complete would lead to
// a deadlock.
if (cc.getContextIndex() != 0)
return 0.0;
contextImpl.getPositions(positionsVec);
executeOnWorkerThread(includeForces);
return addForces(includeForces, includeEnergy, -1);
}
void CommonCalcCustomCPPForceKernel::beginComputation(bool includeForces, bool includeEnergy, int groups) {
...
...
@@ -8290,6 +8304,7 @@ double CommonCalcCustomCPPForceKernel::addForces(bool includeForces, bool includ
// Wait until executeOnWorkerThread() is finished.
if (cc.getNumContexts() == 1)
cc.getWorkThread().flush();
// Add in the forces.
...
...
platforms/cuda/tests/TestCudaCustomCPPForce.cpp
View file @
e7d78e5f
...
...
@@ -33,5 +33,7 @@
#include "TestCustomCPPForce.h"
void
runPlatformTests
()
{
platform
.
setPropertyDefaultValue
(
"DeviceIndex"
,
"0,0"
);
testForce
();
}
platforms/hip/tests/TestHipCustomCPPForce.cpp
View file @
e7d78e5f
...
...
@@ -33,4 +33,6 @@
#include "TestCustomCPPForce.h"
void
runPlatformTests
()
{
platform
.
setPropertyDefaultValue
(
"DeviceIndex"
,
"0,0"
);
testForce
();
}
platforms/opencl/tests/TestOpenCLCustomCPPForce.cpp
View file @
e7d78e5f
...
...
@@ -33,5 +33,7 @@
#include "TestCustomCPPForce.h"
void
runPlatformTests
()
{
platform
.
setPropertyDefaultValue
(
"DeviceIndex"
,
"0,0"
);
testForce
();
}
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