thrust::reduce_by_keyzipと順列のイテレータを使用して実行しようとしています。つまり、これをいくつかの「仮想」置換配列のzip配列で実行します。ファンクターの構文を書くのに問題がありますdensity_update。
しかし、最初に問題の設定。
これが私の関数呼び出しです:
thrust::reduce_by_key( dflagt,
dflagtend,
thrust::make_zip_iterator(
thrust::make_tuple(
thrust::make_permutation_iterator(dmasst, dmapt),
thrust::make_permutation_iterator(dvelt, dmapt),
thrust::make_permutation_iterator(dmasst, dflagt),
thrust::make_permutation_iterator(dvelt, dflagt)
)
),
thrust::make_discard_iterator(),
danswert,
thrust::equal_to<int>(),
density_update()
)
dmapt、dflagtはタイプthrust::device_ptr<int>とdvelt、、dmasstはdanstタイプ
thrust::device_ptr<double>です。
(それらは私の生のcuda配列へのスラストラッパーです)
配列maptとflagtは両方ともインデックスベクトルであり、そこから配列dmasstとから収集操作を実行する必要がありますdvelt。
danswert縮小ステップの後、データを配列に書き込むつもりです。削減には複数の配列が使用されているため、明らかにzipイテレータを使用しています。
density_update私の問題は、二項演算で あるファンクターを書くことにあります。
struct density_update
{
typedef thrust::device_ptr<double> ElementIterator;
typedef thrust::device_ptr<int> IndexIterator;
typedef thrust::permutation_iterator<ElementIterator,IndexIterator> PIt;
typedef thrust::tuple< PIt , PIt , PIt, PIt> Tuple;
__host__ __device__
double operator()(const Tuple& x , const Tuple& y)
{
return thrust::get<0>(*x) * (thrust::get<1>(*x) - thrust::get<3>(*x)) + \
thrust::get<0>(*y) * (thrust::get<1>(*y) - thrust::get<3>(*y));
}
};
返される値はdoubleです。二項演算が上記のファンクターのように見える理由は重要ではありません。上記を構文的に修正する方法を知りたいだけです。上に示したように、コードはいくつかのコンパイルエラーをスローしています。どこが間違っているのかわかりません。
Ubuntu10.10のGTX570でCUDA4.0を使用しています