# Header Reference

Meta-header to include all Boost.Compute algorithm headers.

T `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `T

initial value

` `BinaryFunction

binary reduction function

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Returns the result of applying `function` to the elements in the range [`first`, `last`) and `init`.

If no function is specified, `plus` will be used.

In specific situations the call to `accumulate()` can be automatically optimized to a call to the more efficient `reduce()` algorithm. This occurs when the binary reduction function is recognized as associative (such as the `plus<int>` function).

Note that because floating-point addition is not associative, calling `accumulate()` with `plus<float>` results in a less efficient serial reduction algorithm being executed. If a slight loss in precision is acceptable, the more efficient parallel `reduce()` algorithm should be used instead.

For example:

    // with vec = boost::compute::vector<int>
    accumulate(vec.begin(), vec.end(), 0, plus<int>());   // fast
    reduce(vec.begin(), vec.end(), &result, plus<int>()); // fast

    // with vec = boost::compute::vector<float>
    accumulate(vec.begin(), vec.end(), 0, plus<float>());   // slow
    reduce(vec.begin(), vec.end(), &result, plus<float>()); // fast

Space complexity: \Omega(1) Space complexity when optimized to `reduce()`: \Omega(n)

# See Also:

reduce()

the accumulated result value

T `InputIterator` `InputIterator` `T` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
OutputIterator `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `OutputIterator

first element in the output range

` `BinaryFunction

binary difference function

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Stores the difference of each pair of consecutive values in the range [`first`, `last`) to the range beginning at `result`. If `op` is not provided, `minus<T>` is used.

Space complexity: \Omega(1) Space complexity when `result` == `first:` \Omega(n)

# See Also:

adjacent_find()

`OutputIterator` to the end of the result range

OutputIterator `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
InputIterator `InputIterator

first element in the range to search

` `InputIterator

last element in the range to search

` `Compare

binary comparison function

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Searches the range [`first`, `last`) for two identical adjacent elements and returns an iterator pointing to the first.

Space complexity: \Omega(1)

# See Also:

find(), adjacent_difference()

`InputIteratorm` to the first element which compares equal to the following element. If none are equal, returns `last`.

InputIterator `InputIterator` `InputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool `InputIterator` `InputIterator` `UnaryPredicate` ``command_queue` &system::default_queue()`

Returns `true` if `predicate` returns `true` for all of the elements in the range [`first`, `last`).

Space complexity: \Omega(1)

# See Also:

any_of(), none_of()

bool `InputIterator` `InputIterator` `UnaryPredicate` ``command_queue` &system::default_queue()`

Returns `true` if `predicate` returns `true` for any of the elements in the range [`first`, `last`).

For example, to test if a vector contains any negative values:

Space complexity: \Omega(1)

# See Also:

all_of(), none_of()

bool `InputIterator` `InputIterator` `const T &` ``command_queue` &system::default_queue()`

Returns `true` if `value` is in the sorted range [`first`, `last`).

Space complexity: \Omega(1)

OutputIterator `InputIterator

first element in the range to copy

` `InputIterator

last element in the range to copy

` `OutputIterator

first element in the result range

` ``command_queue` &system::default_queue()

command queue to perform the operation

` `const `wait_list` &wait_list()`

Copies the values in the range [`first`, `last`) to the range beginning at `result`.

The generic copy() function can be used for a variety of data transfer tasks and provides a standard interface to the following OpenCL functions:

- `clEnqueueReadBuffer()`

- `clEnqueueWriteBuffer()`

- `clEnqueueCopyBuffer()`

Unlike the aforementioned OpenCL functions, copy() will also work with non-contiguous data-structures (e.g. `std::list<T>`) as well as with "fancy" iterators (e.g. transform_iterator).

For example, to copy an array of `int` values on the host to a vector on the device:

    // array on the host
    int data[] = { 1, 2, 3, 4 };

    // vector on the device
    boost::compute::vector<int> vec(4, context);

    // copy values to the device vector
    boost::compute::copy(data, data + 4, vec.begin(), queue);

The copy algorithm can also be used with standard containers such as `std::vector<T>`:

    std::vector<int> host_vector = ...
    boost::compute::vector<int> device_vector = ...

    // copy from the host to the device
    boost::compute::copy(
        host_vector.begin(), host_vector.end(), device_vector.begin(), queue
    );

    // copy from the device to the host
    boost::compute::copy(
        device_vector.begin(), device_vector.end(), host_vector.begin(), queue
    );

Space complexity: \Omega(1)

# See Also:

copy_n(), copy_if(), copy_async()

`OutputIterator` to the end of the result range

`future`< OutputIterator > `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()` `const `wait_list` &wait_list()`

Copies the values in the range [`first`, `last`) to the range beginning at `result`. The copy is performed asynchronously.

# See Also:

copy()

OutputIterator `InputIterator` `InputIterator` `OutputIterator` `Predicate` ``command_queue` &system::default_queue()`

Copies each element in the range [`first`, `last`) for which `predicate` returns `true` to the range beginning at `result`.

Space complexity: \Omega(2n)

OutputIterator `InputIterator` `Size` `OutputIterator` ``command_queue` &system::default_queue()` `const `wait_list` &wait_list()`

Copies `count` elements from `first` to `result`.

For example, to copy four values from the host to the device:

    // values on the host and vector on the device
    float values[4] = { 1.f, 2.f, 3.f, 4.f };
    boost::compute::vector<float> vec(4, context);

    // copy from the host to the device
    boost::compute::copy_n(values, 4, vec.begin(), queue);

Space complexity: \Omega(1)

# See Also:

copy()

size_t `InputIterator` `InputIterator` `const T &` ``command_queue` &system::default_queue()`

Returns the number of occurrences of `value` in the range [`first`, `last`).

Space complexity on CPUs: \Omega(1) Space complexity on GPUs: \Omega(n)

# See Also:

count_if()

size_t `InputIterator` `InputIterator` `Predicate` ``command_queue` &system::default_queue()`

Returns the number of elements in the range [`first`, `last`) for which `predicate` returns `true`.

Space complexity on CPUs: \Omega(1) Space complexity on GPUs: \Omega(n)

bool `InputIterator1` `InputIterator1` `InputIterator2` ``command_queue` &system::default_queue()`

Returns `true` if the range [`first1`, `last1`) and the range beginning at `first2` are equal.

Space complexity: \Omega(1)

bool `InputIterator1` `InputIterator1` `InputIterator2` `InputIterator2` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::pair< InputIterator, InputIterator > `InputIterator` `InputIterator` `const T &` ``command_queue` &system::default_queue()`

Returns a pair of iterators containing the range of values equal to `value` in the sorted range [`first`, `last`).

Space complexity: \Omega(1)

OutputIterator `InputIterator

first element in the range to scan

` `InputIterator

last element in the range to scan

` `OutputIterator

first element in the result range

` `T

value used to initialize the scan sequence

` `BinaryOperator

associative binary operator

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Performs an exclusive scan of the elements in the range [`first`, `last`) and stores the results in the range beginning at `result`.

Each element in the output is assigned to the sum of all the previous values in the input.

The default operation is to add the elements up.

But different associative operation can be specified as `binary_op` instead (e.g., multiplication, maximum, minimum). Also value used to initialized the scan sequence can be specified.

Space complexity on GPUs: \Omega(n) Space complexity on GPUs when `first` == `result:` \Omega(2n) Space complexity on CPUs: \Omega(1)

# See Also:

inclusive_scan()

`OutputIterator` to the end of the result range

OutputIterator `InputIterator` `InputIterator` `OutputIterator` `T` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
OutputIterator `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `BufferIterator

first element in the range to fill

` `BufferIterator

last element in the range to fill

` `const T &

value to copy to each element

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Fills the range [`first`, `last`) with `value`.

For example, to fill a vector on the device with sevens:

    // vector on the device
    boost::compute::vector<int> vec(10, context);

    // fill vector with sevens
    boost::compute::fill(vec.begin(), vec.end(), 7, queue);

Space complexity: \Omega(1)

# See Also:

boost::compute::fill_n()

`future`< void > `BufferIterator` `BufferIterator` `const T &` ``command_queue` &system::default_queue()`
void `BufferIterator` `Size` `const T &` ``command_queue` &system::default_queue()`

Fills the range [`first`, `first` + count) with `value`.

Space complexity: \Omega(1)

# See Also:

fill()

InputIterator `InputIterator` `InputIterator` `const T &` ``command_queue` &system::default_queue()`

Returns an iterator pointing to the first element in the range [`first`, `last`) that equals `value`.

Space complexity: \Omega(1)

TextIterator `TextIterator

Iterator pointing to start of text

` `TextIterator

Iterator pointing to end of text

` `PatternIterator

Iterator pointing to start of pattern

` `PatternIterator

Iterator pointing to end of pattern

` ``command_queue` &system::default_queue()

Queue on which to execute

` Substring matching algorithm.

Searches for the last match of the pattern [p_first, p_last) in text [t_first, t_last).

Space complexity: \Omega(n)

Iterator pointing to beginning of last occurence

InputIterator `InputIterator` `InputIterator` `UnaryPredicate` ``command_queue` &system::default_queue()`

Returns an iterator pointing to the first element in the range [`first`, `last`) for which `predicate` returns `true`.

Space complexity: \Omega(1)

InputIterator `InputIterator` `InputIterator` `UnaryPredicate` ``command_queue` &system::default_queue()`

Returns an iterator pointing to the first element in the range [`first`, `last`) for which `predicate` returns `false`.

Space complexity: \Omega(1)

# See Also:

find_if()

UnaryFunction `InputIterator` `InputIterator` `UnaryFunction` ``command_queue` &system::default_queue()`

Calls `function` on each element in the range [`first`, `last`).

Space complexity: \Omega(1)

# See Also:

transform()

UnaryFunction `InputIterator` `Size` `UnaryFunction` ``command_queue` &system::default_queue()`

Calls `function` on each element in the range [`first`, `first` `+` `count`).

Space complexity: \Omega(1)

# See Also:

for_each()

void `MapIterator` `MapIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()`

Copies the elements using the indices from the range [`first`, `last`) to the range beginning at `result` using the input values from the range beginning at `input`.

Space complexity: \Omega(1)

# See Also:

scatter()

void `OutputIterator` `OutputIterator` `Generator` ``command_queue` &system::default_queue()`

Stores the result of `generator` for each element in the range [`first`, `last`).

Space complexity: \Omega(1)

void `OutputIterator` `Size` `Generator` ``command_queue` &system::default_queue()`

Stores the result of `generator` for each element in the range [`first`, `first` + `count`).

Space complexity: \Omega(1)

bool `InputIterator1

Iterator pointing to start of first set

` `InputIterator1

Iterator pointing to end of first set

` `InputIterator2

Iterator pointing to start of second set

` `InputIterator2

Iterator pointing to end of second set

` ``command_queue` &system::default_queue()

Queue on which to execute

` Includes algorithm.

Finds if the sorted range [first1, last1) includes the sorted range [first2, last2). In other words, it checks if [first1, last1) is a superset of [first2, last2).

Space complexity: \Omega(distance(`first1`, `last1`) + distance(`first2`, `last2`))

True, if [first1, last1) includes [first2, last2). False otherwise.

OutputIterator `InputIterator

first element in the range to scan

` `InputIterator

last element in the range to scan

` `OutputIterator

first element in the result range

` `BinaryOperator

associative binary operator

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Performs an inclusive scan of the elements in the range [`first`, `last`) and stores the results in the range beginning at `result`.

Each element in the output is assigned to the sum of the current value in the input with the sum of every previous value in the input.

The default operation is to add the elements up.

But different associative operation can be specified as `binary_op` instead (e.g., multiplication, maximum, minimum).

Space complexity on GPUs: \Omega(n) Space complexity on GPUs when `first` == `result:` \Omega(2n) Space complexity on CPUs: \Omega(1)

# See Also:

exclusive_scan()

`OutputIterator` to the end of the result range

OutputIterator `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
T `InputIterator1` `InputIterator1` `InputIterator2` `T` ``command_queue` &system::default_queue()`

Returns the inner product of the elements in the range [`first1`, `last1`) with the elements in the range beginning at `first2`.

Space complexity: \Omega(1) Space complexity when binary operator is recognized as associative: \Omega(n)

T `InputIterator1` `InputIterator1` `InputIterator2` `T` `BinaryAccumulateFunction` `BinaryTransformFunction` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `Iterator` `Iterator` `Iterator` ``command_queue` &system::default_queue()`

Merges the sorted values in the range [`first`, `middle`) with the sorted values in the range [`middle`, `last`) in-place.

Space complexity: \Omega(n)

void `BufferIterator` `BufferIterator` `const T &` ``command_queue` &system::default_queue()`

Fills the range [`first`, `last`) with sequential values starting at `value`.

For example, the following code:

Will fill `vec` with the values (`0`, `1`, `2`, ``...).

Space complexity: \Omega(1)

bool `InputIterator` `InputIterator` `UnaryPredicate` ``command_queue` &system::default_queue()`

Returns `true` if the values in the range [`first`, `last`) are partitioned according to `predicate`.

Space complexity: \Omega(1)

bool `InputIterator1

Iterator pointing to start of first range

` `InputIterator1

Iterator pointing to end of first range

` `InputIterator2

Iterator pointing to start of second range

` `InputIterator2

Iterator pointing to end of second range

` ``command_queue` &system::default_queue()

Queue on which to execute

` Permutation checking algorithm.

Checks if the range [first1, last1) can be permuted into the range [first2, last2)

Space complexity: \Omega(distance(`first1`, `last1`) + distance(`first2`, `last2`))

True, if it can be permuted. False, otherwise.

bool `InputIterator

first element in the range to check

` `InputIterator

last element in the range to check

` `Compare

comparison function (by default `less`)

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Returns `true` if the values in the range [`first`, `last`) are in sorted order.

Space complexity: \Omega(1)

# See Also:

sort()

`true` if the range [`first`, `last`) is sorted

bool `InputIterator` `InputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool `InputIterator1` `InputIterator1` `InputIterator2` `InputIterator2` ``command_queue` &system::default_queue()`

Checks if the first range [first1, last1) is lexicographically less than the second range [first2, last2).

Space complexity: \Omega(max(distance(`first1`, `last1`), distance(`first2`, `last2`)))

InputIterator `InputIterator` `InputIterator` `const T &` ``command_queue` &system::default_queue()`

Returns an iterator pointing to the first element in the sorted range [`first`, `last`) that is not less than `value`.

Space complexity: \Omega(1)

# See Also:

upper_bound()

InputIterator `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `Compare

comparison function object which returns true if the first argument is less than (i.e. is ordered before) the second.

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Returns an iterator pointing to the element in the range [`first`, `last`) with the maximum value.

For example, to find `int2` value with maximum first component in given vector:

    // comparison function object
    BOOST_COMPUTE_FUNCTION(bool, compare_first, (const int2_ &a, const int2_ &b),
    {
        return a.x < b.x;
    });

    // create vector
    boost::compute::vector<uint2_> data = ...

    boost::compute::vector<uint2_>::iterator max =
        boost::compute::max_element(data.begin(), data.end(), compare_first, queue);

Space complexity on CPUs: \Omega(1) Space complexity on GPUs: \Omega(N)

# See Also:

min_element()

InputIterator `InputIterator` `InputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
OutputIterator `InputIterator1

first element in the first range to merge

` `InputIterator1

last element in the first range to merge

` `InputIterator2

first element in the second range to merge

` `InputIterator2

last element in the second range to merge

` `OutputIterator

first element in the result range

` `Compare

comparison function (by default `less`)

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Merges the sorted values in the range [`first1`, `last1`) with the sorted values in the range [`first2`, last2) and stores the result in the range beginning at `result`. Values are compared using the `comp` function. If no comparision function is given, `less` is used.

Space complexity: \Omega(distance(`first1`, `last1`) + distance(`first2`, `last2`))

# See Also:

inplace_merge()

`OutputIterator` to the end of the result range

OutputIterator `InputIterator1` `InputIterator1` `InputIterator2` `InputIterator2` `OutputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
InputIterator `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `Compare

comparison function object which returns true if the first argument is less than (i.e. is ordered before) the second.

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Returns an iterator pointing to the element in range [`first`, `last`) with the minimum value.

For example, to find `int2` value with minimum first component in given vector:

    // comparison function object
    BOOST_COMPUTE_FUNCTION(bool, compare_first, (const int2_ &a, const int2_ &b),
    {
        return a.x < b.x;
    });

    // create vector
    boost::compute::vector<uint2_> data = ...

    boost::compute::vector<uint2_>::iterator min =
        boost::compute::min_element(data.begin(), data.end(), compare_first, queue);

Space complexity on CPUs: \Omega(1) Space complexity on GPUs: \Omega(N)

# See Also:

max_element()

InputIterator `InputIterator` `InputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::pair< InputIterator, InputIterator > `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `Compare

comparison function object which returns true if the first argument is less than (i.e. is ordered before) the second.

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Returns a pair of iterators with the first pointing to the minimum element and the second pointing to the maximum element in the range [`first`, `last`).

Space complexity on CPUs: \Omega(1) Space complexity on GPUs: \Omega(N)

# See Also:

max_element(), min_element()

