Skip to content

Commit

Permalink
Merge pull request #43 from peastman/queue
Browse files Browse the repository at this point in the history
Removed separate queue for uploading forces
  • Loading branch information
peastman authored Jan 17, 2021
2 parents cf4efd7 + 0c0aeed commit e253b70
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 1 addition & 6 deletions platforms/opencl/src/OpenCLPlumedKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ OpenCLCalcPlumedForceKernel::~OpenCLCalcPlumedForceKernel() {
}

void OpenCLCalcPlumedForceKernel::initialize(const System& system, const PlumedForce& force) {
queue = cl::CommandQueue(cl.getContext(), cl.getDevice());
int elementSize = (cl.getUseDoublePrecision() ? sizeof(double) : sizeof(float));
plumedForces = new OpenCLArray(cl, 3*system.getNumParticles(), elementSize, "plumedForces");
map<string, string> defines;
Expand Down Expand Up @@ -227,7 +226,7 @@ void OpenCLCalcPlumedForceKernel::executeOnWorkerThread() {
buffer[3*i+2] = (float) p[2];
}
}
queue.enqueueWriteBuffer(plumedForces->getDeviceBuffer(), CL_FALSE, 0, plumedForces->getSize()*plumedForces->getElementSize(), cl.getPinnedBuffer(), NULL, &syncEvent);
plumedForces->upload(cl.getPinnedBuffer(), false);
}

double OpenCLCalcPlumedForceKernel::addForces(bool includeForces, bool includeEnergy, int groups) {
Expand All @@ -237,10 +236,6 @@ double OpenCLCalcPlumedForceKernel::addForces(bool includeForces, bool includeEn
// Wait until executeOnWorkerThread() is finished.

cl.getWorkThread().flush();
vector<cl::Event> events(1);
events[0] = syncEvent;
syncEvent = cl::Event();
queue.enqueueWaitForEvents(events);

// Add in the forces.

Expand Down
2 changes: 0 additions & 2 deletions platforms/opencl/src/OpenCLPlumedKernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ class OpenCLCalcPlumedForceKernel : public CalcPlumedForceKernel {
OpenMM::OpenCLContext& cl;
OpenMM::OpenCLArray* plumedForces;
cl::Kernel addForcesKernel;
cl::CommandQueue queue;
cl::Event syncEvent;
int lastStepIndex, forceGroupFlag;
std::vector<double> masses, charges;
std::vector<OpenMM::Vec3> positions, forces;
Expand Down

0 comments on commit e253b70

Please sign in to comment.