Unverified Commit ee037398 authored by peastman's avatar peastman Committed by GitHub
Browse files

Updated to latest version of OpenCL C++ API (#2962)

parent e23dc927
......@@ -27,12 +27,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#define __CL_ENABLE_EXCEPTIONS
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_TARGET_OPENCL_VERSION 120
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#include "openmm/OpenMMException.h"
#include "openmm/common/windowsExportCommon.h"
#include "openmm/common/ArrayInterface.h"
#include <cl.hpp>
#include <opencl.hpp>
#include <iostream>
#include <sstream>
#include <vector>
......
......@@ -29,8 +29,9 @@
#include <map>
#include <string>
#define __CL_ENABLE_EXCEPTIONS
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_TARGET_OPENCL_VERSION 120
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#ifndef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
#define CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 0x4040
#endif
......@@ -48,7 +49,7 @@
#define NOMINMAX
#endif
#include <pthread.h>
#include <cl.hpp>
#include <opencl.hpp>
#include "openmm/common/windowsExportCommon.h"
#include "OpenCLArray.h"
#include "OpenCLBondedUtilities.h"
......
......@@ -29,7 +29,6 @@
#include "OpenCLArray.h"
#include "OpenCLContext.h"
#include <cl.hpp>
#include <string>
#include <vector>
......
......@@ -31,7 +31,6 @@
#include "OpenCLArray.h"
#include "OpenCLExpressionUtilities.h"
#include "openmm/common/NonbondedUtilities.h"
#include <cl.hpp>
#include <sstream>
#include <string>
#include <vector>
......
......@@ -614,10 +614,7 @@ cl::Program OpenCLContext::createProgram(const string source, const map<string,
if (!defines.empty())
src << endl;
src << source << endl;
// Get length before using c_str() to avoid length() call invalidating the c_str() value.
string src_string = src.str();
::size_t src_length = src_string.length();
cl::Program::Sources sources(1, make_pair(src_string.c_str(), src_length));
cl::Program::Sources sources({src.str()});
cl::Program program(context, sources);
try {
program.build(vector<cl::Device>(1, device), options.c_str());
......
......@@ -32,7 +32,7 @@ OpenCLEvent::OpenCLEvent(OpenCLContext& context) : context(context) {
}
void OpenCLEvent::enqueue() {
context.getQueue().enqueueMarker(&event);
context.getQueue().enqueueMarkerWithWaitList(NULL, &event);
}
void OpenCLEvent::wait() {
......
......@@ -26,7 +26,6 @@
#include "OpenCLIntegrationUtilities.h"
#include "OpenCLContext.h"
#include <cl.hpp>
using namespace OpenMM;
using namespace std;
......
......@@ -60,7 +60,7 @@ static void setPosqCorrectionArg(OpenCLContext& cl, cl::Kernel& kernel, int inde
if (cl.getUseMixedPrecision())
kernel.setArg<cl::Buffer>(index, cl.getPosqCorrection().getDeviceBuffer());
else
kernel.setArg<void*>(index, NULL);
kernel.setArg(index, sizeof(void*), NULL);
}
static void setPeriodicBoxSizeArg(OpenCLContext& cl, cl::Kernel& kernel, int index) {
......@@ -598,8 +598,8 @@ public:
void computeForceAndEnergy(bool includeForces, bool includeEnergy, int groups) {
if ((groups&(1<<forceGroup)) != 0) {
vector<cl::Event> events(1);
cl.getQueue().enqueueMarker(&events[0]);
queue.enqueueWaitForEvents(events);
cl.getQueue().enqueueMarkerWithWaitList(NULL, &events[0]);
queue.enqueueBarrierWithWaitList(&events);
}
}
private:
......@@ -624,7 +624,7 @@ public:
vector<cl::Event> events(1);
events[0] = event;
event = cl::Event();
cl.getQueue().enqueueWaitForEvents(events);
cl.getQueue().enqueueBarrierWithWaitList(&events);
if (includeEnergy)
cl.executeKernel(addEnergyKernel, pmeEnergyBuffer.getSize());
}
......@@ -1320,8 +1320,8 @@ double OpenCLCalcNonbondedForceKernel::execute(ContextImpl& context, bool includ
cl.executeKernel(computeExclusionParamsKernel, exclusionParams.getSize());
if (usePmeQueue) {
vector<cl::Event> events(1);
cl.getQueue().enqueueMarker(&events[0]);
pmeQueue.enqueueWaitForEvents(events);
cl.getQueue().enqueueMarkerWithWaitList(NULL, &events[0]);
pmeQueue.enqueueBarrierWithWaitList(&events);
}
if (hasOffsets)
energy = 0.0; // The Ewald self energy was computed in the kernel.
......@@ -1563,7 +1563,7 @@ double OpenCLCalcNonbondedForceKernel::execute(ContextImpl& context, bool includ
cl.executeKernel(pmeDispersionInterpolateForceKernel, cl.getNumAtoms());
}
if (usePmeQueue) {
pmeQueue.enqueueMarker(&pmeSyncEvent);
pmeQueue.enqueueMarkerWithWaitList(NULL, &pmeSyncEvent);
cl.restoreDefaultQueue();
}
}
......@@ -1852,8 +1852,8 @@ void OpenCLCalcCustomCVForceKernel::copyState(ContextImpl& context, ContextImpl&
copyStateKernel.setArg<cl::Buffer>(5, cl2.getPosqCorrection().getDeviceBuffer());
}
else {
copyStateKernel.setArg<void*>(1, NULL);
copyStateKernel.setArg<void*>(5, NULL);
copyStateKernel.setArg(1, sizeof(void*), NULL);
copyStateKernel.setArg(5, sizeof(void*), NULL);
}
copyForcesKernel.setArg<cl::Buffer>(1, invAtomOrder.getDeviceBuffer());
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -29,9 +29,12 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_TARGET_OPENCL_VERSION 120
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#include "OpenCLTests.h"
#include "TestNonbondedForce.h"
#include <cl.hpp>
#include <opencl.hpp>
#include <string>
void testParallelComputation(NonbondedForce::NonbondedMethod method) {
......
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