std::pair< InputIterator, InputIterator > `InputIterator` `InputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::pair< InputIterator1, InputIterator2 > `InputIterator1` `InputIterator1` `InputIterator2` ``command_queue` &system::default_queue()`

Returns a pair of iterators pointing to the first position where the range [`first1`, `last1`) and the range starting at `first2` differ.

Space complexity: \Omega(1)

std::pair< InputIterator1, InputIterator2 > `InputIterator1` `InputIterator1` `InputIterator2` `InputIterator2` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool `InputIterator

Iterator pointing to start of range

` `InputIterator

Iterator pointing to end of range

` ``command_queue` &system::default_queue()

Queue on which to execute

` Permutation generating algorithm.

Transforms the range [first, last) into the next permutation from the set of all permutations arranged in lexicographic order

Space complexity: \Omega(1)

Boolean value signifying if the last permutation was crossed and the range was reset

bool `InputIterator` `InputIterator` `UnaryPredicate` ``command_queue` &system::default_queue()`

Returns `true` if `predicate` returns `true` for none of the elements in the range [`first`, `last`).

Space complexity: \Omega(1)

# See Also:

all_of(), any_of()

void `Iterator` `Iterator` `Iterator` `Compare` ``command_queue` &system::default_queue()`

Rearranges the elements in the range [`first`, `last`) such that the `nth` element would be in that position in a sorted sequence.

Space complexity: \Omega(3n)

void `Iterator` `Iterator` `Iterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
OutputIterator `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()`

Calculates the cumulative sum of the elements in the range [`first`, `last`) and writes the resulting values to the range beginning at `result`.

Space complexity on GPUs: \Omega(n) Space complexity on GPUs when `first` == `result:` \Omega(2n) Space complexity on CPUs: \Omega(1)

Iterator `Iterator` `Iterator` `UnaryPredicate` ``command_queue` &system::default_queue()`

Partitions the elements in the range [`first`, `last`) according to `predicate`. Order of the elements need not be preserved.

Space complexity: \Omega(3n)

# See Also:

is_partitioned() and stable_partition()

std::pair< OutputIterator1, OutputIterator2 > `InputIterator` `InputIterator` `OutputIterator1` `OutputIterator2` `UnaryPredicate` ``command_queue` &system::default_queue()`

Copies all of the elements in the range [`first`, `last`) for which `predicate` returns `true` to the range beginning at `first_true` and all of the elements for which `predicate` returns `false` to the range beginning at `first_false`.

Space complexity: \Omega(2n)

# See Also:

partition()

InputIterator `InputIterator

Iterator pointing to start of range

` `InputIterator

Iterator pointing to end of range

` `UnaryPredicate

Unary predicate to be applied on each element

` ``command_queue` &system::default_queue()

Queue on which to execute

` Partition point algorithm.

Finds the end of true values in the partitioned range [first, last)

Space complexity: \Omega(1)

# See Also:

partition() and stable_partition()

Iterator pointing to end of true values

bool `InputIterator

Iterator pointing to start of range

` `InputIterator

Iterator pointing to end of range

` ``command_queue` &system::default_queue()

Queue on which to execute

` Permutation generating algorithm.

Transforms the range [first, last) into the previous permutation from the set of all permutations arranged in lexicographic order

Space complexity: \Omega(1)

Boolean value signifying if the first permutation was crossed and the range was reset

void `Iterator` `Iterator` ``command_queue` &system::default_queue()`

Randomly shuffles the elements in the range [`first`, `last`).

Space complexity: \Omega(2n)

# See Also:

scatter()

void `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `OutputIterator

iterator pointing to the output

` `BinaryFunction

binary reduction function

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Returns the result of applying `function` to the elements in the range [`first`, `last`).

If no function is specified, `plus` will be used.

The `reduce()` algorithm assumes that the binary reduction function is associative. When used with non-associative functions the result may be non-deterministic and vary in precision. Notably this affects the `plus<float>()` function as floating-point addition is not associative and may produce slightly different results than a serial algorithm.

This algorithm supports both host and device iterators for the result argument. This allows for values to be reduced and copied to the host all with a single function call.

For example, to calculate the sum of the values in a device vector and copy the result to a value on the host:

Note that while the the `reduce()` algorithm is conceptually identical to the `accumulate()` algorithm, its implementation is substantially more efficient on parallel hardware. For more information, see the documentation on the `accumulate()` algorithm.

Space complexity on GPUs: \Omega(n) Space complexity on CPUs: \Omega(1)

# See Also:

accumulate()

void `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::pair< OutputKeyIterator, OutputValueIterator > `InputKeyIterator

the first key

` `InputKeyIterator

the last key

` `InputValueIterator

the first input value

` `OutputKeyIterator

iterator pointing to the key output

` `OutputValueIterator

iterator pointing to the reduced value output

` `BinaryFunction

binary reduction function

` `BinaryPredicate

binary predicate which returns true only if two keys are equal

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

The `reduce_by_key()` algorithm performs reduction for each contiguous subsequence of values determinate by equivalent keys.

Returns a pair of iterators at the end of the ranges [`keys_result`, keys_result_last) and [`values_result`, `values_result_last`).

If no function is specified, `plus` will be used. If no predicate is specified, `equal_to` will be used.

The `reduce_by_key()` algorithm assumes that the binary reduction function is associative. When used with non-associative functions the result may be non-deterministic and vary in precision. Notably this affects the `plus<float>()` function as floating-point addition is not associative and may produce slightly different results than a serial algorithm.

For example, to calculate the sum of the values for each key:

Space complexity on GPUs: \Omega(2n) Space complexity on CPUs: \Omega(1)

# See Also:

reduce()

std::pair< OutputKeyIterator, OutputValueIterator > `InputKeyIterator` `InputKeyIterator` `InputValueIterator` `OutputKeyIterator` `OutputValueIterator` `BinaryFunction` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::pair< OutputKeyIterator, OutputValueIterator > `InputKeyIterator` `InputKeyIterator` `InputValueIterator` `OutputKeyIterator` `OutputValueIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Iterator `Iterator` `Iterator` `const T &` ``command_queue` &system::default_queue()`

Removes each element equal to `value` in the range [`first`, `last`).

Space complexity: \Omega(3n)

# See Also:

remove_if()

Iterator `Iterator` `Iterator` `Predicate` ``command_queue` &system::default_queue()`

Removes each element for which `predicate` returns `true` in the range [`first`, `last`).

Space complexity: \Omega(3n)

# See Also:

remove()

void `Iterator` `Iterator` `const T &` `const T &` ``command_queue` &system::default_queue()`

Replaces each instance of `old_value` in the range [`first`, `last`) with `new_value`.

Space complexity: \Omega(1)

OutputIterator `InputIterator` `InputIterator` `OutputIterator` `const T &` `const T &` ``command_queue` &system::default_queue()`

Copies the value in the range [`first`, `last`) to the range beginning at `result` while replacing each instance of `old_value` with `new_value`.

Space complexity: \Omega(1)

# See Also:

replace()

void `Iterator` `Iterator` ``command_queue` &system::default_queue()`

Reverses the elements in the range [`first`, `last`).

Space complexity: \Omega(1)

# See Also:

reverse_copy()

OutputIterator `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()`

Copies the elements in the range [`first`, `last`) in reversed order to the range beginning at `result`.

Space complexity: \Omega(1)

# See Also:

reverse()

void `InputIterator` `InputIterator` `InputIterator` ``command_queue` &system::default_queue()`

Performs left rotation such that element at `n_first` comes to the beginning.

Space complexity: \Omega(distance(`first`, `last`))

# See Also:

rotate_copy()

void `InputIterator` `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()`

Performs left rotation such that element at n_first comes to the beginning and the output is stored in range starting at result.

Space complexity: \Omega(1)

# See Also:

rotate()

void `InputIterator` `InputIterator` `MapIterator` `OutputIterator` ``command_queue` &system::default_queue()`

Copies the elements from the range [`first`, `last`) to the range beginning at `result` using the output indices from the range beginning at `map`.

Space complexity: \Omega(1)

# See Also:

gather()

void `InputIterator` `InputIterator` `MapIterator` `StencilIterator` `OutputIterator` `Predicate` ``command_queue` &system::default_queue()`

Copies the elements from the range [`first`, `last`) to the range beginning at `result` using the output indices from the range beginning at `map` if stencil is resolved to true. By default the predicate is an identity

Space complexity: \Omega(1)

void `InputIterator` `InputIterator` `MapIterator` `StencilIterator` `OutputIterator` ``command_queue` &system::default_queue()`
TextIterator `TextIterator

Iterator pointing to start of text

` `TextIterator

Iterator pointing to end of text

` `PatternIterator

Iterator pointing to start of pattern

` `PatternIterator

Iterator pointing to end of pattern

` ``command_queue` &system::default_queue()

Queue on which to execute

` Substring matching algorithm.

Searches for the first match of the pattern [p_first, p_last) in text [t_first, t_last).

Space complexity: \Omega(distance(`t_first`, `t_last`))

Iterator pointing to beginning of first occurrence

TextIterator `TextIterator

Iterator pointing to start of text

` `TextIterator

Iterator pointing to end of text

` `size_t

Number of times value repeats

` `ValueType

Value which repeats

` ``command_queue` &system::default_queue()

Queue on which to execute

` Substring matching algorithm.

Searches for the first occurrence of n consecutive occurrences of value in text [t_first, t_last).

Space complexity: \Omega(distance(`t_first`, `t_last`))

Iterator pointing to beginning of first occurrence

OutputIterator `InputIterator1

Iterator pointing to start of first set

` `InputIterator1

Iterator pointing to end of first set

` `InputIterator2

Iterator pointing to start of second set

` `InputIterator2

Iterator pointing to end of second set

` `OutputIterator

Iterator pointing to start of range in which the difference will be stored

` ``command_queue` &system::default_queue()

Queue on which to execute

` Set difference algorithm.

Finds the difference of the sorted range [first2, last2) from the sorted range [first1, last1) and stores it in range starting at result

Space complexity: \Omega(2(distance(`first1`, `last1`) + distance(`first2`, `last2`)))

Iterator pointing to end of difference

OutputIterator `InputIterator1

Iterator pointing to start of first set

` `InputIterator1

Iterator pointing to end of first set

` `InputIterator2

Iterator pointing to start of second set

` `InputIterator2

Iterator pointing to end of second set

` `OutputIterator

Iterator pointing to start of range in which the intersection will be stored

` ``command_queue` &system::default_queue()

Queue on which to execute

` Set intersection algorithm.

Finds the intersection of the sorted range [first1, last1) with the sorted range [first2, last2) and stores it in range starting at result

Space complexity: \Omega(2(distance(`first1`, `last1`) + distance(`first2`, `last2`)))

Iterator pointing to end of intersection

OutputIterator `InputIterator1

Iterator pointing to start of first set

` `InputIterator1

Iterator pointing to end of first set

` `InputIterator2

Iterator pointing to start of second set

` `InputIterator2

Iterator pointing to end of second set

` `OutputIterator

Iterator pointing to start of range in which the symmetric difference will be stored

` ``command_queue` &system::default_queue()

Queue on which to execute

` Set symmetric difference algorithm.

Finds the symmetric difference of the sorted range [first2, last2) from the sorted range [first1, last1) and stores it in range starting at result

Space complexity: \Omega(2(distance(`first1`, `last1`) + distance(`first2`, `last2`)))

Iterator pointing to end of symmetric difference

OutputIterator `InputIterator1

Iterator pointing to start of first set

` `InputIterator1

Iterator pointing to end of first set

` `InputIterator2

Iterator pointing to start of second set

` `InputIterator2

Iterator pointing to end of second set

` `OutputIterator

Iterator pointing to start of range in which the union will be stored

` ``command_queue` &system::default_queue()

Queue on which to execute

` Set union algorithm.

Finds the union of the sorted range [first1, last1) with the sorted range [first2, last2) and stores it in range starting at result

Space complexity: \Omega(2(distance(`first1`, `last1`) + distance(`first2`, `last2`)))

Iterator pointing to end of union

void `Iterator

first element in the range to sort

` `Iterator

last element in the range to sort

` `Compare

comparison function (by default `less`)

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Sorts the values in the range [`first`, `last`) according to `compare`.

For example, to sort a vector on the device:

    // create vector on the device with data
    float data[] = { 2.f, 4.f, 1.f, 3.f };
    boost::compute::vector<float> vec(data, data + 4, queue);

    // sort the vector on the device
    boost::compute::sort(vec.begin(), vec.end(), queue);

The sort() algorithm can also be directly used with host iterators. This example will automatically transfer the data to the device, sort it, and then transfer the data back to the host:

    std::vector<int> data = { 9, 3, 2, 5, 1, 4, 6, 7 };

    boost::compute::sort(data.begin(), data.end(), queue);

Space complexity: \Omega(n)

# See Also:

is_sorted()

void `Iterator` `Iterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `KeyIterator` `KeyIterator` `ValueIterator` `Compare` ``command_queue` &system::default_queue()`

Performs a key-value sort using the keys in the range [`keys_first`, `keys_last`) on the values in the range [`values_first`, `values_first` `+` (`keys_last` `-` `keys_first`)) using `compare`.

If no compare function is specified, `less` is used.

Space complexity: \Omega(2n)

# See Also:

sort()

void `KeyIterator` `KeyIterator` `ValueIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Iterator `Iterator

Iterator pointing to start of range

` `Iterator

Iterator pointing to end of range

` `UnaryPredicate

Unary predicate to be applied on each element

` ``command_queue` &system::default_queue()

Queue on which to execute

` Partitioning algorithm.

Partitions the elements in the range [`first`, `last`) according to `predicate`. The order of the elements is preserved.

Space complexity: \Omega(3n)

# See Also:

is_partitioned() and partition()

Iterator pointing to end of true values

void `Iterator` `Iterator` `Compare` ``command_queue` &system::default_queue()`

Sorts the values in the range [`first`, `last`) according to `compare`. The relative order of identical values is preserved.

Space complexity: \Omega(n)

# See Also:

sort(), is_sorted()

void `Iterator` `Iterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `KeyIterator` `KeyIterator` `ValueIterator` `Compare` ``command_queue` &system::default_queue()`

Performs a key-value stable sort using the keys in the range [`keys_first`, `keys_last`) on the values in the range [`values_first`, `values_first` `+` (`keys_last` `-` `keys_first`)) using `compare`.

If no compare function is specified, `less` is used.

Space complexity: \Omega(2n)

# See Also:

sort()

void `KeyIterator` `KeyIterator` `ValueIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Iterator2 `Iterator1` `Iterator1` `Iterator2` ``command_queue` &system::default_queue()`

Swaps the elements in the range [`first1`, `last1`) with the elements in the range beginning at `first2`.

Space complexity: \Omega(distance(`first1`, `last1`))

OutputIterator `InputIterator` `InputIterator` `OutputIterator` `UnaryOperator` ``command_queue` &system::default_queue()`

Transforms the elements in the range [`first`, `last`) using operator `op` and stores the results in the range beginning at `result`.

For example, to calculate the absolute value for each element in a vector:

Space complexity: \Omega(1)

# See Also:

copy()

OutputIterator `InputIterator1` `InputIterator1` `InputIterator2` `OutputIterator` `BinaryOperator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
OutputIterator `InputIterator` `InputIterator` `OutputIterator` `UnaryFunction` `Predicate` ``command_queue` &system::default_queue()`

Copies each element in the range [`first`, `last`) for which `predicate` returns `true` to the range beginning at `result`.

Space complexity: O(2n)

void `InputIterator` `InputIterator` `OutputIterator` `UnaryTransformFunction` `BinaryReduceFunction` ``command_queue` &system::default_queue()`

Transforms each value in the range [`first`, `last`) with the unary `transform_function` and then reduces each transformed value with `reduce_function`.

For example, to calculate the sum of the absolute values of a vector of integers:

Space complexity on GPUs: \Omega(n) Space complexity on CPUs: \Omega(1)

# See Also:

reduce(), inner_product()

void `InputIterator1` `InputIterator1` `InputIterator2` `OutputIterator` `BinaryTransformFunction` `BinaryReduceFunction` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
InputIterator `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `BinaryPredicate

binary operator used to check for uniqueness

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Removes all consecutive duplicate elements (determined by `op`) from the range [first, last). If `op` is not provided, the equality operator is used.

Space complexity: \Omega(4n)

# See Also:

unique_copy()

`InputIterator` to the new logical end of the range

InputIterator `InputIterator` `InputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
OutputIterator `InputIterator

first element in the input range

` `InputIterator

last element in the input range

` `OutputIterator

first element in the result range

` `BinaryPredicate

binary operator used to check for uniqueness

` ``command_queue` &system::default_queue()

command queue to perform the operation

`

Makes a copy of the range [first, last) and removes all consecutive duplicate elements (determined by `op`) from the copy. If `op` is not provided, the equality operator is used.

Space complexity: \Omega(4n)

# See Also:

unique()

`OutputIterator` to the end of the result range

OutputIterator `InputIterator` `InputIterator` `OutputIterator` ``command_queue` &system::default_queue()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
InputIterator `InputIterator` `InputIterator` `const T &` ``command_queue` &system::default_queue()`

Returns an iterator pointing to the first element in the sorted range [`first`, `last`) that is not less than or equal to `value`.

Space complexity: \Omega(1)

Meta-header to include all Boost.Compute allocator headers.

The buffer_allocator class allocates memory with buffer objects.

# See Also:

buffer

T
unspecified
unspecified
std::size_t
std::ptrdiff_t
const `context` &
const `buffer_allocator`< T > &
`buffer_allocator`< T > & `const `buffer_allocator`< T > &`
buffer_allocator
< T > &&
`buffer_allocator`< T > & ``buffer_allocator`< T > &&`
pointer `size_type`
void `pointer` `size_type`
size_type
`context`
void `cl_mem_flags`
boost::compute::buffer_allocator< T >
const `context` &
const pinned_allocator< T > &
pinned_allocator< T > & `const pinned_allocator< T > &`

Meta-header to include all Boost.Compute async headers.

Holds the result of an asynchronous computation.

# See Also:

event, wait_list

const T &
const `event` &
const `future`< T > &
`future` & `const `future`< T > &`
T

Returns the result of the computation. This will block until the result is ready.

bool Returns `true` if the future is valid.
void Blocks until the computation is complete.
`event` Returns the underlying event object.
`future` & `Function`

Invokes a generic callback function once the future is ready.

The function specified by callback must be invokable with zero arguments.

See the documentation for

void class... `Events &&...`

Blocks until all events have completed. Events can either be event objects or future<T> objects.

# See Also:

event, wait_list

boost::noncopyable
A guard object for synchronizing an operation on the device.

The wait_guard class stores a waitable object representing an operation on a compute device (e.g. event, future<T>) and calls its `wait()` method when the guard object goes out of scope.

This is useful for ensuring that an OpenCL operation completes before leaving the current scope and cleaning up any resources.

For example:

    // enqueue a compute kernel for execution
    event e = queue.enqueue_nd_range_kernel(...);

    // call e.wait() upon exiting the current scope
    wait_guard<event> guard(e);

wait_list, wait_for_all()

const Waitable &
Creates a new wait_guard object for `waitable`.

Destroys the wait_guard object. The default implementation will call `wait()` on the stored waitable object.

boost::compute::memory_object
A memory buffer on a compute device.

The buffer class represents a memory buffer on a compute device.

Buffers are allocated within a compute context. For example, to allocate a memory buffer for 32 float's:

Once created, data can be copied to and from the buffer using the `enqueue_*_buffer`() methods in the command_queue class. For example, to copy a set of `int` values from the host to the device:

    int data[] = { 1, 2, 3, 4 };

    queue.enqueue_write_buffer(buf, 0, 4 * sizeof(int), data);

Also see the copy() algorithm for a higher-level interface to copying data between the host and the device. For a higher-level, dynamically-resizable, type-safe container for data on a compute device, use the vector<T> class.

Buffer objects have reference semantics. Creating a copy of a buffer object simply creates another reference to the underlying OpenCL memory object. To create an actual copy use the buffer::clone() method.

# See Also:

context, command_queue

Creates a null buffer object.
cl_mem
bool
true

Creates a buffer object for `mem`. If `retain` is `true`, the reference count for `mem` will be incremented.

const `context` &
size_t
cl_mem_flags
read_write
void *
0

Create a new memory buffer in of `size` with `flags` in `context`.

See the documentation for

const `buffer` &
Creates a new buffer object as a copy of `other`.
`buffer` & `const `buffer` &` Copies the buffer object from `other` to `*this`.
buffer
&&
Move-constructs a new buffer object from `other`.
`buffer` & ``buffer` &&` Move-assigns the buffer from `other` to `*this`.
Destroys the buffer object.
size_t Returns the size of the buffer in bytes.
T `cl_mem_info`

Returns information about the buffer.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`buffer` ``command_queue` &`

Creates a new buffer with a copy of the data in `*this`. Uses `queue` to perform the copy.

`buffer` `cl_mem_flags` `size_t` `size_t`

Creates a new buffer out of this buffer. The new buffer is a sub region of this buffer. `flags` The mem_flags which should be used to create the new buffer `origin` The start index in this buffer `size` The size of the new sub buffer

See the documentation for

The return type for the function.

The name of the function.

A list of arguments for the function.

A list of variables to capture.

The OpenCL C source code for the function.

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()

A command queue.

Command queues provide the interface for interacting with compute devices. The command_queue class provides methods to copy data to and from a compute device as well as execute compute kernels.

Command queues are created for a compute device within a compute context.

For example, to create a context and command queue for the default device on the system (this is the normal set up code used by almost all OpenCL programs):

    #include <boost/compute/core.hpp>

    // get the default compute device
    boost::compute::device device = boost::compute::system::default_device();

    // set up a compute context and command queue
    boost::compute::context context(device);
    boost::compute::command_queue queue(context, device);

The default command queue for the system can be obtained with the system::default_queue() method.

# See Also:

buffer, context, kernel

CL_QUEUE_PROFILING_ENABLE
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
CL_MAP_READ
CL_MAP_WRITE
Creates a null command queue.
cl_command_queue
bool
true
const `context` &
const `device` &
cl_command_queue_properties
0

Creates a command queue in `context` for `device` with `properties`.

See the documentation for

const `command_queue` &
Creates a new command queue object as a copy of `other`.
`command_queue` & `const `command_queue` &` Copies the command queue object from `other` to `*this`.
command_queue
&&
Move-constructs a new command queue object from `other`.
`command_queue` & ``command_queue` &&` Move-assigns the command queue from `other` to `*this`.

Destroys the command queue.

See the documentation for

cl_command_queue & Returns the underlying OpenCL command queue.
`device` Returns the device that the command queue issues commands to.
`context` Returns the context for the command queue.
T `cl_command_queue_info`

Returns information about the command queue.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
cl_command_queue_properties Returns the properties for the command queue.
`command_queue`

Returns the current default device command queue for the underlying device.

This method is only available if the OpenCL version is 2.1 or later.

void

Replaces the default device command queue for the underlying device with this command queue. Command queue must have been created with CL_QUEUE_ON_DEVICE flag.

See the documentation for

`event` `const `buffer` &` `size_t` `size_t` `void *` `const `wait_list` &wait_list()`

Enqueues a command to read data from `buffer` to host memory.

See the documentation for

`event` `const `buffer` &` `size_t` `size_t` `void *` `const `wait_list` &wait_list()`

Enqueues a command to read data from `buffer` to host memory. The copy will be performed asynchronously.

See the documentation for

`event` `const `buffer` &` `const size_t` `const size_t` `const size_t` `size_t` `size_t` `size_t` `size_t` `void *` `const `wait_list` &wait_list()`

Enqueues a command to read a rectangular region from `buffer` to host memory.

See the documentation for

`event` `const `buffer` &` `const size_t` `const size_t` `const size_t` `size_t` `size_t` `size_t` `size_t` `void *` `const `wait_list` &wait_list()`

Enqueues a command to read a rectangular region from `buffer` to host memory. The copy will be performed asynchronously.

See the documentation for

`event` `const `buffer` &` `size_t` `size_t` `const void *` `const `wait_list` &wait_list()`

Enqueues a command to write data from host memory to `buffer`.

See the documentation for

`event` `const `buffer` &` `size_t` `size_t` `const void *` `const `wait_list` &wait_list()`

Enqueues a command to write data from host memory to `buffer`. The copy is performed asynchronously.

See the documentation for

`event` `const `buffer` &` `const size_t` `const size_t` `const size_t` `size_t` `size_t` `size_t` `size_t` `void *` `const `wait_list` &wait_list()`

Enqueues a command to write a rectangular region from host memory to `buffer`.

See the documentation for

`event` `const `buffer` &` `const size_t` `const size_t` `const size_t` `size_t` `size_t` `size_t` `size_t` `void *` `const `wait_list` &wait_list()`

Enqueues a command to write a rectangular region from host memory to `buffer`. The copy is performed asynchronously.

See the documentation for

`event` `const `buffer` &` `const `buffer` &` `size_t` `size_t` `size_t` `const `wait_list` &wait_list()`

Enqueues a command to copy data from `src_buffer` to `dst_buffer`.

See the documentation for

`event` `const `buffer` &` `const `buffer` &` `const size_t` `const size_t` `const size_t` `size_t` `size_t` `size_t` `size_t` `const `wait_list` &wait_list()`

Enqueues a command to copy a rectangular region from `src_buffer` to `dst_buffer`.

See the documentation for

`event` `const `buffer` &` `const void *` `size_t` `size_t` `size_t` `const `wait_list` &wait_list()`

Enqueues a command to fill `buffer` with `pattern`.

See the documentation for

void * `const `buffer` &` `cl_map_flags` `size_t` `size_t` ``event` &` `const `wait_list` &wait_list()`

Enqueues a command to map `buffer` into the host address space. Event associated with map operation is returned through `map_buffer_event` parameter.

See the documentation for

void * `const `buffer` &` `cl_map_flags` `size_t` `size_t` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void * `const `buffer` &` `cl_map_flags` `size_t` `size_t` ``event` &` `const `wait_list` &wait_list()`

Enqueues a command to map `buffer` into the host address space. Map operation is performed asynchronously. The pointer to the mapped region cannot be used until the map operation has completed.

Event associated with map operation is returned through `map_buffer_event` parameter.

See the documentation for

`event` `const `buffer` &` `void *` `const `wait_list` &wait_list()`

Enqueues a command to unmap `buffer` from the host memory space.

See the documentation for

`event` `cl_mem` `void *` `const `wait_list` &wait_list()`

Enqueues a command to unmap `mem` from the host memory space.

See the documentation for

`event` `const `image_object` &` `const size_t *` `const size_t *` `size_t` `size_t` `void *` `const `wait_list` &wait_list()`

Enqueues a command to read data from `image` to host memory.

See the documentation for

`event` size_t `const `image_object` &` `const `extents`< N >` `const `extents`< N >` `void *` `size_t0` `size_t0` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`event` ``image_object` &` `const size_t *` `const size_t *` `const void *` `size_t0` `size_t0` `const `wait_list` &wait_list()`

Enqueues a command to write data from host memory to `image`.

See the documentation for

`event` size_t ``image_object` &` `const `extents`< N >` `const `extents`< N >` `const void *` `const size_t0` `const size_t0` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void * `const `image_object` &` `cl_map_flags` `const size_t *` `const size_t *` `size_t &` `size_t &` ``event` &` `const `wait_list` &wait_list()`

Enqueues a command to map `image` into the host address space.

Event associated with map operation is returned through `map_image_event` parameter.

See the documentation for

void * `const `image_object` &` `cl_map_flags` `const size_t *` `const size_t *` `size_t &` `size_t &` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void * size_t ``image_object` &` `cl_map_flags` `const `extents`< N >` `const `extents`< N >` `size_t &` `size_t &` ``event` &` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void * size_t ``image_object` &` `cl_map_flags` `const `extents`< N >` `const `extents`< N >` `size_t &` `size_t &` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void * `const `image_object` &` `cl_map_flags` `const size_t *` `const size_t *` `size_t &` `size_t &` ``event` &` `const `wait_list` &wait_list()`

Enqueues a command to map `image` into the host address space. Map operation is performed asynchronously. The pointer to the mapped region cannot be used until the map operation has completed.

Event associated with map operation is returned through `map_image_event` parameter.

See the documentation for

void * size_t ``image_object` &` `cl_map_flags` `const `extents`< N >` `const `extents`< N >` `size_t &` `size_t &` ``event` &` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`event` `const `image_object` &` `void *` `const `wait_list` &wait_list()`

Enqueues a command to unmap `image` from the host memory space.

See the documentation for

`event` `const `image_object` &` ``image_object` &` `const size_t *` `const size_t *` `const size_t *` `const `wait_list` &wait_list()`

Enqueues a command to copy data from `src_image` to `dst_image`.

See the documentation for

`event` size_t `const `image_object` &` ``image_object` &` `const `extents`< N >` `const `extents`< N >` `const `extents`< N >` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`event` `const `image_object` &` ``memory_object` &` `const size_t *` `const size_t *` `size_t` `const `wait_list` &wait_list()`

Enqueues a command to copy data from `src_image` to `dst_buffer`.

See the documentation for

`event` `const `memory_object` &` ``image_object` &` `size_t` `const size_t *` `const size_t *` `const `wait_list` &wait_list()`

Enqueues a command to copy data from `src_buffer` to `dst_image`.

See the documentation for

`event` ``image_object` &` `const void *` `const size_t *` `const size_t *` `const `wait_list` &wait_list()`

Enqueues a command to fill `image` with `fill_color`.

See the documentation for

`event` size_t ``image_object` &` `const void *` `const `extents`< N >` `const `extents`< N >` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`event` `uint_` `const cl_mem *` `cl_mem_migration_flags` `const `wait_list` &wait_list()`

Enqueues a command to migrate `mem_objects`.

See the documentation for

`event` `const `kernel` &` `size_t` `const size_t *` `const size_t *` `const size_t *` `const `wait_list` &wait_list()`

Enqueues a kernel for execution.

See the documentation for

`event` size_t `const `kernel` &` `const `extents`< N > &` `const `extents`< N > &` `const `extents`< N > &` `const `wait_list` &wait_list()` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`event` `const `kernel` &` `size_t` `size_t` `size_t` `const `wait_list` &wait_list()`

Convenience method which calls enqueue_nd_range_kernel() with a one-dimensional range.

`event` `const `kernel` &` `const `wait_list` &wait_list()`

Enqueues a kernel to execute using a single work-item.

See the documentation for

`event` `void(BOOST_COMPUTE_CL_CALLBACK *user_func)(void *)` `void *` `size_t` `uint_` `const cl_mem *` `const void **` `const `wait_list` &wait_list()` Enqueues a function to execute on the host.
`event` `void(BOOST_COMPUTE_CL_CALLBACK *user_func)(void)` `const `wait_list` &wait_list()`

Convenience overload for enqueue_native_kernel() which enqueues a native kernel on the host with a nullary function.

void

Flushes the command queue.

See the documentation for

void

Blocks until all outstanding commands in the queue have finished.

See the documentation for

void Enqueues a barrier in the queue.
`event` `const `wait_list` &`

Enqueues a barrier in the queue after `events`.

This method is only available if the OpenCL version is 1.2 or later.

`event`

Enqueues a marker in the queue and returns an event that can be used to track its progress.

`event` `const `wait_list` &`

Enqueues a marker after `events` in the queue and returns an event that can be used to track its progress.

This method is only available if the OpenCL version is 1.2 or later.

`event` `void *` `const void *` `size_t` `const `wait_list` &wait_list()`

Enqueues a command to copy `size` bytes of data from `src_ptr` to `dst_ptr`.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
`event` `void *` `const void *` `size_t` `const `wait_list` &wait_list()`

Enqueues a command to copy `size` bytes of data from `src_ptr` to `dst_ptr`. The operation is performed asynchronously.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
`event` `void *` `const void *` `size_t` `size_t` `const `wait_list` &wait_list()`

Enqueues a command to fill `size` bytes of data at `svm_ptr` with `pattern`.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
`event` `void *` `const `wait_list` &wait_list()`

Enqueues a command to free `svm_ptr`.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
`event` `void *` `size_t` `cl_map_flags` `const `wait_list` &wait_list()`

Enqueues a command to map `svm_ptr` to the host memory space.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
`event` `void *` `const `wait_list` &wait_list()`

Enqueues a command to unmap `svm_ptr` from the host memory space.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
`event` `const std::vector< const void * > &` `const std::vector< size_t > &` `const cl_mem_migration_flags0` `const `wait_list` &wait_list()`

Enqueues a command to indicate which device a set of ranges of SVM allocations should be associated with. The pair `svm_ptrs`[i] and `sizes`[i] together define the starting address and number of bytes in a range to be migrated.

If `sizes` is empty, then that means every allocation containing any `svm_ptrs`[i] is to be migrated. Also, if `sizes`[i] is zero, then the entire allocation containing `svm_ptrs`[i] is migrated.

This method is only available if the OpenCL version is 2.1 or later.

See the documentation for
`event` `const void *` `const size_t0` `const cl_mem_migration_flags0` `const `wait_list` &wait_list()`

Enqueues a command to indicate which device a range of SVM allocation should be associated with. The pair `svm_ptr` and `size` together define the starting address and number of bytes in a range to be migrated.

If `size` is 0, then the entire allocation containing `svm_ptr` is migrated. The default value for `size` is 0.

This method is only available if the OpenCL version is 2.1 or later.

See the documentation for
bool `const `command_queue` &` Returns `true` if the command queue is the same at `other`.
bool `const `command_queue` &` Returns `true` if the command queue is different from `other`.

Meta-header to include all Boost.Compute container headers.

std::size_t
A fixed-size container.

The array container is very similar to the vector container except its size is fixed at compile-time rather than being dynamically resizable at run-time.

For example, to create a fixed-size array with eight values on the device:

    boost::compute::array<int, 8> values(context);

The Boost.Compute `array` class provides a STL-like API and is modeled after the `std::array` class from the C++ standard library.

# See Also:

vector<T>

N
T
std::size_t
ptrdiff_t
unspecified
unspecified
T *
const T *
`buffer_iterator`< T >
`buffer_iterator`< T >
std::reverse_iterator< `iterator` >
std::reverse_iterator< `const_iterator` >
const `context` &
system::default_context()
const `array`< T, N > &
const boost::array< T, N > &
const `context` &
system::default_context()
const `array`< T, N > &
const `command_queue` &
`array`< T, N > & `const `array`< T, N > &`
`array`< T, N > & `const boost::array< T, N > &`
`iterator`
`const_iterator`
`const_iterator`
`iterator`
`const_iterator`
`const_iterator`
reverse_iterator
const_reverse_iterator
const_reverse_iterator
reverse_iterator
const_reverse_iterator
const_reverse_iterator
size_type
bool
size_type
reference `size_type`
const_reference `size_type`
reference `size_type`
const_reference `size_type`
reference
const_reference
reference
const_reference
void `const value_type &` `const `command_queue` &`
void ``array`< T, N > &` `const `command_queue` &`
void `const value_type &`
void ``array`< T, N > &`
const `buffer` &
`command_queue`
std::char_traits<CharT>
A template for a dynamically-sized character sequence.

The `basic_string` class provides a generic template for a dynamically- sized character sequence. This is most commonly used through the `string` typedef (for `basic_string<char>`).

For example, to create a string on the device with its contents copied from a C-string on the host:

    boost::compute::string str("hello, world!");

# See Also:

vector<T>

Traits
Traits::char_type
size_t
`::boost::compute::vector`< CharT >::reference
`::boost::compute::vector`< CharT >::const_reference
`::boost::compute::vector`< CharT >::iterator
`::boost::compute::vector`< CharT >::const_iterator
`::boost::compute::vector`< CharT >::reverse_iterator
`::boost::compute::vector`< CharT >::const_reverse_iterator
const size_type
size_type
CharT
const `basic_string` &
size_type
size_type
npos
const char *
size_type
const char *
InputIterator
InputIterator
const `basic_string`< CharT, Traits > &
`basic_string`< CharT, Traits > & `const `basic_string`< CharT, Traits > &`
reference `size_type`
const_reference `size_type`
reference `size_type`
const_reference `size_type`
reference
const_reference
reference
const_reference
`iterator`
`const_iterator`
`const_iterator`
`iterator`
`const_iterator`
`const_iterator`
reverse_iterator
const_reverse_iterator
const_reverse_iterator
reverse_iterator
const_reverse_iterator
const_reverse_iterator
bool
size_type
size_type
size_type
void `size_type`
size_type
void
void
void ``basic_string`< CharT, Traits > &`
`basic_string`< CharT, Traits > `size_type0` `size_typenpos`
size_type `CharT` `size_type0` Finds the first character `ch`.
size_type ``basic_string` &` `size_type0` Finds the first substring equal to `str`.
size_type `const char *` `size_type0`

Finds the first substring equal to the character string pointed to by `s`. The length of the string is determined by the first null character.

For example, the following code

will return 5 as position.

std::ostream & `std::ostream &` ``boost::compute::basic_string`< CharT, Traits >const &`
ulong_
buffer_allocator<Block>
The dynamic_bitset class contains a resizable bit array.

For example, to create a dynamic-bitset with space for 1000 bits on the device:

    boost::compute::dynamic_bitset<> bits(1000, queue);

The Boost.Compute `dynamic_bitset` class provides a STL-like API and is modeled after the `boost::dynamic_bitset` class from Boost.

# See Also:

vector<T>

Block
Alloc
`vector`< Block, Alloc >
container_type::size_type
size_type
bits_per_block
sizeof(block_type) *CHAR_BIT
size_type
npos
static_cast< size_type >(-1)
size_type
command_queue
&

Creates a new dynamic bitset with storage for `size` bits. Initializes all bits to zero.

const `dynamic_bitset` &
Creates a new dynamic bitset as a copy of `other`.
`dynamic_bitset` & `const `dynamic_bitset` &` Copies the data from `other` to `*this`.
Destroys the dynamic bitset.
size_type Returns the size of the dynamic bitset.
size_type Returns the number of blocks to store the bits in the dynamic bitset.
size_type Returns the maximum possible size for the dynamic bitset.
bool Returns `true` if the dynamic bitset is empty (i.e. `size()` == `0`).
size_type ``command_queue` &` Returns the number of set bits (i.e. '1') in the bitset.
void `size_type` ``command_queue` &`

Resizes the bitset to contain `num_bits`. If the new size is greater than the current size the new bits are set to zero.

void `size_type` ``command_queue` &` Sets the bit at position `n` to `true`.
void `size_type` `bool` ``command_queue` &` Sets the bit at position `n` to `value`.
bool `size_type` ``command_queue` &` Returns `true` if the bit at position `n` is set (i.e. '1').
void `size_type` ``command_queue` &` Flips the value of the bit at position `n`.
bool ``command_queue` &` Returns `true` if any bit in the bitset is set (i.e. '1').
bool ``command_queue` &` Returns `true` if all of the bits in the bitset are set to zero.
void ``command_queue` &` Sets all of the bits in the bitset to zero.
void `size_type` ``command_queue` &` Sets the bit at position `n` to zero.
void Empties the bitset (e.g. `resize(0)`).
allocator_type Returns the allocator used to allocate storage for the bitset.
Key
T
`::boost::compute::vector`< std::pair< Key, T > >
vector_type::value_type
vector_type::size_type
vector_type::difference_type
vector_type::reference
vector_type::const_reference
vector_type::pointer
vector_type::const_pointer
`vector_type::iterator`
`vector_type::const_iterator`
vector_type::reverse_iterator
vector_type::const_reverse_iterator
const `context` &
system::default_context()
const flat_map< Key, T > &
flat_map< Key, T > & `const flat_map< Key, T > &`
`iterator`
`const_iterator`
`const_iterator`
`iterator`
`const_iterator`
`const_iterator`
reverse_iterator
const_reverse_iterator
const_reverse_iterator
reverse_iterator
const_reverse_iterator
const_reverse_iterator
size_type
size_type
bool
size_type
void `size_type` ``command_queue` &`
void `size_type`
void
void
std::pair< `iterator`, bool > `const value_type &` ``command_queue` &`
std::pair< `iterator`, bool > `const value_type &`
`iterator` `const `const_iterator` &` ``command_queue` &`
`iterator` `const `const_iterator` &`
`iterator` `const `const_iterator` &` `const `const_iterator` &` ``command_queue` &`
`iterator` `const `const_iterator` &` `const `const_iterator` &`
size_type `const key_type &` ``command_queue` &`
`iterator` `const key_type &` ``command_queue` &`
`iterator` `const key_type &`
`const_iterator` `const key_type &` ``command_queue` &`
`const_iterator` `const key_type &`
size_type `const key_type &` ``command_queue` &`
size_type `const key_type &`
`iterator` `const key_type &` ``command_queue` &`
`iterator` `const key_type &`
`const_iterator` `const key_type &` ``command_queue` &`
`const_iterator` `const key_type &`
`iterator` `const key_type &` ``command_queue` &`
`iterator` `const key_type &`
`const_iterator` `const key_type &` ``command_queue` &`
`const_iterator` `const key_type &`
const mapped_type `const key_type &`
unspecified `const key_type &`
T
`vector`< T >::value_type
`vector`< T >::size_type
`vector`< T >::difference_type
`vector`< T >::reference
`vector`< T >::const_reference
`vector`< T >::pointer
`vector`< T >::const_pointer
`vector`< T >::iterator
`vector`< T >::const_iterator
`vector`< T >::reverse_iterator
`vector`< T >::const_reverse_iterator
const `context` &
system::default_context()
const flat_set< T > &
flat_set< T > & `const flat_set< T > &`
`iterator`
`const_iterator`
`const_iterator`
`iterator`
`const_iterator`
`const_iterator`
reverse_iterator
const_reverse_iterator
const_reverse_iterator
reverse_iterator
const_reverse_iterator
const_reverse_iterator
size_type
size_type
bool
size_type
void `size_type` ``command_queue` &`
void `size_type`
void
void
std::pair< `iterator`, bool > `const value_type &` ``command_queue` &`
std::pair< `iterator`, bool > `const value_type &`
`iterator` `const `const_iterator` &` ``command_queue` &`
`iterator` `const `const_iterator` &`
`iterator` `const `const_iterator` &` `const `const_iterator` &` ``command_queue` &`
`iterator` `const `const_iterator` &` `const `const_iterator` &`
size_type `const key_type &` ``command_queue` &`
size_type `const key_type &`
`iterator` `const key_type &` ``command_queue` &`
`iterator` `const key_type &`
`const_iterator` `const key_type &` ``command_queue` &`
`const_iterator` `const key_type &`
size_type `const key_type &` ``command_queue` &`
size_type `const key_type &`
`iterator` `const key_type &` ``command_queue` &`
`iterator` `const key_type &`
`const_iterator` `const key_type &` ``command_queue` &`
`const_iterator` `const key_type &`
`iterator` `const key_type &` ``command_queue` &`
`iterator` `const key_type &`
`const_iterator` `const key_type &` ``command_queue` &`
`const_iterator` `const key_type &`
A mapped view of host memory.

The mapped_view class simplifies mapping host-memory to a compute device. This allows for host-allocated memory to be used with the Boost.Compute algorithms.

The following example shows how to map a simple C-array containing data on the host to the device and run the reduce() algorithm to calculate the sum:

# See Also:

buffer

T
size_t
ptrdiff_t
`buffer_iterator`< T >
`buffer_iterator`< T >
Creates a null mapped_view object.
T *
size_type
const `context` &
system::default_context()

Creates a mapped_view for `host_ptr` with `n` elements. After constructing a mapped_view the data is available for use by a compute device. Use the `unmap()` method to make the updated data available to the host.

const T *
size_type
const `context` &
system::default_context()

Creates a read-only mapped_view for `host_ptr` with `n` elements. After constructing a mapped_view the data is available for use by a compute device. Use the `unmap()` method to make the updated data available to the host.

const `mapped_view`< T > &
Creates a copy of `other`.
`mapped_view`< T > & `const `mapped_view`< T > &` Copies the mapped buffer from `other`.
Destroys the mapped_view object.
`iterator` Returns an iterator to the first element in the mapped_view.
`const_iterator` Returns a const_iterator to the first element in the mapped_view.
`const_iterator` Returns a const_iterator to the first element in the mapped_view.
`iterator` Returns an iterator to one past the last element in the mapped_view.
`const_iterator` Returns a const_iterator to one past the last element in the mapped_view.
`const_iterator` Returns a const_iterator to one past the last element in the mapped_view.
size_type Returns the number of elements in the mapped_view.
T * Returns the host data pointer.
const T * Returns the host data pointer.
void `size_type` Resizes the mapped_view to `size` elements.
bool Returns `true` if the mapped_view is empty.
const `buffer` & Returns the mapped buffer.
void `cl_map_flags` ``command_queue` &`

Maps the buffer into the host address space.

See the documentation for

void ``command_queue` &`

Maps the buffer into the host address space for reading and writing.

Equivalent to:

    map(CL_MAP_READ | CL_MAP_WRITE, queue);

void ``command_queue` &`

Unmaps the buffer from the host address space.

See the documentation for

`vector`< T >
container_type::size_type
container_type::value_type
const stack< T > &
stack< T > & `const stack< T > &`
bool
size_type
value_type
void `const T &`
void
`basic_string`< char_ >
const `context` &
system::default_context()
size_t
const `context` &
system::default_context()
const T &
size_t
const `context` &
system::default_context()
const T *
size_t
const `context` &
system::default_context()
const valarray< T > &
const std::valarray< T > &
const `context` &
system::default_context()
valarray< T > & `const valarray< T > &`
valarray< T > & `const std::valarray< T > &`
valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T >
valarray< T >
valarray< T >
valarray< char >

In OpenCL there cannot be memory buffer with bool type, for this reason return type is valarray<char> instead of valarray<bool>. 1 means true, 0 means false.

valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T > & `const T &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
valarray< T > & `const valarray< T > &`
size_t
void `size_t` `TT()`
unspecified `size_t`
unspecified `size_t`
T
T
T
valarray< T > `UnaryFunction`
const `buffer` &
`buffer_iterator`< T >
`buffer_iterator`< T >
buffer_allocator<T>
A resizable array of values.

