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缓冲区的方式有条件地过滤和复制到主机上?