# Header Reference

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

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

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

See Also:

reduce()

the accumulated result value

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

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

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.

See Also:

adjacent_find()

`OutputIterator` to the end of the result range

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

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

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

See Also:

find(), adjacent_difference()

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

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`).

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:

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`).

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

`

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

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

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`.

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

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

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`).

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`.

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

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

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`).

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

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

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.

See Also:

inclusive_scan()

`OutputIterator` to the end of the result range

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

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`.

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`.

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

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`.

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`.

See Also:

find_if()

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

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

See Also:

transform()

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

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

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`.

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`).

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

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

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

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

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

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

See Also:

exclusive_scan()

`OutputIterator` to the end of the result range

T `InputIterator1` `InputIterator1` `InputIterator2` `T` `command_queue &system::default_queue()`
T `InputIterator1` `InputIterator1` `InputIterator2` `T` `BinaryAccumulateFunction` `BinaryTransformFunction` `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`.

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.

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`, ``...).
bool `InputIterator` `InputIterator` `UnaryPredicate` `command_queue &system::default_queue()`

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

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)

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

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

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

See Also:

sort()

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

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

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`.

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

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

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

See Also:

min_element()

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

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

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.

See Also:

inplace_merge()

`OutputIterator` to the end of the result range

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

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

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

See Also:

max_element()

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

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

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`).

See Also:

max_element(), min_element()

std::pair< InputIterator1, InputIterator2 > `InputIterator1` `InputIterator1` `InputIterator2` `command_queue &system::default_queue()`
std::pair< InputIterator1, InputIterator2 > `InputIterator1` `InputIterator1` `InputIterator2` `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.

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

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`).

See Also:

all_of(), any_of()

void `Iterator` `Iterator` `Iterator` `Compare` `command_queue &system::default_queue()`
void `Iterator` `Iterator` `Iterator` `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.

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`.

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.

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`.

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)

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

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`).

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

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

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.

See Also:

accumulate()

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

`
std::pair< OutputKeyIterator, OutputValueIterator > `InputKeyIterator` `InputKeyIterator` `InputValueIterator` `OutputKeyIterator` `OutputValueIterator` `BinaryFunction` `command_queue &system::default_queue()`
std::pair< OutputKeyIterator, OutputValueIterator > `InputKeyIterator` `InputKeyIterator` `InputValueIterator` `OutputKeyIterator` `OutputValueIterator` `command_queue &system::default_queue()`

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:

See Also:

reduce()

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

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

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`).

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`.

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`.

See Also:

replace()

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

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

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`.

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.

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.

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`.

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

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

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

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

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

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

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

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

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

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

See Also:

is_sorted()

void `KeyIterator` `KeyIterator` `ValueIterator` `Compare` `command_queue &system::default_queue()`
void `KeyIterator` `KeyIterator` `ValueIterator` `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.

See Also:

sort()

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.

See Also:

is_partitioned() and partition()

Iterator pointing to end of true values

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

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

See Also:

sort(), is_sorted()

void `KeyIterator` `KeyIterator` `ValueIterator` `Compare` `command_queue &system::default_queue()`
void `KeyIterator` `KeyIterator` `ValueIterator` `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.

See Also:

sort()

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`.

OutputIterator `InputIterator` `InputIterator` `OutputIterator` `UnaryOperator` `command_queue &system::default_queue()`
OutputIterator `InputIterator1` `InputIterator1` `InputIterator2` `OutputIterator` `BinaryOperator` `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:

See Also:

copy()

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`.

void `InputIterator` `InputIterator` `OutputIterator` `UnaryTransformFunction` `BinaryReduceFunction` `command_queue &system::default_queue()`
void `InputIterator1` `InputIterator1` `InputIterator2` `OutputIterator` `BinaryTransformFunction` `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:

See Also:

reduce(), inner_product()

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

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

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

See Also:

unique_copy()

`InputIterator` to the new logical end of the range

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

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

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.

See Also:

unique()