The vector<T> class stores a dynamic array of values. Internally, the data is stored in an OpenCL buffer object.

The vector class is the prefered container for storing and accessing data on a compute device. In most cases it should be used instead of directly dealing with buffer objects. If the undelying buffer is needed, it can be accessed with the get_buffer() method.

The internal storage is allocated in a specific OpenCL context which is passed as an argument to the constructor when the vector is created.

For example, to create a vector on the device containing space for ten `int` values:

    boost::compute::vector<int> vec(10, context);

Allocation and data transfer can also be performed in a single step:

    // values on the host
    int data[] = { 1, 2, 3, 4 };

    // create a vector of size four and copy the values from data
    boost::compute::vector<int> vec(data, data + 4, queue);

The Boost.Compute `vector` class provides a STL-like API and is modeled after the `std::vector` class from the C++ standard library. It can be used with any of the STL-like algorithms provided by Boost.Compute including `copy()`, `transform()`, and `sort()` (among many others).

For example:

    // a vector on a compute device
    boost::compute::vector<float> vec = ...

    // copy data to the vector from a host std:vector
    boost::compute::copy(host_vec.begin(), host_vec.end(), vec.begin(), queue);

    // copy data from the vector to a host std::vector
    boost::compute::copy(vec.begin(), vec.end(), host_vec.begin(), queue);

    // sort the values in the vector
    boost::compute::sort(vec.begin(), vec.end(), queue);

    // calculate the sum of the values in the vector (also see reduce())
    float sum = boost::compute::accumulate(vec.begin(), vec.end(), 0, queue);

    // reverse the values in the vector
    boost::compute::reverse(vec.begin(), vec.end(), queue);

    // fill the vector with ones
    boost::compute::fill(vec.begin(), vec.end(), 1, queue);

# See Also:

array<T, N>, buffer

T
Alloc
allocator_type::size_type
allocator_type::difference_type
unspecified
unspecified
allocator_type::pointer
allocator_type::const_pointer
`buffer_iterator`< T >
`buffer_iterator`< T >
std::reverse_iterator< `iterator` >
std::reverse_iterator< `const_iterator` >
const `context` &
system::default_context()
Creates an empty vector in `context`.
size_type
const `context` &
system::default_context()

Creates a vector with space for `count` elements in `context`.

Note that unlike `std::vector's` constructor, this will not initialize the values in the container. Either call the vector constructor which takes a value to initialize with or use the fill() algorithm to set the initial values.

For example:

    // create a vector on the device with space for ten ints
    boost::compute::vector<int> vec(10, context);

size_type
const T &
command_queue
&
system::default_queue()

Creates a vector with space for `count` elements and sets each equal to `value`.

For example:

    // creates a vector with four values set to nine (e.g. [9, 9, 9, 9]).
    boost::compute::vector<int> vec(4, 9, queue);

InputIterator
InputIterator
command_queue
&
system::default_queue()

Creates a vector with space for the values in the range [`first`, `last`) and copies them into the vector with `queue`.

For example:

    // values on the host
    int data[] = { 1, 2, 3, 4 };

    // create a vector of size four and copy the values from data
    boost::compute::vector<int> vec(data, data + 4, queue);

const `vector` &
command_queue
&
system::default_queue()
Creates a new vector and copies the values from `other`.
const `vector`< T, OtherAlloc > &
command_queue
&
system::default_queue()
Creates a new vector and copies the values from `other`.
const std::vector< T, OtherAlloc > &
command_queue
&
system::default_queue()
Creates a new vector and copies the values from `vector`.
std::initializer_list< T >
command_queue
&
system::default_queue()
`vector` & `const `vector` &`
`vector` & `const `vector`< T, OtherAlloc > &`
`vector` & `const std::vector< T, OtherAlloc > &`
vector
&&
Move-constructs a new vector from `other`.
`vector` & ``vector` &&` Move-assigns the data from `other` to `*this`.
Destroys the vector object.
`iterator`
`const_iterator`
`const_iterator`
`iterator`
`const_iterator`
`const_iterator`
reverse_iterator
const_reverse_iterator
const_reverse_iterator
reverse_iterator
const_reverse_iterator
const_reverse_iterator
size_type Returns the number of elements in the vector.
size_type
void `size_type` ``command_queue` &` Resizes the vector to `size`.
void `size_type` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Returns `true` if the vector is empty.
size_type Returns the capacity of the vector.
void `size_type` ``command_queue` &`
void `size_type`
void ``command_queue` &`
void
reference `size_type`
const_reference `size_type`
reference `size_type`
const_reference `size_type`
reference
const_reference
reference
const_reference
void `InputIterator` `InputIterator` ``command_queue` &`
void `InputIterator` `InputIterator`
void `size_type` `const T &` ``command_queue` &`
void `size_type` `const T &`
void `const T &` ``command_queue` &`

Inserts `value` at the end of the vector (resizing if neccessary).

Note that calling `push_back()` to insert data values one at a time is inefficient as there is a non-trivial overhead in performing a data transfer to the device. It is usually better to store a set of values on the host (for example, in a `std::vector`) and then transfer them in bulk using the `insert()` method or the copy() algorithm.

void `const T &` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void ``command_queue` &`
void
`iterator` ``iterator`` `const T &` ``command_queue` &`
`iterator` ``iterator`` `const T &`
void ``iterator`` `size_type` `const T &` ``command_queue` &`
void ``iterator`` `size_type` `const T &`
void ``iterator`` `InputIterator` `InputIterator` ``command_queue` &`

Inserts the values in the range [`first`, `last`) into the vector at `position` using `queue`.

void ``iterator`` `InputIterator` `InputIterator` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`iterator` ``iterator`` ``command_queue` &`
`iterator` ``iterator``
`iterator` ``iterator`` ``iterator`` ``command_queue` &`
`iterator` ``iterator`` ``iterator``
void ``vector` &` Swaps the contents of `*this` with `other`.
void Removes all elements from the vector.
allocator_type
const `buffer` & Returns the underlying buffer.
A compute context.

The context class represents a compute context.

A context object manages a set of OpenCL resources including memory buffers and program objects. Before allocating memory on the device or executing kernels you must set up a context object.

To create a context for the default device on the system:

    // get the default compute device
    boost::compute::device gpu = boost::compute::system::default_device();

    // create a context for the device
    boost::compute::context context(gpu);

Once a context is created, memory can be allocated using the buffer class and kernels can be executed using the command_queue class.

# See Also:

device, command_queue

Create a null context object.
const `device` &
const cl_context_properties *
0

Creates a new context for `device` with `properties`.

See the documentation for

const std::vector< `device` > &
const cl_context_properties *
0

Creates a new context for `devices` with `properties`.

See the documentation for

cl_context
bool
true

Creates a new context object for `context`. If `retain` is `true`, the reference count for `context` will be incremented.

const `context` &
Creates a new context object as a copy of `other`.
`context` & `const `context` &` Copies the context object from `other` to `*this`.
context
&&
Move-constructs a new context object from `other`.
`context` & ``context` &&` Move-assigns the context from `other` to `*this`.
Destroys the context object.
cl_context & Returns the underlying OpenCL context.
`device`

Returns the device for the context. If the context contains multiple devices, the first is returned.

std::vector< `device` > Returns a vector of devices for the context.
T `cl_context_info`

Returns information about the context.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool `const `context` &` Returns `true` if the context is the same as `other`.
bool `const `context` &` Returns `true` if the context is different from `other`.
`context`

Creates a shared OpenCL/OpenGL context for the currently active OpenGL context.

Once created, the shared context can be used to create OpenCL memory objects which can interact with OpenGL memory objects (e.g. VBOs).

`unsupported_extension_error` if no CL-GL sharing capable devices are found.

Meta-header to include all Boost.Compute core headers.

A compute device.

Typical compute devices include GPUs and multi-core CPUs. A list of all compute devices available on a platform can be obtained via the platform::devices() method.

The default compute device for the system can be obtained with the system::default_device() method. For example:

# See Also:

platform, context, command_queue

CL_DEVICE_TYPE_CPU
CL_DEVICE_TYPE_GPU
CL_DEVICE_TYPE_ACCELERATOR
Creates a null device object.
cl_device_id
bool
true

Creates a new device object for `id`. If `retain` is `true`, the reference count for the device will be incremented.

const `device` &
Creates a new device object as a copy of `other`.
`device` & `const `device` &` Copies the device from `other` to `*this`.
device
&&
Move-constructs a new device object from `other`.
`device` & ``device` &&` Move-assigns the device from `other` to `*this`.
Destroys the device object.
cl_device_id Returns the ID of the device.
cl_device_id & Returns a reference to the underlying OpenCL device id.
cl_device_type Returns the type of the device.
`platform` Returns the platform for the device.
std::string Returns the name of the device.
std::string Returns the name of the vendor for the device.
std::string Returns the device profile string.
std::string Returns the device version string.
std::string Returns the driver version string.
std::vector< std::string > Returns a list of extensions supported by the device.
bool `const std::string &`

Returns `true` if the device supports the extension with `name`.

uint_ Returns the number of address bits.
ulong_ Returns the global memory size in bytes.
ulong_ Returns the local memory size in bytes.
uint_ Returns the clock frequency for the device's compute units.
uint_ Returns the number of compute units in the device.
uint_ Returns the preferred vector width for type `T`.
size_t Returns the profiling timer resolution in nanoseconds.
bool Returns `true` if the device is a sub-device.
T `cl_device_info`

Returns information about the device.

For example, to get the number of compute units:

    device.get_info<cl_uint>(CL_DEVICE_MAX_COMPUTE_UNITS);

Alternatively, the template-specialized version can be used which automatically determines the result type:

    device.get_info<CL_DEVICE_MAX_COMPUTE_UNITS>();

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< `device` > `const cl_device_partition_property *`

Partitions the device into multiple sub-devices according to `properties`.

This method is only available if the OpenCL version is 1.2 or later.

std::vector< `device` > `size_t`

This method is only available if the OpenCL version is 1.2 or later.

std::vector< `device` > `const std::vector< size_t > &`

This method is only available if the OpenCL version is 1.2 or later.

std::vector< `device` > `cl_device_affinity_domain`

This method is only available if the OpenCL version is 1.2 or later.

ulong_

Returns the current value of the host clock as seen by device in nanoseconds.

See the documentation for

std::pair< ulong_, ulong_ >

Returns a reasonably synchronized pair of timestamps from the device timer and the host timer as seen by device in nanoseconds. The first of returned std::pair is a device timer timestamp, the second is a host timer timestamp.

See the documentation for

Duration

Returns the current value of the host clock as seen by device as duration.

For example, to print the current value of the host clock as seen by device in milliseconds:

    std::cout << device.get_host_timer<std::chrono::milliseconds>().count() << " ms";

See the documentation for

std::pair< Duration, Duration >

Returns a reasonably synchronized pair of timestamps from the device timer and the host timer as seen by device as a std::pair<Duration, Duration> value. The first of returned std::pair is a device timer timestamp, the second is a host timer timestamp.

See the documentation for

bool `const `device` &` Returns `true` if the device is the same at `other`.
bool `const `device` &` Returns `true` if the device is different from `other`.
bool `int` `int`

Returns `true` if the device OpenCL version is major.minor or newer; otherwise returns `false`.

An event corresponding to an operation on a compute device.

Event objects are used to track operations running on the device (such as kernel executions and memory transfers). Event objects are returned by the various `enqueue_*` methods of the command_queue class.

Events can be used to synchronize operations between the host and the device. The `wait()` method will block execution on the host until the operation corresponding to the event on the device has completed. The status of the operation can also be polled with the `status()` method.

Event objects can also be used for performance profiling. In order to use events for profiling, the command queue must be constructed with the `CL_QUEUE_PROFILING_ENABLE` flag. Then the `duration()` method can be used to retrieve the total duration of the operation on the device:

    std::cout << "time = " << e.duration<std::chrono::milliseconds>().count() << "ms\n";

# See Also:

future<T>, wait_list

Creates a null event object.
cl_event
bool
true
const `event` &
Makes a new event as a copy of `other`.
`event` & `const `event` &` Copies the event object from `other` to `*this`.
event
&&
Move-constructs a new event object from `other`.
`event` & ``event` &&` Move-assigns the event from `other` to `*this`.
Destroys the event object.
cl_event & Returns a reference to the underlying OpenCL event object.
cl_int Returns the status of the event.
cl_command_type Returns the command type for the event.
T `cl_event_info`

Returns information about the event.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
T `cl_profiling_info`

Returns profiling information for the event.

# See Also:

event::duration()

See the documentation for
void

Blocks until the actions corresponding to the event have completed.

void `void(BOOST_COMPUTE_CL_CALLBACK *callback)(cl_event `event`, cl_int status, void *user_data)` `cl_intCL_COMPLETE` `void *0`

Registers a function to be called when the event status changes to `status` (by default CL_COMPLETE). The callback is passed the OpenCL event object, the event status, and a pointer to arbitrary user data.

See the documentation for

void `Function` `cl_intCL_COMPLETE`

Registers a generic function to be called when the event status changes to `status` (by default `CL_COMPLETE`).

The function specified by `callback` must be invokable with zero arguments (e.g. `callback()`).

This method is only available if the OpenCL version is 1.1 or later.

Duration `cl_profiling_infoCL_PROFILING_COMMAND_START` `cl_profiling_infoCL_PROFILING_COMMAND_END`

Returns the total duration of the event from `start` to `end`.

For example, to print the number of milliseconds the event took to execute:

    std::cout << event.duration<std::chrono::milliseconds>().count() << " ms" << std::endl;

# See Also:

event::get_profiling_info()

bool `const `event` &` Returns `true` if the event is the same as `other`.
bool `const `event` &` Returns `true` if the event is different from `other`.

Meta-header to include all Boost.Compute exception headers.

std::exception
A run-time OpenCL context error.

The context_error exception is thrown when the OpenCL context encounters an error condition. Boost.Compute is notified of these error conditions by registering an error handler when creating context objects (via the `pfn_notify` argument to the `clCreateContext()` function).

This exception is different than the opencl_error exception which is thrown as a result of error caused when calling a single OpenCL API function.

# See Also:

opencl_error

const `context` *
const char *
const void *
size_t
Creates a new context error exception object.
Destroys the context error object.
const char * Returns a string with a description of the error.
const `context` *

Returns a pointer to the context object which generated the error notification.

const void * Returns a pointer to the private info memory block.
size_t Returns the size of the private info memory block.
std::exception
Exception thrown when no OpenCL device is found.

This exception is thrown when no valid OpenCL device can be found.

# See Also:

opencl_error

Creates a new no_device_found exception object.
Destroys the no_device_found exception object.
const char * Returns a string containing a human-readable error message.
std::exception
A run-time OpenCL error.

The opencl_error class represents an error returned from an OpenCL function.

# See Also:

context_error

cl_int
Creates a new opencl_error exception object for `error`.
Destroys the opencl_error object.
cl_int Returns the numeric error code.
std::string Returns a string description of the error.
const char * Returns a C-string description of the error.
std::string `cl_int`

Static function which converts the numeric OpenCL error code `error` to a human-readable string.

For example:

    std::cout << opencl_error::to_string(CL_INVALID_KERNEL_ARGS) << std::endl;

Will print "Invalid Kernel Arguments".

If the error code is unknown (e.g. not a valid OpenCL error), a string containing "Unknown OpenCL Error" along with the error number will be returned.

boost::compute::opencl_error
A failure when building OpenCL program.

Instances of this class are thrown when OpenCL program build fails. Extends opencl_error by saving a program build log so it can be used for testing, debugging, or logging purposes.

# See Also:

opencl_error

cl_int
const std::string &

Creates a new program_build_failure exception object for `error` and `build_log`.

Destroys the program_build_failure object.
std::string Retrieve the log of a failed program build.
std::exception
Exception thrown when failure to set default command queue.

This exception is thrown when Boost.Compute fails to set up user-provided default command queue for the system.

Creates a new set_default_queue_error exception object.
Destroys the set_default_queue_error object.
const char * Returns a string with a description of the error.
std::exception
Exception thrown when attempting to use an unsupported OpenCL extension.

This exception is thrown when the user attempts to use an OpenCL extension which is not supported on the platform and/or device.

An example of this is attempting to use CL-GL sharing on a non-GPU device.

# See Also:

opencl_error

const char *

Creates a new unsupported extension error exception object indicating that `extension` is not supported by the OpenCL platform or device.

Destroys the unsupported extension error object.
std::string Returns the name of the unsupported extension.
const char *

Returns a string containing a human-readable error message containing the name of the unsupported exception.

A function object.
const std::string &
Creates a new function object with `name`.
Destroys the function object.
bool `const `function`< Signature > &`
bool `const `function`< Signature > &`
`function`< Signature > `const std::string &

The function name.

` `const std::string &

The function source code.

`

Creates a function object given its `name` and `source`.

# See Also:

BOOST_COMPUTE_FUNCTION()

The return type for the function.

The name of the function.

A list of arguments for the function.

The OpenCL C source code for the function.

Creates a function object with `name` and `source`.

The function declaration and signature are automatically created using the `return_type`, `name`, and `arguments` macro parameters.

The source code for the function is interpreted as OpenCL C99 source code which is stringified and passed to the OpenCL compiler when the function is invoked.

For example, to create a function which squares a number:

    BOOST_COMPUTE_FUNCTION(float, square, (float x),
    {
        return x * x;
    });

And to create a function which sums two numbers:

    BOOST_COMPUTE_FUNCTION(int, sum_two, (int x, int y),
    {
        return x + y;
    });

# See Also:

BOOST_COMPUTE_CLOSURE()

Meta-header to include all Boost.Compute functional headers.

The as function converts its argument to type `T` (similar to reinterpret_cast<T>).

# See Also:

convert<T>

T
boost::compute::function< T(T *, T)>
boost::compute::function< T(T *, T)>
boost::compute::function< T(T *, T, T)>
boost::compute::function< T(T *)>
boost::compute::function< T(T *)>
boost::compute::function< T(T *, T)>
boost::compute::function< T(T *, T)>
boost::compute::function< T(T *, T)>
boost::compute::function< T(T *, T)>
boost::compute::function< T(T *, T)>
boost::compute::function< T(T *, T)>
boost::false_type
Meta-function returning `true` if `T` is a placeholder type.
`placeholder`< 0 > const
`placeholder`< 1 > const
unspecified class... `F` `Args...`

Returns a function wrapper which invokes `f` with `args` when called.

For example, to generate a unary function object which returns `true` when its argument is less than `7`:

    using boost::compute::less;
    using boost::compute::placeholders::_1;

    auto less_than_seven = boost::compute::bind(less<int>(), _1, 7);

The convert function converts its argument to type `T` (similar to static_cast<T>).

# See Also:

as<T>

T

Returns the named field from a value.

The template-type `T` specifies the field's value type. Note that the value type must match the actual type of the field otherwise runtime compilation or logic errors may occur.

For example, to access the `second` field in a `std::pair<int, float>` object:

    field<float>("second");

This can also be used with vector types to access individual components as well as perform swizzle operations.

For example, to access the first and third components of an `int` vector type (e.g. `int4`):

    field<int2_>("xz");

# See Also:

get<N>

Result type.
T
const std::string &
Creates a new field functor with `field`.
size_t

Returns the `N'th` element of an aggregate type (e.g. scalarN, pair, tuple, etc.).

# See Also:

field<T>

unspecified `const Arg &`

The hash function returns a hash value for the input value.

The return type is `ulong_` (the OpenCL unsigned long type).

Identity function which simply returns its input.

For example, to directly copy values using the transform() algorithm:

    transform(input.begin(), input.end(), output.begin(), identity<int>(), queue);

# See Also:

as<T>, convert<T>

Identity function result type.
T
Creates a new identity function.
boost::compute::binary_function< void, void, int >

The binnary_negate function adaptor negates a binary function.

# See Also:

not2()

Predicate
boost::compute::unary_function< T, int >

The logical_not function negates its argument and returns it.

# See Also:

not1(), not2()

boost::compute::unary_function< void, int >

The unary_negate function adaptor negates a unary function.

# See Also:

not1()

Predicate
`unary_negate`< Predicate > `const Predicate &

the unary function to wrap

`

Returns a unary_negate adaptor around `predicate`.

a unary_negate wrapper around `predicate`

`binary_negate`< Predicate > `const Predicate &

the binary function to wrap

`

Returns a binary_negate adaptor around `predicate`.

a binary_negate wrapper around `predicate`

boost::compute::function< T(T)>

Returns the number of non-zero bits in `x`.

See the documentation for

Meta-header to include all Boost.Compute image headers.

boost::compute::image_object
An OpenCL 1D image object.

This method is only available if the OpenCL version is 1.2 or later.

# See Also:

image_format, image2d

Creates a null image1d object.
const `context` &
size_t
const `image_format` &
cl_mem_flags
read_write
void *
0

Creates a new image1d object.

See the documentation for

const `image1d` &
Creates a new image1d as a copy of `other`.
`image1d` & `const `image1d` &` Copies the image1d from `other`.
image1d
&&
Move-constructs a new image object from `other`.
`image1d` & ``image1d` &&` Move-assigns the image from `other` to `*this`.
Destroys the image1d object.
`extents`< 1 > Returns the size (width) of the image.
`extents`< 1 > Returns the origin of the image (`0`).
T `cl_image_info`

Returns information about the image.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`image1d` ``command_queue` &`

Creates a new image with a copy of the data in `*this`. Uses `queue` to perform the copy operation.

std::vector< `image_format` > `const `context` &` `cl_mem_flagsread_write`

Returns the supported image formats for the context.

See the documentation for

bool `const `image_format` &` `const `context` &` `cl_mem_flagsread_write`

Returns `true` if `format` is a supported 1D image format for `context`.

boost::compute::image_object
An OpenCL 2D image object.

For example, to create a 640x480 8-bit RGBA image:

# See Also:

image_format, image3d

Creates a null image2d object.
const `context` &
size_t
size_t
const `image_format` &
cl_mem_flags
read_write
void *
0
size_t
0

Creates a new image2d object.

See the documentation for

const `image2d` &
Creates a new image2d as a copy of `other`.
`image2d` & `const `image2d` &` Copies the image2d from `other`.
image2d
&&
Move-constructs a new image object from `other`.
`image2d` & ``image2d` &&` Move-assigns the image from `other` to `*this`.
Destroys the image2d object.
`extents`< 2 > Returns the size (width, height) of the image.
`extents`< 2 > Returns the origin of the image (`0`, `0`).
T `cl_image_info`

