]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/README.md
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / compute / README.md
1 # Boost.Compute #
2
3 [![Build Status](https://travis-ci.org/boostorg/compute.svg?branch=master)](https://travis-ci.org/boostorg/compute)
4 [![Build status](https://ci.appveyor.com/api/projects/status/4s2nvfc97m7w23oi/branch/master?svg=true)](https://ci.appveyor.com/project/jszuppe/compute/branch/master)
5 [![Coverage Status](https://coveralls.io/repos/boostorg/compute/badge.svg?branch=master)](https://coveralls.io/r/boostorg/compute)
6 [![Gitter](https://badges.gitter.im/boostorg/compute.svg)](https://gitter.im/boostorg/compute?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
7
8 Boost.Compute is a GPU/parallel-computing library for C++ based on OpenCL.
9
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.
12
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<>`).
19
20 The full documentation is available at http://boostorg.github.io/compute/.
21
22 ## Example ##
23
24 The following example shows how to sort a vector of floats on the GPU:
25
26 ```c++
27 #include <vector>
28 #include <algorithm>
29 #include <boost/compute.hpp>
30
31 namespace compute = boost::compute;
32
33 int main()
34 {
35 // get the default compute device
36 compute::device gpu = compute::system::default_device();
37
38 // create a compute context and command queue
39 compute::context ctx(gpu);
40 compute::command_queue queue(ctx, gpu);
41
42 // generate random numbers on the host
43 std::vector<float> host_vector(1000000);
44 std::generate(host_vector.begin(), host_vector.end(), rand);
45
46 // create vector on the device
47 compute::vector<float> device_vector(1000000, ctx);
48
49 // copy data to the device
50 compute::copy(
51 host_vector.begin(), host_vector.end(), device_vector.begin(), queue
52 );
53
54 // sort data on the device
55 compute::sort(
56 device_vector.begin(), device_vector.end(), queue
57 );
58
59 // copy data back to the host
60 compute::copy(
61 device_vector.begin(), device_vector.end(), host_vector.begin(), queue
62 );
63
64 return 0;
65 }
66 ```
67
68 Boost.Compute is a header-only library, so no linking is required. The example
69 above can be compiled with:
70
71 `g++ -I/path/to/compute/include sort.cpp -lOpenCL`
72
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.
76
77 ## Support ##
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).
80
81 Bugs and feature requests can be reported through the [issue tracker](
82 https://github.com/boostorg/compute/issues?state=open).
83
84 Also feel free to send me an email with any problems, questions, or feedback.
85
86 ## Help Wanted ##
87 The Boost.Compute project is currently looking for additional developers with
88 interest in parallel computing.
89
90 Please send an email to Kyle Lutz (kyle.r.lutz@gmail.com) for more information.