簡體   English   中英

boost :: compute copy自定義結構

[英]boost::compute copy custom structures

是否可以使用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());

是的,從Boost.Compute測試看這個例子 請記住:

由於主機編譯器和設備編譯器之間的struct padding不同,BOOST_COMPUTE_ADAPT_STRUCT()宏要求對適配的結構進行打包(即成員之間沒有填充字節)。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM