0
我收到的主旨的模板實例中的編譯時錯誤嘗試執行以下操作時:推力copy_if設備到主機
thrust::copy_if(deviceEntries.begin(), deviceEntries.end(), hostResultBuffer->begin(),
IsEntrySelected(rootLayer));
定義爲IsEntrySelected:
struct IsEntrySelected : thrust::unary_function<Entry, bool> {
inline IsEntrySelected(const unsigned long int layer):_layer(layer) {}
__device__ __host__
inline bool operator()(const Entry & val) const {
return val.selected && val.layer == _layer;
}
private:
unsigned long int _layer;
};
是該操作可能?我可以通過將結果放置在GPU上的中間device_vector緩衝區中來使用相同的調用,而不是直接複製到主機緩衝區,但希望避免這樣做來節省GPU內存。有沒有另外一種方法可以避免額外的GPU緩衝區的方式有條件地過濾和複製到主機上?