我有 相同的長度 在裝置上的整數dmap
和dflag
的兩個陣列和我與推力裝置指針包裹它們,dmapt
和 dflagt
類型推力的返回值的::的remove_if
有dmap數組中值爲-1的一些元素。我想 從dflag數組中刪除這些-1和相應的值從 。
我正在使用remove_if函數來做到這一點,但我無法弄清楚 這個調用的返回值是什麼或我該如何使用這個 得到的返回值。
(我想這些降低數組傳遞到reduce_by_key
功能 其中dflagt將被用作密鑰。)
我使用下列調用做的減少。請讓我 知道我可以存儲在一個變量返回的值,並 用它來解決各個陣列dflag
和dmap
thrust::remove_if(
thrust::make_zip_iterator(thrust::make_tuple(dmapt, dflagt)),
thrust::make_zip_iterator(thrust::make_tuple(dmapt+numindices, dflagt+numindices)),
minus_one_equality_test()
);
其中上面使用的謂詞函子被定義爲
struct minus_one_equality_test
{
typedef typename thrust::tuple<int,int> Tuple;
__host__ __device__
bool operator()(const Tuple& a)
{
return thrust::get<0>(a) == (-1);
}
}