Cuda 如何将make_transform_iterator()与counting_iterator一起使用<&燃气轮机;政策的执行力如何?

Cuda 如何将make_transform_iterator()与counting_iterator一起使用<&燃气轮机;政策的执行力如何?,cuda,gpgpu,nvidia,thrust,Cuda,Gpgpu,Nvidia,Thrust,我尝试用MSVS2012、CUDA5.5和1.7版本编译这段代码: #include <iostream> #include <thrust/iterator/counting_iterator.h> #include <thrust/iterator/transform_iterator.h> #include <thrust/find.h> #include <thrust/execution_policy.h> struct

我尝试用MSVS2012、CUDA5.5和1.7版本编译这段代码:

#include <iostream>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/find.h>

#include <thrust/execution_policy.h>

struct is_odd {
  __host__ __device__ bool operator()(uint64_t &x) {
    return x & 1;
  }
};

int main() {
    thrust::counting_iterator<uint64_t> first(0);
    thrust::counting_iterator<uint64_t> last = first + 100;

    auto iter = thrust::find(thrust::device,
                thrust::make_transform_iterator(first, is_odd()),
                thrust::make_transform_iterator(last, is_odd()),
                true);

    int bbb; std::cin >> bbb;
    return 0;
}
#包括
#包括
#包括
#包括
#包括
结构是奇数{
__主机设备布尔运算符(){
返回x&1;
}
};
int main(){
首先计算迭代器(0);
推力::计数迭代器last=first+100;
自动iter=推力::查找(推力::设备,
推力::make_transform_迭代器(首先是_odd()),
推力::make_transform_迭代器(最后一个是_odd()),
正确的);
int bbb;std::cin>>bbb;
返回0;
}
并获取一个错误:

错误1错误:不允许使用不完整的类型C:\Program Files\NVIDIA GPU计算工具包\CUDA\v5.5\include\推力\detail\type\u traits.h 413 1主机设备


如果我使用主机/设备向量而不是计数迭代器,那么一切正常。怎么了?

我稍微更改了你的函子定义,如下所示:

struct is_odd {
  __host__ __device__ bool operator()(uint64_t &x) {
为此:

struct is_odd : public thrust::unary_function<uint64_t, bool> {
  __host__ __device__ bool operator()(const uint64_t &x) {
结构是奇数:公共推力::一元函数{ __主机设备布尔运算符(){ 它为我编译