Returns information about the image.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`image2d` ``command_queue` &`

Creates a new image with a copy of the data in `*this`. Uses `queue` to perform the copy operation.

std::vector< `image_format` > `const `context` &` `cl_mem_flagsread_write`

Returns the supported image formats for the context.

See the documentation for

bool `const `image_format` &` `const `context` &` `cl_mem_flagsread_write`

Returns `true` if `format` is a supported 2D image format for `context`.

boost::compute::image_object
An OpenCL 3D image object.

# See Also:

image_format, image2d

Creates a null image3d object.
const `context` &
size_t
size_t
size_t
const `image_format` &
cl_mem_flags
read_write
void *
0
size_t
0
size_t
0

Creates a new image3d object.

See the documentation for

const `image3d` &
Creates a new image3d as a copy of `other`.
`image3d` & `const `image3d` &` Copies the image3d from `other`.
image3d
&&
Move-constructs a new image object from `other`.
`image3d` & ``image3d` &&` Move-assigns the image from `other` to `*this`.
Destroys the image3d object.
`extents`< 3 > Returns the size (width, height, depth) of the image.
`extents`< 3 > Returns the origin of the image (`0`, `0`, `0`).
T `cl_image_info`

Returns information about the image.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
`image3d` ``command_queue` &`

Creates a new image with a copy of the data in `*this`. Uses `queue` to perform the copy operation.

std::vector< `image_format` > `const `context` &` `cl_mem_flagsread_write`

Returns the supported 3D image formats for the context.

See the documentation for

bool `const `image_format` &` `const `context` &` `cl_mem_flagsread_write`

Returns `true` if `format` is a supported 3D image format for `context`.

A OpenCL image format.

For example, to create a format for a 8-bit RGBA image:

    boost::compute::image_format rgba8(CL_RGBA, CL_UNSIGNED_INT8);

After being constructed, image_format objects are usually passed to the constructor of the various image classes (e.g. image2d, image3d) to create an image object on a compute device.

Image formats supported by a context can be queried with the static get_supported_formats() in each image class. For example:

    std::vector<image_format> formats = image2d::get_supported_formats(ctx);

# See Also:

image2d

CL_R
CL_A
CL_INTENSITY
CL_LUMINANCE
CL_RG
CL_RA
CL_RGB
CL_RGBA
CL_ARGB
CL_BGRA
CL_SNORM_INT8
CL_SNORM_INT16
CL_UNORM_INT8
CL_UNORM_INT16
CL_UNORM_SHORT_565
CL_UNORM_SHORT_555
CL_UNORM_INT_101010
CL_SIGNED_INT8
CL_SIGNED_INT16
CL_SIGNED_INT32
CL_UNSIGNED_INT8
CL_UNSIGNED_INT16
CL_UNSIGNED_INT32
CL_HALF_FLOAT
CL_FLOAT
cl_channel_order
cl_channel_type
Creates a new image format object with `order` and `type`.
const cl_image_format &
Creates a new image format object from `format`.
const `image_format` &
Creates a new image format object as a copy of `other`.
`image_format` & `const `image_format` &` Copies the format from `other` to `*this`.
Destroys the image format object.
const cl_image_format * Returns a pointer to the `cl_image_format` object.
bool `const `image_format` &` Returns `true` if `*this` is the same as `other`.
bool `const `image_format` &` Returns `true` if `*this` is not the same as `other`.
boost::compute::memory_object
Base-class for image objects.

The image_object class is the base-class for image objects on compute devices.

# See Also:

image1d, image2d, image3d

cl_mem
bool
true
const `image_object` &
`image_object` & `const `image_object` &`
image_object
&&
Destroys the image object.
T `cl_mem_info`

Returns information about the image object.

See the documentation for

`image_format` Returns the format for the image.
size_t Returns the width of the image.
size_t

Returns the height of the image.

For 1D images, this function will return `1`.

size_t

Returns the depth of the image.

For 1D and 2D images, this function will return `1`.

std::vector< `image_format` > `const `context` &` `cl_mem_object_type` `cl_mem_flagsread_write`

Returns the supported image formats for the `type` in `context`.

See the documentation for

bool `const `image_format` &` `const `context` &` `cl_mem_object_type` `cl_mem_flagsread_write`

Returns `true` if `format` is a supported image format for `type` in `context` with `flags`.

An OpenCL image sampler object.

# See Also:

image2d, image_format

CL_ADDRESS_NONE
CL_ADDRESS_CLAMP_TO_EDGE
CL_ADDRESS_CLAMP
CL_ADDRESS_REPEAT
CL_FILTER_NEAREST
CL_FILTER_LINEAR
const `context` &
bool
cl_addressing_mode
cl_filter_mode
cl_sampler
bool
true
const `image_sampler` &
Creates a new image sampler object as a copy of `other`.
`image_sampler` & `const `image_sampler` &` Copies the image sampler object from `other` to `*this`.
image_sampler
&&
`image_sampler` & ``image_sampler` &&`
Destroys the image sampler object.
cl_sampler & Returns the underlying `cl_sampler` object.
`context` Returns the context for the image sampler object.
T `cl_sampler_info`

Returns information about the sampler.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool `const `image_sampler` &` Returns `true` if the sampler is the same at `other`.
bool `const `image_sampler` &` Returns `true` if the sampler is different from `other`.
cl_sampler

Meta-header to include all Boost.Compute OpenGL interop headers.

`event` `const uint_` `const cl_mem *` ``command_queue` &` `const `wait_list` &wait_list()`

Enqueues a command to acquire the specified OpenGL memory objects.

See the documentation for

`event` `const uint_` `const cl_mem *` ``command_queue` &` `const `wait_list` &wait_list()`

Enqueues a command to release the specified OpenGL memory objects.

See the documentation for

`event` `const `opengl_buffer` &` ``command_queue` &` `const `wait_list` &wait_list()`

Enqueues a command to acquire the specified OpenGL buffer.

See the documentation for

`event` `const `opengl_buffer` &` ``command_queue` &` `const `wait_list` &wait_list()`

Enqueues a command to release the specified OpenGL buffer.

See the documentation for

boost::compute::buffer

A OpenCL buffer for accessing an OpenGL memory object.

Creates a null OpenGL buffer object.
cl_mem
bool
true
Creates a new OpenGL buffer object for `mem`.
const `context` &
GLuint
cl_mem_flags
read_write

Creates a new OpenGL buffer object in `context` for `bufobj` with `flags`.

See the documentation for

const `opengl_buffer` &
Creates a new OpenGL buffer object as a copy of `other`.
`opengl_buffer` & `const `opengl_buffer` &` Copies the OpenGL buffer object from `other`.
Destroys the OpenGL buffer object.
GLuint

Returns the OpenGL memory object ID.

See the documentation for

cl_gl_object_type

Returns the OpenGL memory object type.

See the documentation for

boost::compute::image_object

A OpenCL buffer for accessing an OpenGL renderbuffer object.

Creates a null OpenGL renderbuffer object.
cl_mem
bool
true
Creates a new OpenGL renderbuffer object for `mem`.
const `context` &
GLuint
cl_mem_flags
read_write

Creates a new OpenGL renderbuffer object in `context` for `renderbuffer` with `flags`.

See the documentation for

const `opengl_renderbuffer` &
Creates a new OpenGL renderbuffer object as a copy of `other`.
`opengl_renderbuffer` & `const `opengl_renderbuffer` &` Copies the OpenGL renderbuffer object from `other`.
Destroys the OpenGL buffer object.
`extents`< 2 > Returns the size (width, height) of the renderbuffer.
`extents`< 2 > Returns the origin of the renderbuffer (`0`, `0`).
GLuint

Returns the OpenGL memory object ID.

See the documentation for

cl_gl_object_type

Returns the OpenGL memory object type.

See the documentation for

boost::compute::image_object

A OpenCL image2d for accessing an OpenGL texture object.

Creates a null OpenGL texture object.
cl_mem
bool
true
Creates a new OpenGL texture object for `mem`.
const `context` &
GLenum
GLint
GLuint
cl_mem_flags
read_write

Creates a new OpenGL texture object in `context` for `texture` with `flags`.

See the documentation for

const `opengl_texture` &
Creates a new OpenGL texture object as a copy of `other`.
`opengl_texture` & `const `opengl_texture` &` Copies the OpenGL texture object from `other`.
Destroys the texture object.
`extents`< 2 > Returns the size (width, height) of the texture.
`extents`< 2 > Returns the origin of the texture (`0`, `0`).
T `cl_gl_texture_info`

Returns information about the texture.

See the documentation for

Meta-header to include all Boost.Compute iterator headers.

An iterator for values in a buffer.

The buffer_iterator class iterates over values in a memory buffer on a compute device. It is the most commonly used iterator in Boost.Compute and is used by the vector<T> and array<T, N> container classes.

Buffer iterators store a reference to a memory buffer along with an index into that memory buffer.

The buffer_iterator class allows for arbitrary OpenCL memory objects (including those created outside of Boost.Compute) to be used with the Boost.Compute algorithms (such as transform() and sort()). For example, to reverse the contents of an OpenCL memory buffer containing a set of integers:

# See Also:

buffer, make_buffer_iterator()

unspecified
super_type::reference
super_type::difference_type
const `buffer` &
size_t
const `buffer_iterator`< T > &
`buffer_iterator`< T > & `const `buffer_iterator`< T > &`
const `buffer` &
size_t
T ``command_queue` &`
void `const T &` ``command_queue` &`
`buffer_iterator`< T > `const `buffer` &

the buffer object

` `size_t0

the index in the buffer

`

Creates a new buffer_iterator for `buffer` at `index`.

a `buffer_iterator` for `buffer` at `index`

An iterator for a buffer in the `constant` memory space.

The constant_buffer_iterator class provides an iterator for values in a buffer in the `constant` memory space.

For iterating over values in the `global` memory space (the most common case), use the buffer_iterator class.

# See Also:

buffer_iterator

unspecified
super_type::reference
super_type::difference_type
const `buffer` &
size_t
const `constant_buffer_iterator`< T > &
`constant_buffer_iterator`< T > & `const `constant_buffer_iterator`< T > &`
const `buffer` &
size_t
T ``command_queue` &`
void `const T &` ``command_queue` &`
unspecified `const Expr &`
reference
bool `const `constant_buffer_iterator`< T > &`
void
void
void `difference_type`
difference_type `const `constant_buffer_iterator`< T > &`
`constant_buffer_iterator`< T > `const `buffer` &

the buffer object

` `size_t0

the index in the buffer

`

Creates a new constant_buffer_iterator for `buffer` at `index`.

a `constant_buffer_iterator` for `buffer` at `index`

An iterator with a constant value.

The constant_iterator class provides an iterator which returns a constant value when dereferenced.

For example, this could be used to implement the fill() algorithm in terms of the copy() algorithm by copying from a range of constant iterators:

# See Also:

make_constant_iterator()

unspecified
super_type::reference
super_type::difference_type
const T &
size_t
0
const `constant_iterator`< T > &
`constant_iterator`< T > & `const `constant_iterator`< T > &`
size_t
`constant_iterator`< T > `const T &

the constant value

` `size_t0

the iterators index

`

Returns a new constant_iterator with `value` at `index`.

a `constant_iterator` with `value`

The counting_iterator class implements a counting iterator.

A counting iterator returns an internal value (initialized with `init`) which is incremented each time the iterator is incremented.

For example, this could be used to implement the iota() algorithm in terms of the copy() algorithm by copying from a range of counting iterators:

# See Also:

make_counting_iterator()

unspecified
super_type::reference
super_type::difference_type
const T &
const `counting_iterator`< T > &
`counting_iterator`< T > & `const `counting_iterator`< T > &`
size_t
unspecified `const Expr &`
reference
bool `const `counting_iterator`< T > &`
void
void
void `difference_type`
difference_type `const `counting_iterator`< T > &`
`counting_iterator`< T > `const T &

the initial value

`

Returns a new counting_iterator starting at `init`.

For example, to create a counting iterator which returns unsigned integers and increments from one:

    auto iter = make_counting_iterator<uint_>(1);

a counting_iterator with `init`.

An iterator which discards all values written to it.

# See Also:

make_discard_iterator(), constant_iterator

unspecified
super_type::reference
super_type::difference_type
size_t
0
const `discard_iterator` &
`discard_iterator` & `const `discard_iterator` &`
discard_iterator
boost::true_type
internal_ (is_device_iterator specialization for discard_iterator)
`discard_iterator` `size_t0

the index of the iterator

`

Returns a new discard_iterator with `index`.

a `discard_iterator` at `index`

Iterator which returns the result of a function when dereferenced.

For example:

# See Also:

make_function_input_iterator()

unspecified
super_type::reference
super_type::difference_type
Function
const Function &
size_t
0
const `function_input_iterator`< Function > &
`function_input_iterator`< Function > & `const `function_input_iterator`< Function > &`
size_t
unspecified `const Expr &`
reference
bool `const `function_input_iterator`< Function > &`
void
void
void `difference_type`
difference_type `const `function_input_iterator`< Function > &`
`function_input_iterator`< Function > `const Function &

function to execute when dereferenced

` `size_t0

index of the iterator

`

Returns a function_input_iterator with `function`.

a `function_input_iterator` with `function`

The permutation_iterator class provides a permuation iterator.

A permutation iterator iterates over a value range and an index range. When dereferenced, it returns the value from the value range using the current index from the index range.

For example, to reverse a range using the copy() algorithm and a permutation sequence:

# See Also:

make_permutation_iterator()

unspecified
super_type::value_type
super_type::reference
super_type::base_type
super_type::difference_type
IndexIterator
ElementIterator
IndexIterator
const `permutation_iterator`< ElementIterator, IndexIterator > &
`permutation_iterator`< ElementIterator, IndexIterator > & `const `permutation_iterator`< ElementIterator, IndexIterator > &`
size_t
const `buffer` &
unspecified `const IndexExpr &`
reference
`permutation_iterator`< ElementIterator, IndexIterator > `ElementIterator

the element range iterator

` `IndexIterator

the index range iterator

`

Returns a permutation_iterator for `e` using indices from `i`.

a `permutation_iterator` for `e` using `i`

An iterator adaptor with adjustable iteration step.

The strided iterator adaptor skips over multiple elements each time it is incremented or decremented.

# See Also:

buffer_iterator, make_strided_iterator(), make_strided_iterator_end()

unspecified
super_type::value_type
super_type::reference
super_type::base_type
super_type::difference_type
Iterator
difference_type
const `strided_iterator`< Iterator > &
`strided_iterator`< Iterator > & `const `strided_iterator`< Iterator > &`
size_t
const `buffer` &
unspecified `const IndexExpression &`
reference
bool `const `strided_iterator`< Iterator > &`
void
void
void `typename super_type::difference_type`
difference_type `const `strided_iterator`< Iterator > &`
`strided_iterator`< Iterator > `Iterator

the underlying iterator

` `typename std::iterator_traits< Iterator >::difference_type

the iteration step for strided_iterator

`

Returns a strided_iterator for `iterator` with `stride`.

For example, to create an iterator which iterates over every other element in a `vector<int>`:

    auto strided_iterator = make_strided_iterator(vec.begin(), 2);

a `strided_iterator` for `iterator` with `stride`.

`strided_iterator`< Iterator > `Iterator

the iterator referring to the first element accessible through strided_iterator for `first` with `stride`

` `Iterator

the iterator referring to the last element that may be accessible through strided_iterator for `first` with `stride`

` `typename std::iterator_traits< Iterator >::difference_type

the iteration step

`

Returns a strided_iterator which refers to element that would follow the last element accessible through strided_iterator for `first` iterator with `stride`.

Parameter `stride` must be greater than zero.

It can be helpful when iterating over strided_iterator:

    // vec.size() may not be divisible by 3
    auto strided_iterator_begin = make_strided_iterator(vec.begin(), 3);
    auto strided_iterator_end = make_strided_iterator_end(vec.begin(), vec.end(), 3);

    // copy every 3rd element to result
    boost::compute::copy(
            strided_iterator_begin,
            strided_iterator_end,
            result.begin(),
            queue
    );

a `strided_iterator` referring to element that would follow the last element accessible through strided_iterator for `first` iterator with `stride`.

A transform iterator adaptor.

The transform_iterator adaptor applies a unary function to each element produced from the underlying iterator when dereferenced.

For example, to copy from an input range to an output range while taking the absolute value of each element:

# See Also:

buffer_iterator, make_transform_iterator()

unspecified
super_type::value_type
super_type::reference
super_type::base_type
super_type::difference_type
UnaryFunction
InputIterator
UnaryFunction
const `transform_iterator`< InputIterator, UnaryFunction > &
`transform_iterator`< InputIterator, UnaryFunction > & `const `transform_iterator`< InputIterator, UnaryFunction > &`
size_t
const `buffer` &
unspecified `const IndexExpression &`
reference
`transform_iterator`< InputIterator, UnaryFunction > `InputIterator

the underlying iterator

` `UnaryFunction

the unary transform function

`

Returns a transform_iterator for `iterator` with `transform`.