`OutputIterator` to the end of the result range

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`.

The `buffer_allocator` class allocates memory with buffer objects.

See Also:

buffer

T
unspecified
unspecified
std::size_t
std::ptrdiff_t
pointer `size_type`
void `pointer` `size_type`
size_type
context
const context &
const `buffer_allocator`< T > &
`buffer_allocator`< T > & `const `buffer_allocator`< T > &`
buffer_allocator
< T > &&
`buffer_allocator`< T > & ``buffer_allocator`< T > &&`
void `cl_mem_flags`
boost::compute::buffer_allocator< T >
const context &
const pinned_allocator< T > &
pinned_allocator< T > & `const pinned_allocator< T > &`
Holds the result of an asynchronous computation.

See Also:

event, `wait_list`

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.
const T &
const event &
const `future`< T > &
`future` & `const `future`< T > &`
void class... `Events &&...`

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

See Also:

event, `wait_list`

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.

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` >
`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 &
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 > &`
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
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.
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 > &`
std::ostream & `std::ostream &` ``boost::compute::basic_string`< CharT, Traits >const &`
ulong_

boost::compute::buffer_allocator

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 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.
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.
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
`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 &`
const context &
system::default_context()
const flat_map< Key, T > &
flat_map< Key, T > & `const flat_map< Key, T > &`
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
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 &`
const context &
system::default_context()
const flat_set< T > &
flat_set< T > & `const flat_set< T > &`
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 >
`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 clEnqueueMapBuffer() for more information.

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 clEnqueueUnmapMemObject() for more information.

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.
`vector`< T >
container_type::size_type
container_type::value_type
bool
size_type
value_type
void `const T &`
void
const stack< T > &
stack< T > & `const stack< T > &`
`basic_string`< char_ >
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 &
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 > &`
`buffer_iterator`< T >
`buffer_iterator`< T >

boost::compute::buffer_allocator

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` >
`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.
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.
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 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.
const context *
const char *
const void *
size_t
Creates a new context error exception object.
Destroys the context error object.
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`

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

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

See Also:

`context_error`

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.
cl_int
Creates a new `opencl_error` exception object for `error`.
Destroys the `opencl_error` object.
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.

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`

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.

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.

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

See Also:

`convert<T>`

T
function< T(T *, T)>
function< T(T *, T)>
function< T(T *, T)>
function< T(T *)>
function< T(T *)>
function< T(T *, T, T)>
function< T(T *, T)>
function< T(T *, T)>
function< T(T *, T)>
function< T(T *, T)>
function< T(T *, T)>
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::unary_function< void, int >

The `unary_negate` function adaptor negates a unary function.

See Also:

not1()

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

`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`

function< T(T)>

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

See the documentation for popcount() for more information.

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`

`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 clGetImageInfo() for more information.

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.

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 clCreateImage() for more information.

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.
std::vector< `image_format` > `const context &` `cl_mem_flagsread_write`

Returns the supported image formats for the context.

See the documentation for clGetSupportedImageFormats() for more information.

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`

`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 clGetImageInfo() for more information.

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.

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 clCreateImage() for more information.

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.
std::vector< `image_format` > `const context &` `cl_mem_flagsread_write`

Returns the supported image formats for the context.

See the documentation for clGetSupportedImageFormats() for more information.

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`

`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 clGetImageInfo() for more information.

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.

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 clCreateImage() for more information.

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.
std::vector< `image_format` > `const context &` `cl_mem_flagsread_write`

Returns the supported 3D image formats for the context.

See the documentation for clGetSupportedImageFormats() for more information.

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
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`.
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.
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`

T `cl_mem_info`

Returns information about the image object.

See the documentation for clGetImageInfo() for more information.

`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`.

cl_mem
bool
true
const `image_object` &
`image_object` & `const `image_object` &`
image_object
&&
Destroys the image object.
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 clGetSupportedImageFormats() for more information.

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
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 clGetSamplerInfo() for more information.

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
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.
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 clEnqueueAcquireGLObjects() for more information.

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 clEnqueueReleaseGLObjects() for more information.

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

Enqueues a command to acquire the specified OpenGL buffer.

See the documentation for clEnqueueAcquireGLObjects() for more information.

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

Enqueues a command to release the specified OpenGL buffer.

See the documentation for clEnqueueReleaseGLObjects() for more information.

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.

buffer

A OpenCL buffer for accessing an OpenGL memory object.

GLuint

Returns the OpenGL memory object ID.

See the documentation for clGetGLObjectInfo() for more information.

