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
91d56f74
Commit
91d56f74
authored
Sep 05, 2024
by
Peter Eastman
Browse files
Prevent deadlock using CustomCPPForceImpl with multiple GPUs
parent
3b8df952
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
platforms/common/src/CommonKernels.cpp
platforms/common/src/CommonKernels.cpp
+22
-7
No files found.
platforms/common/src/CommonKernels.cpp
View file @
91d56f74
...
...
@@ -8245,15 +8245,29 @@ void CommonCalcCustomCPPForceKernel::initialize(const System& system, CustomCPPF
addForcesKernel->addArg(cc.getLongForceBuffer());
addForcesKernel->addArg(cc.getAtomIndexArray());
forceGroupFlag = (1<<force.getOwner().getForceGroup());
cc.addPreComputation(new StartCalculationPreComputation(*this));
cc.addPostComputation(new AddForcesPostComputation(*this));
if (cc.getNumContexts() == 1) {
cc.addPreComputation(new StartCalculationPreComputation(*this));
cc.addPostComputation(new AddForcesPostComputation(*this));
}
}
double CommonCalcCustomCPPForceKernel::execute(ContextImpl& context, bool includeForces, bool includeEnergy) {
// 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;
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,7 +8304,8 @@ double CommonCalcCustomCPPForceKernel::addForces(bool includeForces, bool includ
// Wait until executeOnWorkerThread() is finished.
cc.getWorkThread().flush();
if (cc.getNumContexts() == 1)
cc.getWorkThread().flush();
// Add in the forces.
...
...
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