Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying Memory location of an OpenCl backend using VexCL and using that location with Boost.compute #284

Open
kafi350 opened this issue Jun 25, 2021 · 6 comments

Comments

@kafi350
Copy link

kafi350 commented Jun 25, 2021

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..

@ddemidov
Copy link
Owner

Something like this?
https://vexcl.readthedocs.io/en/latest/interop.html

@kafi350
Copy link
Author

kafi350 commented Jun 25, 2021

I will try this and let you know. Btw, Thank you.

@kafi350
Copy link
Author

kafi350 commented Jun 28, 2021

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?

@ddemidov
Copy link
Owner

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:

device_vector(cl::Buffer buffer) : buffer( std::move(buffer) ) {}

@kafi350
Copy link
Author

kafi350 commented Jul 11, 2021

vex::vector a(&queue, &buffer, data_size);

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?

@ddemidov
Copy link
Owner

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants