PrevUpHomeNext

Macro BOOST_COMPUTE_CLOSURE

BOOST_COMPUTE_CLOSURE

Synopsis

// In header: <boost/compute/closure.hpp>

BOOST_COMPUTE_CLOSURE(return_type, name, arguments, capture, source)

Description

Creates a closure function object with name and source.

For example, to create a function which checks if a 2D point is contained in a circle of a given radius:

// radius variable declared in C++
float radius = 1.5f;

// create a closure function which returns true if the 2D point
// argument is contained within a circle of the given radius
BOOST_COMPUTE_CLOSURE(bool, is_in_circle, (const float2_ p), (radius),
{
    return sqrt(p.x*p.x + p.y*p.y) < radius;
});

// vector of 2D points
boost::compute::vector<float2_> points = ...

// count number of points in the circle
size_t count = boost::compute::count_if(
    points.begin(), points.end(), is_in_circle, queue
);

See Also:

BOOST_COMPUTE_FUNCTION()

Parameters:

arguments

A list of arguments for the function.

capture

A list of variables to capture.

name

The name of the function.

return_type

The return type for the function.

source

The OpenCL C source code for the function.


PrevUpHomeNext