igal k
igal k

Reputation: 1914

can't build a comparison predicate for thrust::cuda min_element() function

im getting here an annoying message and im not quite sure what im doing wrong.

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());   

and the predicate:

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

the error message :

1>c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\device\generic\extrema.inl(104): error : function "equalOperator::operator()" cannot be called with the given argument list

thanks!

Upvotes: 2

Views: 839

Answers (1)

igal k
igal k

Reputation: 1914

After spending a few hours on the case I managed to solve the problem. After I a long reviewing, I entered the .inl file that executes the min_element() function and calls the approriate operator() that I have provided I noticed I was missing some

const

So here's the answer :

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

took me few days...

Upvotes: 4

Related Questions