我在这里查看了很多类似的问题,虽然有一些小的变化。我正在尝试使用zip_iterator作为复合键对值进行排序。
具体来说,我有以下函数:
我收到的错误信息如下:
提前感谢, Nathan
具体来说,我有以下函数:
void thrustSort( unsigned int * primaryKey, float * secondaryKey, unsigned int * values, unsigned int numberOfPoints) { thrust::device_ptr dev_ptr_pkey = thrust::device_pointer_cast(primaryKey); thrust::device_ptr dev_ptr_skey = thrust::device_pointer_cast(secondaryKey); thrust::device_ptr dev_ptr_values = thrust::device_pointer_cast(values);以及以下自定义谓词:
thrust::tuple,thrust::device_ptr> keytup_begin = thrust::make_tuple,thrust::device_ptr>(dev_ptr_pkey, dev_ptr_skey);
thrust::zip_iterator, thrust::device_ptr > > first = thrust::make_zip_iterator, thrust::device_ptr > >(keytup_begin);
thrust::sort_by_key(first, first + numberOfPoints, dev_ptr_values, ZipComparator()); }
typedef thrust::device_ptr<unsigned int> tdp_uint ;
typedef thrust::device_ptr<float> tdp_float ;
typedef thrust::tuple<tdp_uint, tdp_float> tdp_uif_tuple ;
struct ZipComparator
{
__host__ __device__
inline bool operator() (const tdp_uif_tuple &a, const tdp_uif_tuple &b)
{
if(a.head < b.head) return true;
if(a.head == b.head) return a.tail < b.tail;
return false;
}
};
我收到的错误信息如下:
错误1:错误:没有与参数列表匹配的构造函数“thrust :: device_ptr :: device_ptr [with T = unsigned int]” C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v4.0 \ include \ thrust \ detail \ tuple.inl 309 1 --- 错误2:错误:没有与参数列表匹配的构造函数“thrust :: device_ptr :: device_ptr [with T = float]” C:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v4.0 \ include \ thrust \ detail \ tuple.inl 401 1 ---你有什么想法是什么导致这个问题出现的吗?怎样编写一个确实有效的谓词呢?
提前感谢, Nathan