I've looked through a lot of questions here for something similar and there are quite a few, albeit with one minor change. I'm trying to sort values with a zip_iterator as a compound key.
Specifically, I have the following function:
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()); }
and this custom predicate:
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;
}
};
The errors I'm getting are:
Error 1 error : no instance of constructor "thrust::device_ptr::device_ptr [with T=unsigned int]" matches the argument list C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\thrust\detail\tuple.inl 309 1 --- Error 2 error : no instance of constructor "thrust::device_ptr::device_ptr [with T=float]" matches the argument list C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\thrust\detail\tuple.inl 401 1 ---
Any ideas what might cause this / how do I write a predicate that indeed works?
Thanks in Advance, Nathan