Я просмотрел здесь много вопросов в поисках чего-то похожего, и их довольно много, хотя и с одним небольшим изменением. Я пытаюсь отсортировать значения с помощью итератора zip_в качестве составного ключа.
В частности, у меня есть следующая функция:
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;
}
};
Ошибки, которые я получаю::
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 ---
Любые идеи, что может вызвать это/как мне написать предикат, который действительно работает?
Заранее спасибо! Натан