For example, to create an iterator which returns the square-root of each value in a `vector<int>`:

    auto sqrt_iterator = make_transform_iterator(vec.begin(), sqrt<int>());

a `transform_iterator` for `iterator` with `transform`

A zip iterator adaptor.

The zip_iterator class combines values from multiple input iterators. When dereferenced it returns a tuple containing each value at the current position in each input range.

# See Also:

make_zip_iterator()

unspecified
super_type::value_type
super_type::reference
super_type::difference_type
IteratorTuple
IteratorTuple
const `zip_iterator`< IteratorTuple > &
`zip_iterator`< IteratorTuple > & `const `zip_iterator`< IteratorTuple > &`
const IteratorTuple &
unspecified `const IndexExpression &`
reference
bool `const `zip_iterator`< IteratorTuple > &`
void
void
void `difference_type`
difference_type `const `zip_iterator`< IteratorTuple > &`
`zip_iterator`< IteratorTuple > `IteratorTuple

a tuple of input iterators to zip together

`

Creates a zip_iterator for `iterators`.

For example, to zip together iterators from three vectors (`a`, `b`, and `c`):

    auto zipped = boost::compute::make_zip_iterator(
        boost::make_tuple(a.begin(), b.begin(), c.begin())
    );

a `zip_iterator` for `iterators`

A compute kernel.

# See Also:

command_queue, program

Creates a null kernel object.
cl_kernel
bool
true

Creates a new kernel object for `kernel`. If `retain` is `true`, the reference count for `kernel` will be incremented.

const `program` &
const std::string &
Creates a new kernel object with `name` from `program`.
const `kernel` &
Creates a new kernel object as a copy of `other`.
`kernel` & `const `kernel` &` Copies the kernel object from `other` to `*this`.
kernel
&&
Move-constructs a new kernel object from `other`.
`kernel` & ``kernel` &&` Move-assigns the kernel from `other` to `*this`.
Destroys the kernel object.
`kernel`

Creates a new kernel object based on a shallow copy of the undelying OpenCL kernel object.

This method is only available if the OpenCL version is 2.1 or later.

See the documentation for
cl_kernel & Returns a reference to the underlying OpenCL kernel object.
std::string Returns the function name for the kernel.
size_t Returns the number of arguments for the kernel.
`program` Returns the program for the kernel.
`context` Returns the context for the kernel.
T `cl_kernel_info`

Returns information about the kernel.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
T `size_t` `cl_kernel_arg_info`

Returns information about the argument at `index`.

For example, to get the name of the first argument:

    std::string arg = kernel.get_arg_info<std::string>(0, CL_KERNEL_ARG_NAME);

Note, this function requires that the program be compiled with the `"-cl-kernel-arg-info"` flag. For example:

    program.build("-cl-kernel-arg-info");

This method is only available if the OpenCL version is 1.2 or later.

See the documentation for
unspecified int `size_t` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
T `const `device` &` `cl_kernel_work_group_info`

Returns work-group information for the kernel with `device`.

See the documentation for

boost::optional< T > `const `device` &` `cl_kernel_sub_group_info` `const size_t` `const void *`

Returns sub-group information for the kernel with `device`. Returns a null optional if `device` is not 2.1 device, or is not 2.0 device with support for cl_khr_subgroups extension.

This method is only available if the OpenCL version is 2.1 or later. See the documentation for

boost::optional< T > `const `device` &` `cl_kernel_sub_group_info` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
boost::optional< T > `const `device` &` `cl_kernel_sub_group_info` `const size_t` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
boost::optional< T > `const `device` &` `cl_kernel_sub_group_info` `const std::vector< size_t >` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `size_t` `size_t` `const void *`

Sets the argument at `index` to `value` with `size`.

See the documentation for

void `size_t` `const T &`

Sets the argument at `index` to `value`.

For built-in types (e.g. `float`, `int4_`), this is equivalent to calling set_arg(index, sizeof(type), &value).

Additionally, this method is specialized for device memory objects such as buffer and image2d. This allows for them to be passed directly without having to extract their underlying cl_mem object.

This method is also specialized for device container types such as vector<T> and array<T, N>. This allows for them to be passed directly as kernel arguments without having to extract their underlying buffer.

For setting local memory arguments (e.g. "__local float *buf"), the local_buffer<T> class may be used:

    // set argument to a local buffer with storage for 32 float's
    kernel.set_arg(0, local_buffer<float>(32));

For setting NULL to global and constant memory arguments (C++11):

    kernel.set_arg(0, nullptr);

void `size_t` `std::nullptr_t` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void class... `T &&...` Sets the arguments for the kernel to `args`.
void `cl_kernel_exec_info` `size_t` `const void *`

Sets additional execution information for the kernel.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
bool `const `kernel` &` Returns `true` if the kernel is the same at `other`.
bool `const `kernel` &` Returns `true` if the kernel is different from `other`.

Meta-header to include all Boost.Compute memory headers.

Represents a local memory buffer on the device.

The local_buffer class represents a block of local memory on a compute device.

This class is most commonly used to set local memory arguments for compute kernels:

    // set argument to a local buffer with storage for 32 float's
    kernel.set_arg(0, local_buffer<float>(32));

# See Also:

buffer, kernel

const size_t
Creates a local buffer object for `size` elements.
const `local_buffer` &
Creates a local buffer object as a copy of `other`.
`local_buffer` & `const `local_buffer` &` Copies `other` to `*this`.
Destroys the local memory object.
size_t Returns the number of elements in the local buffer.
T
std::ptrdiff_t
T *
T &
std::random_access_iterator_tag
void *
const `context` &
const svm_ptr< T > &
svm_ptr< T > & `const svm_ptr< T > &`
void *
svm_ptr< T > `difference_type`
difference_type `svm_ptr< T >`
const `context` &
bool `const svm_ptr< T > &`
bool `const svm_ptr< T > &`
Base-class for memory objects.

The memory_object class is the base-class for memory objects on compute devices.

# See Also:

buffer, vector

CL_MEM_READ_WRITE
CL_MEM_READ_ONLY
CL_MEM_WRITE_ONLY
CL_MEM_USE_HOST_PTR
CL_MEM_ALLOC_HOST_PTR
CL_MEM_COPY_HOST_PTR
Flags for the creation of memory objects.
Symbolic names for the OpenCL address spaces.
cl_mem & Returns the underlying OpenCL memory object.
size_t Returns the size of the memory object in bytes.
cl_mem_object_type Returns the type for the memory object.
cl_mem_flags Returns the flags for the memory object.
`context` Returns the context for the memory object.
void * Returns the host pointer associated with the memory object.
uint_ Returns the reference count for the memory object.
T `cl_mem_info`

Returns information about the memory object.

See the documentation for

void `void(BOOST_COMPUTE_CL_CALLBACK *callback)(cl_mem memobj, void *user_data)` `void *0`

Registers a function to be called when the memory object is deleted and its resources freed.

See the documentation for

void `Function`

Registers a function to be called when the memory object is deleted and its resources freed.

The function specified by `callback` must be invokable with zero arguments (e.g. `callback()`).

This method is only available if the OpenCL version is 1.1 or later.

bool `const `memory_object` &` Returns `true` if the memory object is the same as `other`.
bool `const `memory_object` &` Returns `true` if the memory object is different from `other`.
boost::compute::memory_object
A FIFO data pipe.

This method is only available if the OpenCL version is 2.0 or later.

# See Also:

memory_object

Creates a null pipe object.
cl_mem
bool
true

Creates a pipe object for `mem`. If `retain` is `true`, the reference count for `mem` will be incremented.

const `context` &
uint_
uint_
cl_mem_flags
read_write
const cl_pipe_properties *
0
Creates a new pipe in `context`.
const `pipe` &
Creates a new pipe object as a copy of `other`.
`pipe` & `const `pipe` &` Copies the pipe object from `other` to `*this`.
pipe
&&
Move-constructs a new pipe object from `other`.
`pipe` & ``pipe` &&` Move-assigns the pipe from `other` to `*this`.
Destroys the pipe object.
uint_ Returns the packet size.
uint_ Returns the max number of packets.
T `cl_pipe_info`

Returns information about the pipe.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
A compute platform.

The platform class provides an interface to an OpenCL platform.

To obtain a list of all platforms on the system use the system::platforms() method.

# See Also:

device, context

cl_platform_id
Creates a new platform object for `id`.
const `platform` &
Creates a new platform as a copy of `other`.
`platform` & `const `platform` &` Copies the platform id from `other`.
Destroys the platform object.
cl_platform_id Returns the ID of the platform.
std::string Returns the name of the platform.
std::string Returns the name of the vendor for the platform.
std::string Returns the profile string for the platform.
std::string Returns the version string for the platform.
std::vector< std::string > Returns a list of extensions supported by the platform.
bool `const std::string &`

Returns `true` if the platform supports the extension with `name`.

std::vector< `device` > `cl_device_typeCL_DEVICE_TYPE_ALL` Returns a list of devices on the platform.
size_t `cl_device_typeCL_DEVICE_TYPE_ALL` Returns the number of devices on the platform.
T `cl_platform_info`

Returns information about the platform.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void * `const char *`

Returns the address of the `function_name` extension function. Returns `0` if `function_name` is invalid.

void Requests that the platform unload any compiler resources.
bool `const `platform` &` Returns `true` if the platform is the same at `other`.
bool `const `platform` &` Returns `true` if the platform is different from `other`.
bool `int` `int`

Returns `true` if the platform OpenCL version is major.minor or newer; otherwise returns `false`.

A compute program.

The program class represents an OpenCL program.

Program objects are created with one of the static `create_with_*` functions. For example, to create a program from a source string:

And to create a program from a source file:

    boost::compute::program bar_program =
        boost::compute::program::create_with_source_file("/path/to/bar.cl", context);

Once a program object has been successfully created, it can be compiled using the `build()` method:

    // build the program
    foo_program.build();

Once the program is built, kernel objects can be created using the `create_kernel()` method by passing their name:

    // create a kernel from the compiled program
    boost::compute::kernel foo_kernel = foo_program.create_kernel("foo");

# See Also:

kernel

Creates a null program object.
cl_program
bool
true

Creates a program object for `program`. If `retain` is `true`, the reference count for `program` will be incremented.

const `program` &
Creates a new program object as a copy of `other`.
`program` & `const `program` &` Copies the program object from `other` to `*this`.
program
&&
Move-constructs a new program object from `other`.
`program` & ``program` &&` Move-assigns the program from `other` to `*this`.
Destroys the program object.
cl_program & Returns the underlying OpenCL program.
std::string Returns the source code for the program.
std::vector< unsigned char > Returns the binary for the program.
std::vector< unsigned char > Returns the SPIR-V binary for the program.
std::vector< `device` >
`context` Returns the context for the program.
T `cl_program_info`

Returns information about the program.

See the documentation for

unspecified int This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
T `cl_program_build_info` `const `device` &`

Returns build information about the program.

For example, this function can be used to retreive the options used to build the program:

    std::string build_options =
        program.get_build_info<std::string>(CL_PROGRAM_BUILD_OPTIONS);

See the documentation for

void `const std::string &std::string()`

Builds the program with `options`.

If the program fails to compile, this function will throw an opencl_error exception.

    try {
        // attempt to compile to program
        program.build();
    }
    catch(boost::compute::opencl_error &e){
        // program failed to compile, print out the build log
        std::cout << program.build_log() << std::endl;
    }

See the documentation for

void `const std::string &std::string()` `const std::vector< std::pair< std::string, `program` > > &std::vector< std::pair< std::string, program > >()`

Compiles the program with `options`.

This method is only available if the OpenCL version is 1.2 or later.

See the documentation for
std::string Returns the build log.
`kernel` `const std::string &`

Creates and returns a new kernel object for `name`.

For example, to create the `"foo"` kernel (after the program has been created and built):

    boost::compute::kernel foo_kernel = foo_program.create_kernel("foo");

bool `const `program` &` Returns `true` if the program is the same at `other`.
bool `const `program` &` Returns `true` if the program is different from `other`.
`program` `const std::vector< `program` > &` `const `context` &` `const std::string &std::string()`

Links the programs in `programs` with `options` in `context`.

This method is only available if the OpenCL version is 1.2 or later.

See the documentation for
`program` `const std::string &` `const `context` &`

Creates a new program with `source` in `context`.

See the documentation for

`program` `const std::vector< std::string > &` `const `context` &`

Creates a new program with `sources` in `context`.

See the documentation for

`program` `const std::string &` `const `context` &`

Creates a new program with `file` in `context`.

See the documentation for

`program` `const std::vector< std::string > &` `const `context` &`

Creates a new program with `files` in `context`.

See the documentation for

`program` `const unsigned char *` `size_t` `const `context` &`

Creates a new program with `binary` of `binary_size` in `context`.

See the documentation for

`program` `const std::vector< unsigned char > &` `const `context` &`

Creates a new program with `binary` in `context`.

See the documentation for

`program` `const std::string &` `const `context` &`

Creates a new program with `file` in `context`.

See the documentation for

`program` `const `context` &` `const std::vector< `device` > &` `const std::string &`

Creates a new program with the built-in kernels listed in `kernel_names` for `devices` in `context`.

This method is only available if the OpenCL version is 1.2 or later.

See the documentation for
`program` `const void *` `const size_t` `const `context` &`

Creates a new program with `il_binary` (SPIR-V binary) of `il_size` size in `context`.

This method is only available if the OpenCL version is 2.1 or later.

See the documentation for
`program` `const std::vector< unsigned char > &` `const `context` &`

Creates a new program with `il_binary` (SPIR-V binary) in `context`.

This method is only available if the OpenCL version is 2.1 or later.

See the documentation for
`program` `const std::string &` `const `context` &`

Creates a new program in `context` using SPIR-V binary `file`.

This method is only available if the OpenCL version is 2.1 or later.

See the documentation for
`program` `const std::string &` `const `context` &` `const std::string &std::string()` Create a new program with `source` in `context` and builds it with `options`.

In case BOOST_COMPUTE_USE_OFFLINE_CACHE macro is defined, the compiled binary is stored for reuse in the offline cache located in $HOME/.boost_compute on UNIX-like systems and in APPDATA%/boost_compute on Windows.

`program` `const std::string &` `const `context` &` `const std::string &std::string()` Create a new program with `file` in `context` and builds it with `options`.

In case BOOST_COMPUTE_USE_OFFLINE_CACHE macro is defined, the compiled binary is stored for reuse in the offline cache located in $HOME/.boost_compute on UNIX-like systems and in APPDATA%/boost_compute on Windows.

std::string `const std::string &`

Meta-header to include all Boost.Compute random headers.

float
Produces random boolean values according to the following discrete probability function with parameter p : P(true/p) = p and P(false/p) = (1 - p)

The following example shows how to setup a bernoulli distribution to produce random boolean values with parameter p = 0.25

RealType
0.5f
Creates a new bernoulli distribution.
Destroys the bernoulli_distribution object.
RealType Returns the value of the parameter p.
void `OutputIterator` `OutputIterator` `Generator &` ``command_queue` &`

Generates bernoulli distributed booleans and stores them in the range [`first`, `last`).

boost::is_floating_point< RealType >::value
"Template argument must be a floating point type"
`mt19937`
uint_
Produces random integers on the interval [0, n), where probability of each integer is given by the weight of the ith integer divided by the sum of all weights.

The following example shows how to setup a discrete distribution to produce 0 and 1 with equal probability

IntType

Creates a new discrete distribution with a single weight p = { 1 }. This distribution produces only zeroes.

InputIterator
InputIterator

Creates a new discrete distribution with weights given by the range [`first`, `last`).

Destroys the discrete_distribution object.
::std::vector< double > Returns the probabilities.
result_type min Returns the minimum potentially generated value.
result_type max Returns the maximum potentially generated value.
void `OutputIterator` `OutputIterator` `Generator &` ``command_queue` &`

Generates uniformly distributed integers and stores them to the range [`first`, `last`).

boost::is_integral< IntType >::value
"Template argument must be integral"
uint_
'Quick and Dirty' linear congruential engine

Quick and dirty linear congruential engine to generate low quality random numbers very quickly. For uses in which good quality of random numbers is required(Monte-Carlo Simulations), use other engines like Mersenne Twister instead.

T
const T
const T
const size_t
command_queue
&
result_type
default_seed
Creates a new linear_congruential_engine and seeds it with `value`.
const `linear_congruential_engine`< T > &
Creates a new linear_congruential_engine object as a copy of `other`.
`linear_congruential_engine`< T > & `const `linear_congruential_engine`< T > &` Copies `other` to `*this`.
Destroys the linear_congruential_engine object.
void `result_type

seed value for the random-number generator

` ``command_queue` &

command queue to perform the operation

`

Seeds the random number generator with `value`.

If no seed value is provided, `default_seed` is used.

void ``command_queue` &` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `OutputIterator` `OutputIterator` ``command_queue` &` Generates random numbers and stores them to the range [`first`, `last`).
void `OutputIterator` `OutputIterator` `Function` ``command_queue` &`

Generates random numbers, transforms them with `op`, and then stores them to the range [`first`, `last`).

