gpt4 book ai didi

boost-compute - boost::compute 复制自定义结构

转载 作者:行者123 更新时间:2023-12-04 06:19:43 30 4
gpt4 key购买 nike

是否可以使用 boost::compute 复制自定义结构数组?例如

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());

最佳答案

是的,看this example来自 Boost.Compute 测试。请记住:

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 (i.e. no padding bytes between members).

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

关于boost-compute - boost::compute 复制自定义结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40732161/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com