Is it possible to copy arrays of custom structures using boost::compute? Eg
struct A { float a; };
struct AB { float a; float b; };
BOOST_COMPUTE_ADAPT_STRUCT(A, A, (a))
BOOST_COMPUTE_ADAPT_STRUCT(AB, AB, (a, b))
boost::compute::vector<A> va(100);
boost::compute::vector<AB> vab(100);
boost::compute::copy(va.begin(), va.end(), vab.begin());
Yes, look at this example from Boost.Compute tests. Remember that:
Due to differences in struct padding between the host compiler and the device compiler, the BOOST_COMPUTE_ADAPT_STRUCT() macro requires that the adapted struct is packed (ie no padding bytes between members).
Source: boost/compute/types/struct.hpp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.