void `size_t` ``command_queue` &` Generates `z` random numbers and discards them.
Mersenne twister pseudorandom number generator.
T
const T
const T
const T
command_queue
&
result_type
default_seed
Creates a new mersenne_twister_engine and seeds it with `value`.
const `mersenne_twister_engine`< T > &
Creates a new mersenne_twister_engine object as a copy of `other`.
`mersenne_twister_engine`< T > & `const `mersenne_twister_engine`< T > &` Copies `other` to `*this`.
Destroys the mersenne_twister_engine object.
void `result_type

seed value for the random-number generator

` ``command_queue` &

command queue to perform the operation

`

Seeds the random number generator with `value`.

If no seed value is provided, `default_seed` is used.

void ``command_queue` &` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `OutputIterator` `OutputIterator` ``command_queue` &` Generates random numbers and stores them to the range [`first`, `last`).
void `OutputIterator` `OutputIterator` `Function` ``command_queue` &`

Generates random numbers, transforms them with `op`, and then stores them to the range [`first`, `last`).

void `size_t` ``command_queue` &` Generates `z` random numbers and discards them.
`mersenne_twister_engine`< uint_ >
float
Produces random, normally-distributed floating-point numbers.

The following example shows how to setup a normal distribution to produce random `float` values centered at `5`:

# See Also:

default_random_engine, uniform_real_distribution

RealType
RealType
0.f
RealType
1.f

Creates a new normal distribution producing numbers with the given `mean` and `stddev`.

Destroys the normal distribution object.
result_type Returns the mean value of the distribution.
result_type Returns the standard-deviation of the distribution.
result_type min Returns the minimum value of the distribution.
result_type max Returns the maximum value of the distribution.
void `OutputIterator` `OutputIterator` `Generator &` ``command_queue` &`

Generates normally-distributed floating-point numbers and stores them to the range [`first`, `last`).

boost::is_floating_point< RealType >::value
"Template argument must be a floating point type"
uint_
Threefry pseudorandom number generator.
T
const ulong_
command_queue
&
ulong_
default_seed
Creates a new threefry_engine and seeds it with `value`.
const `threefry_engine`< T > &
Creates a new threefry_engine object as a copy of `other`.
`threefry_engine`< T > & `const `threefry_engine`< T > &` Copies `other` to `*this`.
Destroys the threefry_engine object.
void `ulong_

seed value for the random-number generator

` ``command_queue` &

command queue to perform the operation

`

Seeds the random number generator with `value`.

If no seed value is provided, `default_seed` is used.

void ``command_queue` &` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void `OutputIterator` `OutputIterator` ``command_queue` &` Generates random numbers and stores them to the range [`first`, `last`).
void `OutputIterator` `OutputIterator` `Function` ``command_queue` &`

Generates random numbers, transforms them with `op`, and then stores them to the range [`first`, `last`).

void `size_t` ``command_queue` &` Generates `z` random numbers and discards them.
void
uint_
Produces uniformily distributed random integers.

The following example shows how to setup a uniform int distribution to produce random integers 0 and 1.

IntType
IntType
0
IntType
(std::numeric_limits< IntType >::max)()

Creates a new uniform distribution producing numbers in the range [`a`, `b`].

Destroys the uniform_int_distribution object.
result_type Returns the minimum value of the distribution.
result_type Returns the maximum value of the distribution.
void `OutputIterator` `OutputIterator` `Generator &` ``command_queue` &`

Generates uniformily distributed integers and stores them to the range [`first`, `last`).

boost::is_integral< IntType >::value
"Template argument must be integral"
float
Produces uniformly distributed random floating-point numbers.

The following example shows how to setup a uniform real distribution to produce random `float` values between `1` and `100`.

# See Also:

default_random_engine, normal_distribution

RealType
RealType
0.f
RealType
1.f

Creates a new uniform distribution producing numbers in the range [`a`, `b`). Requires a < b

Destroys the uniform_real_distribution object.
result_type Returns the minimum value of the distribution.
result_type Returns the maximum value of the distribution.
void `OutputIterator` `OutputIterator` `Generator &` ``command_queue` &`

Generates uniformly distributed floating-point numbers and stores them to the range [`first`, `last`).

boost::is_floating_point< RealType >::value
"Template argument must be a floating point type"
svm_ptr< T > `const `context` &` `size_t` `cl_svm_mem_flagsCL_MEM_READ_WRITE` `unsigned int0` Allocates a shared virtual memory (SVM) buffer.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
void `svm_ptr< T >`

Deallocates a shared virtual memory (SVM) buffer.

This method is only available if the OpenCL version is 2.0 or later.

See the documentation for
void `const `context` &` `svm_ptr< T >` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Provides access to platforms and devices on the system.

The system class contains a set of static functions which provide access to the OpenCL platforms and compute devices on the host system.

The default_device() convenience method automatically selects and returns the "best" compute device for the system following a set of heuristics and environment variables. This simplifies setup of the OpenCL enviornment.

# See Also:

platform, device, context

`device`

Returns the default compute device for the system.

The default device is selected based on a set of heuristics and can be influenced using one of the following environment variables:

- `BOOST_COMPUTE_DEFAULT_DEVICE` - name of the compute device (e.g. "GTX TITAN")

- `BOOST_COMPUTE_DEFAULT_DEVICE_TYPE` type of the compute device (e.g. "GPU" or "CPU")

- `BOOST_COMPUTE_DEFAULT_PLATFORM` - name of the platform (e.g. "NVIDIA CUDA")

- `BOOST_COMPUTE_DEFAULT_VENDOR` - name of the device vendor (e.g. "NVIDIA")

- `BOOST_COMPUTE_DEFAULT_ENFORCE` - If this is set to "1", then throw a no_device_found() exception if any of the above environment variables is set, but a matching device was not found.

The default device is determined once on the first time this function is called. Calling this function multiple times will always result in the same device being returned.

If no OpenCL device is found on the system, a no_device_found exception is thrown.

For example, to print the name of the default compute device on the system:

    // get the default compute device
    boost::compute::device device = boost::compute::system::default_device();

    // print the name of the device
    std::cout << "default device: " << device.name() << std::endl;

`device` `const std::string &`

Returns the device with `name`.

`no_device_found` if no device with `name` is found.

std::vector< `device` >

Returns a vector containing all of the compute devices on the system.

For example, to print out the name of each OpenCL-capable device available on the system:

    for(const auto &device : boost::compute::system::devices()){
        std::cout << device.name() << std::endl;
    }

size_t Returns the number of compute devices on the system.
`context`

Returns the default context for the system.

The default context is created for the default device on the system (as returned by default_device()).

The default context is created once on the first time this function is called. Calling this function multiple times will always result in the same context object being returned.

`command_queue` & `const `command_queue` &command_queue()`

Returns the default command queue for the system.

If user-provided command queue is given, the system-wide default context and default device will be set up appropriately so that the default queue matches the default context and device.

If the OpenCL context and device associated with user-provided command queue does not match the default context and device that have already been set, a set_default_queue_error exception is thrown. For example:

The default queue is created once on the first time this function is called. Calling this function multiple times will always result in the same command queue object being returned.

void

Blocks until all outstanding computations on the default command queue are complete.

This is equivalent to:

    system::default_queue().finish();

std::vector< `platform` >

Returns a vector containing each of the OpenCL platforms on the system.

For example, to print out the name of each OpenCL platform present on the system:

    for(const auto &platform : boost::compute::system::platforms()){
        std::cout << platform.name() << std::endl;
    }

size_t Returns the number of compute platforms on the system.
boost::false_type

Meta-function returning `true` if `Iterator` is a device-iterator.

By default, this function returns false. Device iterator types (such as buffer_iterator) should specialize this trait and return `true`.

For example:

    is_device_iterator<buffer_iterator<int>>::value == true
    is_device_iterator<std::vector<int>::iterator>::value == false

boost::false_type

Meta-function returning `true` if `T` is a fundamental (i.e. built-in) type.

For example,

    is_fundamental<float>::value == true
    is_fundamental<std::pair<int, float>>::value == false

boost::mpl::bool_< vector_size< T >::value !=1 >

Meta-function returning `true` if `T` is a vector type.

For example,

    is_vector_type<int>::value == false
    is_vector_type<float4_>::value == true

# See Also:

make_vector_type, vector_size

size_t

Meta-function which returns a vector type for `Scalar` with `Size`.

For example,

    make_vector_type<int, 2>::type == int2_
    make_vector_type<float, 4>::type == float4_

# See Also:

is_vector_type

Returns the result of `Function` when called with `Args`.

For example,

    // int + int = int
    result_of<plus(int, int)>::type == int

::boost::tr1_result_of< Signature >::type

Meta-function returning the scalar type for a vector type.

For example,

    scalar_type<float4_>::type == float

std::string

Returns the OpenCL type definition for `T`.

# See Also:

type_name<T>()

a string containing the type definition for `T`

const char *

Returns the OpenCL type name for the type `T` as a string.

For example:

    type_name<float>() == "float"
    type_name<float4_>() == "float4"

# See Also:

type_definition<T>()

a string containing the type name for `T`

Registers the OpenCL type for the C++ `type` to `name`.

For example, the following will allow Eigen's `Vector2f` type to be used with Boost.Compute algorithms and containers as the built-in `float2` type.

    BOOST_COMPUTE_TYPE_NAME(Eigen::Vector2f, float2)

This macro should be invoked in the global namespace.

# See Also:

type_name()

Meta-function returning the size (number of components) of a vector type `T`. For scalar types this function returns `1`.

For example,

    vector_size<float>::value == 1
    vector_size<float4_>::value == 4

Meta-header to include all Boost.Compute types headers.

The C++ type.

The OpenCL name.

A tuple of the struct's members.

The BOOST_COMPUTE_ADAPT_STRUCT() macro makes a C++ struct/class available to OpenCL kernels.

For example, to adapt a 2D particle struct with position (x, y) and velocity (dx, dy):

    // c++ struct definition
    struct Particle
    {
        float x, y;
        float dx, dy;
    };

    // adapt struct for OpenCL
    BOOST_COMPUTE_ADAPT_STRUCT(Particle, Particle, (x, y, dx, dy))

After adapting the struct it can be used in Boost.Compute containers and with Boost.Compute algorithms:

    // create vector of particles
    boost::compute::vector<Particle> particles = ...

    // function to compare particles by their x-coordinate
    BOOST_COMPUTE_FUNCTION(bool, sort_by_x, (Particle a, Particle b),
    {
        return a.x < b.x;
    });

    // sort particles by their x-coordinate
    boost::compute::sort(
        particles.begin(), particles.end(), sort_by_x, queue
    );

Due to differences in struct padding between the host compiler and the device compiler, the `BOOST_COMPUTE_ADAPT_STRUCT()` macro requires that the adapted struct is packed (i.e. no padding bytes between members).

# See Also:

type_name()

boost::compute::event
An user-created event.

This method is only available if the OpenCL version is 1.1 or later.

# See Also:

event

const `context` &

Creates a new user-event object.

See the documentation for

const `user_event` &
Creates a new user-event from `other`.
`user_event` & `const `user_event` &` Copies the user-event from `other` to `*this`.
user_event
&&
Move-constructs a new user event object from `other`.
`user_event` & ``user_event` &&` Move-assigns the user event from `other` to `*this`.
void `cl_int`

Sets the execution status for the user-event.

See the documentation for

`extents`< sizeof...(Args)> class... `Args...`

The variadic `dim()` function provides a concise syntax for creating extents objects.

For example,

    extents<2> region = dim(640, 480); // region == (640, 480)

# See Also:

extents<N>

size_t

The extents class contains an array of n-dimensional extents.

# See Also:

dim()

size_t
boost::array< size_t, N >
array_type::iterator
array_type::const_iterator
const size_type

Creates an extents object with each component set to zero.

For example:

    extents<3> exts(); // (0, 0, 0)

size_t

Creates an extents object with each component set to `value`.

For example:

    extents<3> exts(1); // (1, 1, 1)

std::initializer_list< size_t >
Creates an extents object with `values`.
size_type Returns the size (i.e. dimensionality) of the extents array.
size_type

Returns the linear size of the extents. This is equivalent to the product of each extent in each dimension.

size_t *

Returns a pointer to the extents data array.

This is useful for passing the extents data to OpenCL APIs which expect an array of `size_t`.

const size_t * This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
iterator
const_iterator
const_iterator
iterator
const_iterator
const_iterator
size_t & `size_t` Returns a reference to the extent at `index`.
const size_t & `size_t` This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool `const `extents` &` Returns `true` if the extents in `*this` are the same as `other`.
bool `const `extents` &` Returns `true` if the extents in `*this` are not the same as `other`.
`result_of`< Function(Args...)>::type class... `const Function &` ``command_queue` &` `const Args &...`

Invokes `function` with `args` on `queue`.

For example, to invoke the builtin abs() function:

    int result = invoke(abs<int>(), queue, -10); // returns 10

boost::noncopyable

The program_cache class stores program objects in a LRU cache.

This class can be used to help mitigate the overhead of OpenCL's run-time kernel compilation model. Commonly used programs can be stored persistently in the cache and only compiled once on their first use.

Program objects are stored and retreived based on a user-defined cache key along with the options used to build the program (if any).

For example, to insert a program into the cache:

    cache.insert("foo", foo_program);

And to retreive the program later:

    boost::optional<program> p = cache.get("foo");
    if(p){
        // program found in cache
    }

# See Also:

program

size_t

Creates a new program cache with space for `capacity` number of program objects.

Destroys the program cache.
size_t Returns the number of program objects currently stored in the cache.
size_t Returns the total capacity of the cache.
void Clears the program cache.
boost::optional< `program` > `const std::string &`

Returns the program object with `key`. Returns a null optional if no program with `key` exists in the cache.

boost::optional< `program` > `const std::string &` `const std::string &`

Returns the program object with `key` and `options`. Returns a null optional if no program with `key` and `options` exists in the cache.

void `const std::string &` `const `program` &` Inserts `program` into the cache with `key`.
void `const std::string &` `const std::string &` `const `program` &` Inserts `program` into the cache with `key` and `options`.
`program` `const std::string &` `const std::string &` `const std::string &` `const `context` &`

Loads the program with `key` from the cache if it exists. Otherwise builds a new program with `source` and `options`, stores it in the cache, and returns it.

This is a convenience function to simplify the common pattern of attempting to load a program from the cache and, if not present, building the program from source and storing it in the cache.

Equivalent to:

    boost::optional<program> p = get(key, options);
    if(!p){
        p = program::create_with_source(source, context);
        p->build(options);
        insert(key, options, *p);
    }
    return *p;

boost::shared_ptr< `program_cache` > `const `context` &`

Returns the global program cache for `context`.

This global cache is used internally by Boost.Compute to store compiled program objects used by its algorithms. All Boost.Compute programs are stored with a cache key beginning with `"__boost"`. User programs should avoid using the same prefix in order to prevent collisions.

Stringizes OpenCL source code.

For example, to create a simple kernel which squares each input value:

    const char source[] = BOOST_COMPUTE_STRINGIZE_SOURCE(
        __kernel void square(const float *input, float *output)
        {
            const uint i = get_global_id(0);
            const float x = input[i];
            output[i] = x * x;
        }
    );

    // create and build square program
    program square_program = program::build_with_source(source, context);

    // create square kernel
    kernel square_kernel(square_program, "square");

Stores a list of events.

The wait_list class stores a set of event objects and can be used to specify dependencies for OpenCL operations or to wait on the host until all of the events have completed.

This class also provides convenience functions for interacting with OpenCL APIs which typically accept event dependencies as a `cl_event*` pointer and a `cl_uint` size. For example:

    wait_list events = ...;

    clEnqueueNDRangeKernel(..., events.get_event_ptr(), events.size(), ...);

# See Also:

event, future<T>

std::vector< `event` >::iterator
std::vector< `event` >::const_iterator
Creates an empty wait-list.
const `event` &
Creates a wait-list containing `event`.
const `wait_list` &
Creates a new wait-list as a copy of `other`.
std::initializer_list< `event` >
Creates a wait-list from `events`.
`wait_list` & `const `wait_list` &` Copies the events in the wait-list from `other`.
wait_list
&&
Move-constructs a new wait list object from `other`.
`wait_list` & ``wait_list` &&` Move-assigns the wait list from `other` to `*this`.
Destroys the wait-list.
bool Returns `true` if the wait-list is empty.
uint_ Returns the number of events in the wait-list.
void Removes all of the events from the wait-list.
const cl_event *

Returns a cl_event pointer to the first event in the wait-list. Returns `0` if the wait-list is empty.

This can be used to pass the wait-list to OpenCL functions which expect a `cl_event` pointer to refer to a list of events.

void `size_t` Reserves a minimum length of storage for the wait list object.
void `const `event` &` Inserts `event` into the wait-list.
void `const `future`< T > &` Inserts the event from `future` into the wait-list.
void

Blocks until all of the events in the wait-list have completed.

Does nothing if the wait-list is empty.

const `event` & `size_t` Returns a reference to the event at specified location `pos`.
`event` & `size_t` Returns a reference to the event at specified location `pos`.
iterator Returns an iterator to the first element of the wait-list.
const_iterator Returns an iterator to the first element of the wait-list.
const_iterator Returns an iterator to the first element of the wait-list.
iterator Returns an iterator to the element following the last element of the wait-list.
const_iterator Returns an iterator to the element following the last element of the wait-list.
const_iterator Returns an iterator to the element following the last element of the wait-list.