我收到一条烦人的消息,我不太确定我做错了什么。
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计算toolkit\cuda\v4.0\include\trust\detail\device\generic\extra.inl(104):错误:函数"equalOperator::operator()"不能用给定参数列表
谢谢!
在花了几个小时研究这个案例后,我设法解决了这个问题。经过长时间的回顾,我输入了执行min_element()
函数并调用我提供的相应operator()
的.inl文件。我注意到我缺少了一些
const
答案是:
struct equalOperator
{
__host__ __device__
bool operator()(const float4 x, const float4 y) const
{
return ( x.w > y.w );
}
};
我花了几天时间。。。