我想在我的CUDA應用程序中使用減推力。因此,我包括頭和調用函數:Cuda的推力 - xutility:名稱,後跟「::」必須是類或命名空間
#include <thrust\reduce.h>
__host__ void reduction(){
unsigned int t = 0;
thrust::reduce(t,t);
}
但是我得到的編譯錯誤(只有一種類型):「名字後面加上‘::’必須是類或命名空間」。問題在於一個名爲xutility的文件(我沒有碰過)。所有的錯誤都與下列類別定義有關:
// 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;
};
我沒有真正進入模板編程。我究竟做錯了什麼?
會是什麼'(無效)推力::減少(threadIdx.x,threadIdx.x);'連做,如果它編譯?如果你要問一個關於語法錯誤,以及如何解決這些問題,至少沒有禮貌表現出一些實際的代碼和一個實際的編譯器錯誤和行號,無些廢話僞代碼。 – talonmies
我試圖提供一個最小的例子;因爲這個最小例子中的錯誤依然存在,所以我認爲最好不要包含整個源代碼。編譯器錯誤與前面所述完全相同。我決定提供導致錯誤的行而不是行號,以便您不必滾動瀏覽xutility文件。 – emher