January 2018
Intermediate to advanced
374 pages
9h 53m
English
As mentioned, we are using strings for the OpenCL source code. In order to get a little bit more readability, Boost Compute comes with a convenience macro called BOOST_COMPUTE_FUNCTION, which makes strings out of the source code parameter.
The following table shows a syntactical comparison of them:
|
Using make_function_from_source: |
Using BOOST_COMPUTE_FUNCTION macro: |
namespace bc = boost::compute;
auto circle_area_gpu = bc::make_function_from_source <float(Circle)> (
"circle_area_gpu","float circle_area_gpu(Circle c){"" float pi = 3.14f; "" return c.r * c.r * pi; ""} "); |
BOOST_COMPUTE_FUNCTION( float, // Return type circle_area_gpu, // Name (Circle c), // Arg { float pi = 3.14f; return c.r * c.r ... |