cl_gl_object_type

Returns the OpenGL memory object type.

See the documentation for clGetGLObjectInfo() for more information.

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 clCreateFromGLBuffer() for more information.

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.
boost::compute::image_object

A OpenCL buffer for accessing an OpenGL renderbuffer 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 clGetGLObjectInfo() for more information.

cl_gl_object_type

Returns the OpenGL memory object type.

See the documentation for clGetGLObjectInfo() for more information.

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 clCreateFromGLRenderbuffer() for more information.

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.
boost::compute::image_object

A OpenCL `image2d` for accessing an OpenGL 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 clGetGLTextureInfo() for more information.

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 clCreateFromGLTexture() for more information.

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.
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
T `command_queue &`
void `const T &` `command_queue &`
const buffer &
size_t
const `buffer_iterator`< T > &
`buffer_iterator`< T > & `const `buffer_iterator`< T > &`
`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
T `command_queue &`
void `const T &` `command_queue &`
unspecified `const Expr &`
const buffer &
size_t
const `constant_buffer_iterator`< T > &
`constant_buffer_iterator`< T > & `const `constant_buffer_iterator`< T > &`
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
size_t
const T &
size_t
0
const `constant_iterator`< T > &
`constant_iterator`< T > & `const `constant_iterator`< 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
size_t
unspecified `const Expr &`
const T &
const `counting_iterator`< T > &
`counting_iterator`< T > & `const `counting_iterator`< T > &`
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`.

type
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
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
size_t
unspecified `const Expr &`
const Function &
size_t
0
const `function_input_iterator`< Function > &
`function_input_iterator`< Function > & `const `function_input_iterator`< Function > &`
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
size_t
const buffer &
unspecified `const IndexExpr &`
ElementIterator
IndexIterator
const `permutation_iterator`< ElementIterator, IndexIterator > &
`permutation_iterator`< ElementIterator, IndexIterator > & `const `permutation_iterator`< ElementIterator, IndexIterator > &`
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
size_t
const buffer &
unspecified `const IndexExpression &`
Iterator
difference_type
const `strided_iterator`< Iterator > &
`strided_iterator`< Iterator > & `const `strided_iterator`< Iterator > &`
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
size_t
const buffer &
unspecified `const IndexExpression &`
InputIterator
UnaryFunction
const `transform_iterator`< InputIterator, UnaryFunction > &
`transform_iterator`< InputIterator, UnaryFunction > & `const `transform_iterator`< InputIterator, UnaryFunction > &`
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
const IteratorTuple &
unspecified `const IndexExpression &`
IteratorTuple
const `zip_iterator`< IteratorTuple > &
`zip_iterator`< IteratorTuple > & `const `zip_iterator`< IteratorTuple > &`
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`

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

size_t Returns the number of elements in the local buffer.
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.
T
std::ptrdiff_t
T *
T &
std::random_access_iterator_tag
void *
svm_ptr< T > `difference_type`
difference_type `svm_ptr< T >`
context &
void *
const context &
const svm_ptr< T > &
svm_ptr< T > & `const svm_ptr< T > &`
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 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`).

RealType
0.5f
Creates a new bernoulli distribution.
Destroys the `bernoulli_distribution` object.
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
::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`).

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.
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
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.
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.
Mersenne twister pseudorandom number generator.
T
const T
const T
const T
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.
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.
`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
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`).

RealType
0.f
RealType
1.f

Creates a new normal distribution producing numbers with the given `mean` and `stddev`.

Destroys the normal distribution object.
boost::is_floating_point< RealType >::value
"Template argument must be a floating point type"
uint_
Threefry pseudorandom number generator.
T
const size_t
void `OutputIterator` `OutputIterator` `OutputIterator` `OutputIterator` `command_queue &`

Generates Threefry random numbers using both the counter and key values, and then stores them to the range [`first_ctr`, `last_ctr`).

void `OutputIterator` `OutputIterator` `command_queue &`
command_queue &
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.
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
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`).

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.
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
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`).

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.
boost::is_floating_point< RealType >::value
"Template argument must be a floating point type"
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

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

`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
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`.

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`.
`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

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 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;

size_t

Creates a new program cache with space for `capacity` number of program objects.

Destroys the program cache.
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
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.
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.