vexcl
vexcl copied to clipboard
Copying Memory location of an OpenCl backend using VexCL and using that location with Boost.compute
Is it possible to Copy Memory location of an OpenCl backend using VexCL and using that location with Boost.compute? As Boost.compute uses vector type..
Something like this? https://vexcl.readthedocs.io/en/latest/interop.html
I will try this and let you know. Btw, Thank you.
Hi,for Boost.compute i can convert the boost vector into vexcl vector but I am also trying to convert the opencl (Cl mem object) to a vexcl vector. Is it possible?
Yes, vex::vector may be initialized with vex::device_vector<T>
:
https://vexcl.readthedocs.io/en/latest/memory.html#_CPPv4N3vex6vector6vectorERKN7backend13command_queueERKN7backend13device_vectorI1TEE6size_t
and vex::device_vector<T>
may be constructed from cl::Buffer
:
https://github.com/ddemidov/vexcl/blob/5097dc6b6614235dcf2ce59f402e63618dfbaab1/vexcl/backend/opencl/device_vector.hpp#L66
vex::vector
When I was trying to create the inline vector it doesn't work. It shows the error. I have the parameters to pass on to the inline vector but it doesn't work. Is there any problem in declaring the function?
The following works for me:
#include <vexcl/vexcl.hpp>
int main() {
vex::Context ctx(vex::Filter::Env && vex::Filter::Count(1));
std::cout << ctx << std::endl;
const int n = 1024;
// Raw OpenCL buffer
cl::Buffer raw(ctx.context(0), CL_MEM_READ_WRITE, n * sizeof(float));
// vex::vector wrapping the buffer
vex::vector<float> vec(ctx.queue(0), raw, n);
vec = 42.0f;
}