3 [![Build Status](https://travis-ci.org/boostorg/compute.png?branch=master)]
4 (https://travis-ci.org/boostorg/compute)
5 [![Coverage Status](https://coveralls.io/repos/boostorg/compute/badge.png?branch=master)]
6 (https://coveralls.io/r/boostorg/compute)
8 Boost.Compute is a GPU/parallel-computing library for C++ based on OpenCL.
10 The core library is a thin C++ wrapper over the OpenCL API and provides
11 access to compute devices, contexts, command queues and memory buffers.
13 On top of the core library is a generic, STL-like interface providing common
14 algorithms (e.g. `transform()`, `accumulate()`, `sort()`) along with common
15 containers (e.g. `vector<T>`, `flat_set<T>`). It also features a number of
16 extensions including parallel-computing algorithms (e.g. `exclusive_scan()`,
17 `scatter()`, `reduce()`) and a number of fancy iterators (e.g.
18 `transform_iterator<>`, `permutation_iterator<>`, `zip_iterator<>`).
20 The full documentation is available at http://boostorg.github.io/compute/.
24 The following example shows how to sort a vector of floats on the GPU:
29 #include <boost/compute.hpp>
31 namespace compute = boost::compute;
35 // get the default compute device
36 compute::device gpu = compute::system::default_device();
38 // create a compute context and command queue
39 compute::context ctx(gpu);
40 compute::command_queue queue(ctx, gpu);
42 // generate random numbers on the host
43 std::vector<float> host_vector(1000000);
44 std::generate(host_vector.begin(), host_vector.end(), rand);
46 // create vector on the device
47 compute::vector<float> device_vector(1000000, ctx);
49 // copy data to the device
51 host_vector.begin(), host_vector.end(), device_vector.begin(), queue
54 // sort data on the device
56 device_vector.begin(), device_vector.end(), queue
59 // copy data back to the host
61 device_vector.begin(), device_vector.end(), host_vector.begin(), queue
68 Boost.Compute is a header-only library, so no linking is required. The example
69 above can be compiled with:
71 `g++ -I/path/to/compute/include sort.cpp -lOpenCL`
73 More examples can be found in the [tutorial](
74 http://boostorg.github.io/compute/boost_compute/tutorial.html) and under the
75 [examples](https://github.com/boostorg/compute/tree/master/example) directory.
78 Questions about the library (both usage and development) can be posted to the
79 [mailing list](https://groups.google.com/forum/#!forum/boost-compute).
81 Bugs and feature requests can be reported through the [issue tracker](
82 https://github.com/boostorg/compute/issues?state=open).
84 Also feel free to send me an email with any problems, questions, or feedback.
87 The Boost.Compute project is currently looking for additional developers with
88 interest in parallel computing.
90 Please send an email to Kyle Lutz (kyle.r.lutz@gmail.com) for more information.