【发布时间】:2014-09-20 11:15:17
【问题描述】:
我试图根据第一个向量的值从两个 thrust::device_vector<int> 中删除元素。直觉上我创建了以下片段:
thrust::device_vector<float> idxToValue(COUNT_MAX);
thrust::device_vector<int> idxSorted(COUNT_MAX);
thrust::device_vector<int> groupIdxSorted(COUNT_MAX);
int count = COUNT_MAX;
float const minThreshold = MIN_THRESHOLD;
auto idxToValueSortedIter = thrust::make_permutation_iterator(
idxToValue.begin()
, idxSorted.begin()
);
auto new_end = thrust::remove_if(
thrust::make_zip_iterator(thrust::make_tuple(idxSorted.begin(), groupIdxSorted.begin()))
, thrust::make_zip_iterator(thrust::make_tuple(idxSorted.begin() + count, groupIdxSorted.begin() + count))
, idxToValueSortedIter
, thrust::placeholders::_1 >= minThreshold
);
count = thrust::get<0>(new_end.get_iterator_tuple()) - idxSorted.begin();
不幸的是,推力文档说
范围 [stencil, stencil + (last - first)) 不得与范围 [result, result + (last - first)) 重叠
所以在我的情况下,用作模板序列的idxToValueSortedIter 取决于idxSorted,实际上与结果重叠(相同的向量)。
有什么办法可以在不将数据复制到临时向量的情况下解决这个问题?
【问题讨论】: