I wonder if there is an analog to boost compute Function (http://www.boost.org/doc/libs/1_61_0/libs/compute/doc/html/boost_compute/advanced_topics.html#boost_compute.advanced_topics.custom_functions ) that turns into kernel and can be created as embedded inline code that turns into a kernel?
Asked
Active
Viewed 143 times
0
-
4You can use [a functor with thrust](https://github.com/thrust/thrust/wiki/Quick-Start-Guide), or [lambda expressions](https://devblogs.nvidia.com/parallelforall/new-features-cuda-7-5/). – Robert Crovella Jun 17 '16 at 11:56
1 Answers
3
In thrust, you can use function/functor with __device__
qualifier. An example of vector operation saxpy
is shown in the link, where you could find the functor saxpy_functor
http://docs.nvidia.com/cuda/thrust/#transformations
Similar to boost::compute
, you could also use thrust lambda expression as
thrust::transform(X.begin(), X.end(), Y.begin(), Y.begin(), A * _1 + _2);
or more standard C++ lambda expression as shown by @RobertCrovella.

kangshiyin
- 9,681
- 1
- 17
- 29