Cuda thrust - xutility: name followed by “::” must be a class or namespace

元气小坏坏 提交于 2019-12-13 11:01:34

问题


I would like to use thrust reduction in my CUDA application. Hence I include the header and call the function:

#include <thrust\reduce.h>

__host__ void reduction(){
    unsigned int t = 0;
    thrust::reduce(t,t);
}

However I get compile errors (only one type): "name followed by "::" must be a class or namespace". The problem is with a file called xutility (which i haven't touched). All errors are related to the follow class definition:

    // TEMPLATE CLASS iterator_traits
template<class _Iter>
    struct iterator_traits
    {   // get traits from iterator _Iter
    typedef typename _Iter::iterator_category iterator_category;
    typedef typename _Iter::value_type value_type;
    typedef typename _Iter::difference_type difference_type;
    typedef difference_type distance_type;  // retained
    typedef typename _Iter::pointer pointer;
    typedef typename _Iter::reference reference;
    };

I am not really into template programming. What am I doing wrong?


回答1:


Thrust routines are all designed to be invoked from the host side rather than in the kernels.

See this for the example of using thrust::reduce.

https://github.com/thrust/thrust/blob/master/examples/sum.cu



来源:https://stackoverflow.com/questions/19209736/cuda-thrust-xutility-name-followed-by-must-be-a-class-or-namespace

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!