2013-01-13 124 views
1

根據CUDA的Thrust library documentationthrust::inclusive_scan()有參數:CUDA的thrust :: inclusive_scan()是否有'init'參數?

OutputIterator thrust::inclusive_scan(InputIterator  first, 
             InputIterator  last, 
             OutputIterator  result, 
             AssociativeOperator binary_op 
            ) 

然而,在使用示範(同一文檔中),他們通過參數。一個額外的第四個參數被作爲掃描(酷似thrust::exclusive_scan())的初值通過:

int data[10] = {-5, 0, 2, -3, 2, 4, 0, -1, 2, 8}; 
thrust::maximum<int> binary_op; 
thrust::inclusive_scan(data, data + 10, data, 1, binary_op); // in-place scan 

現在,我的代碼將只編譯通過4個參數(經過5給出了錯誤no instance of overloaded function "thrust::inclusive_scan" matches the argument list),但我碰巧需要就像在這個例子中初始化我的滾動最大值。

任何人都可以澄清如何初始化包容性掃描?

非常感謝。

+0

你在哪裏找到這種用法的示範? – Bart

+0

在Thrust庫文檔中:http://docs.thrust.googlecode.com/hg/group__prefixsums.html#ga7109170b96a48fab736e52b75f423464 – mchen

+0

哈,除非我沒有得到什麼東西,這似乎是錯誤的。也許報告吧。 – Bart

回答

2

看來你不明白包容性掃描操作是什麼。沒有像初始化包容性掃描那樣的事情。根據定義,包含式掃描的第一個值始終是序列的第一個元素。

所以對於序列

[ 1, 2, 3, 4, 5, 6, 7 ] 

包容掃描

[ 1, 3, 6, 10, 15, 21, 28 ] 

和獨特的掃描(初始化爲零)是

[ 0, 1, 3, 6, 10, 15, 21 ] 
+0

是的,我明白了。我想我對Thrust庫文檔中的錯誤用法演示感到困惑。謝謝。 – mchen

相關問題