2016-06-17 29 views
0

我想知道是否有一種模擬方法可以提升計算功能(http://www.boost.org/doc/libs/1_61_0/libs/compute/doc/html/boost_compute/advanced_topics.html#boost_compute.advanced_topics.custom_functions),它可以轉化爲內核,並且可以創建爲嵌入式內嵌代碼,從而變成內核?Thrust中是否存在boost計算函數的類比?

+4

您可以使用[帶推力的函數](https://github.com/thrust/thrust/wiki/Quick-Start-Guide)或[lambda表達式](https://devblogs.nvidia.com/ parallelforall /新功能,CUDA-7-5 /)。 –

回答

3

在推力,你可以使用函數/函子與__device__限定符。向量運算saxpy的一個例子示於鏈路,在這裏可以找到算符saxpy_functor

http://docs.nvidia.com/cuda/thrust/#transformations

類似於boost::compute,您也可以使用推力lambda表達式作爲

thrust::transform(X.begin(), X.end(), Y.begin(), Y.begin(), A * _1 + _2); 

或多種標準C++ lambda表達式,如@RobertCrovella所示。

相關問題