Я пытаюсь написать пользовательскую функцию для выполнения суммы. Я следил за этим вопросом Пользовательская функция Cuda Thrust, чтобы взять ссылку. Вот как я определил свой функтор
struct hashElem
{
int freq;
int error;
};
//basically this function adds some value to to the error field of each element
struct hashErrorAdd{
const int error;
hashErrorAdd(int _error): error(_error){}
__host__ __device__
struct hashElem operator()(const hashElem& o1,const int& o2)
{
struct hashElem o3;
o3.freq = o1.freq;
o3.error = o1.error + (NUM_OF_HASH_TABLE-o2)*error; //NUM_OF_HASH_TABLE is a constant
return o3;
}
};
struct hashElem freqError[SIZE_OF_HASH_TABLE*NUM_OF_HASH_TABLE];
int count[SIZE_OF_HASH_TABLE*NUM_OF_HASH_TABLE];
thrust::device_ptr<struct hashElem> d_freqError(freqError);
thrust::device_ptr<int> d_count(count);
thrust::transform(thrust::device,d_freqError,d_freqError+new_length,d_count,hashErrorAdd(perThreadLoad)); //new_length is a constant
Этот код при компиляции дает следующую ошибку:
ошибка: функция "hashErrorAdd::operator()" не может быть вызвана с заданным списком аргументов
типы аргументов: (hashElem)
тип объекта: hashErrorAdd
Пожалуйста, может кто-нибудь объяснить мне, почему я получаю эту ошибку? и как я могу это решить. Пожалуйста, прокомментируйте, если я не могу четко объяснить проблему. Спасибо.