ddemidov / vexcl

VexCL is a C++ vector expression template library for OpenCL/CUDA/OpenMP
http://vexcl.readthedocs.org
MIT License
699 stars 81 forks source link

Is it possible to create an Boost Compute vector and wrap a vexcl vector with Compute vector? #288

Open kafi350 opened 2 years ago

kafi350 commented 2 years ago

As given in the documentation we can do it for the vexcl but not for the compute vecotrs.

ddemidov commented 2 years ago

Both boost.compute and vexcl vectors are just wrappers around raw opencl buffers, so the conversion is possible both ways.

kafi350 commented 2 years ago

// Wrap boost.compute vectors into vexcl vectors (no data is copied): compute::vector bcv(n, bcq.get_context()); vex::vector y({bcq}, bcv.get_buffer()); y = x * 2;

this is the way to wrap a compute vector but is it possible to wrap a vex vector?

ddemidov commented 2 years ago

See examples in <vexcl/external/boost_compute.hpp>, which uses Boost.compute algorithms with vexcl vectors:

https://github.com/ddemidov/vexcl/blob/ec0cc1fe037f68a9d1c19f56960e92cd820f4f20/vexcl/external/boost_compute.hpp#L60-L102