0
我試圖根據第一個向量的值從兩個thrust::device_vector<int>
中移除元素。憑直覺我創建了以下剪斷:CUDA推力remove_if與operlapping模板序列
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();
推力單證不幸說
範圍[模板,模板+(最後一個 - 第一))應當互不重疊的範圍[結果,結果+(最後 - 第一))
所以在我的情況下idxToValueSortedIter
,其被用作模版序列,取決於idxSorted
實際上是在重疊的結果(相同的載體)。
有沒有辦法解決這個問題,而不需要將數據複製到臨時向量?
我實際上在尋找一種避免自定義函子的方法(即通過使用佔位符),但這是我所要求的,它的工作原理!謝謝! – wondering 2014-09-21 18:19:04