here is the most basic bare bone code sample. that can generates the error.
#include "opencl.hpp"
int main()
{
std::vector<cl::Platform> cl_platforms;
cl::Platform::get(&cl_platforms);
std::vector<cl::Device> devices_available;
cl_platforms[0].getDevices(CL_DEVICE_TYPE_ALL, &devices_available);
cl_int error = 0;
cl::Device device = devices_available[0];
cl::Context context(device, nullptr, nullptr, nullptr, &error);
cl::CommandQueue queue(context, device, 0, &error);
_ASSERT(error == CL_SUCCESS);
static char memory[100];
//cl::Buffer testBuffer(device, CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS, size_t(100), memory, &error);
cl::Buffer testBuffer(device, CL_MEM_READ_WRITE, cl::size_type(1000), nullptr, &error);
_ASSERT(error == CL_SUCCESS);
// this fail with error CL_INVALID_CONTEXT
error = queue.enqueueReadBuffer(testBuffer, CL_FALSE, 0, 100, memory);
//error = m_queue->enqueueWriteBuffer(testBuffer, CL_TRUE, 0, 100, memory);
// this fail with error CL_INVALID_CONTEXT
error = queue.enqueueWriteBuffer(testBuffer, CL_FALSE, 0, 100, memory);
_ASSERT(error == CL_INVALID_CONTEXT);
_ASSERT(error == CL_SUCCESS);
return 0;
}
I searched the forum as well as plenty of other site dedicated to opencl,
but it seems that opencl CPP, has not being adopted to the point that people can make tutorial to explain these kind of issues.
I am guessing that I most create a different context for moving data form host to gpu buffer,
by the api docs, does not seems to show any insight for doing that.
I am at a complete lost, If any one can provide some answer, It will be appreciated.
Julio