简体   繁体   English

boost :: compute copy自定义结构

[英]boost::compute copy custom structures

Is it possible to copy arrays of custom structures using boost::compute? 是否可以使用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. 是的,从Boost.Compute测试看这个例子 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). 由于主机编译器和设备编译器之间的struct padding不同,BOOST_COMPUTE_ADAPT_STRUCT()宏要求对适配的结构进行打包(即成员之间没有填充字节)。

Source: boost/compute/types/struct.hpp 来源: boost / compute / types / struct.hpp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM