无法为thrust :: cuda min_element()函数构建比较谓词

3

我收到了一个烦人的消息,但我不确定自己做错了什么。

float4 *IntsOnHost = new float4[ MAXX * (MAXY - 1) ];
//copy possible intersection points from device to host
CU_SAFE_CALL(cudaMemcpy(IntsOnHost,IntsOnDevToCpyToHost,(MAXX*(MAXY - 1)-1)*sizeof(float4),cudaMemcpyDeviceToHost));
thrust::device_vector<float4> IntsOnDev (IntsOnHost,IntsOnHost + (MAXX * (MAXY - 1)-1)*sizeof(float4)); 
//find the index of the smallest intersection point
thrust::device_vector<float4>::iterator it =  thrust::min_element(IntsOnDev.begin(),IntsOnDev.end(),equalOperator());   

以及谓词:

struct equalOperator
{
  __host__ __device__
    bool operator()(float4 x, float4 y)
    {
        return ( x.w > y.w );
    }
};

错误信息:

1>c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\device\generic\extrema.inl(104): 错误:无法使用给定的参数列表调用函数“equalOperator::operator()”

谢谢!


你能否添加编译器认为的给定参数列表是什么? - Jared Hoberock
1个回答

5

我花了几个小时的时间来解决这个问题。经过长时间的审查,我进入执行min_element()函数并调用我提供的相应的operator()的.inl文件中,发现我遗漏了一些

const

因此,答案如下:

struct equalOperator
{
  __host__ __device__
    bool operator()(const float4 x, const float4 y) const
    {
        return ( x.w > y.w );
    }
};  

花了我几天的时间...


请注意,官方的Thrust文档示例中不包括“const”,但我观察到与您相同的结果。 - foothill

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接