2012-02-11 44 views
3

即時通訊在這裏得到一個惱人的消息,我不太清楚即時通訊做錯了什麼。無法爲推力:: cuda min_element()函數建立一個比較謂詞

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:\程序文件\ NVIDIA圖形處理器計算 工具箱\ CUDA \ V4.0 \包括\推力\詳細\設備\通用\ extrema.inl(104): 錯誤:函數「equalOperator :: operator()」不能調用 給定的參數列表

謝謝!

+0

你能添加什麼編譯器認爲該給予n參數列表是? – 2012-02-12 03:24:22

回答

5

花了幾個小時的案件後,我設法解決這個問題。 後,我長的審查,我進入了執行min_element()功能,並調用選擇恰當的operator(),我提供我發現我失去了一些

常量

因此,這裏的答案.INL文件:

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

我花了幾天......

+0

請注意,官方Thrust doc的示例中不包含「const」,但我觀察到的結果與您所做的相同。 – foothill 2017-03-07 00:34:05