]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [/=========================================================================== |
2 | Copyright (c) 2013-2015 Kyle Lutz <kyle.r.lutz@gmail.com> | |
3 | ||
4 | Distributed under the Boost Software License, Version 1.0 | |
5 | See accompanying file LICENSE_1_0.txt or copy at | |
6 | http://www.boost.org/LICENSE_1_0.txt | |
7 | =============================================================================/] | |
8 | ||
9 | [section:tutorial Tutorial] | |
10 | ||
11 | [section Hello World] | |
12 | ||
13 | The hello world example gives a simple application that prints the name of | |
14 | the default compute device on the system. | |
15 | ||
16 | The [classref boost::compute::system] class provides access to the OpenCL | |
17 | platforms and devices present on the host system. | |
18 | ||
19 | Compute devices are represented with the | |
20 | [classref boost::compute::device device] class. | |
21 | ||
22 | [import ../example/hello_world.cpp] | |
23 | [hello_world_example] | |
24 | ||
25 | [endsect] [/ hello world] | |
26 | ||
27 | [section Transferring Data] | |
28 | ||
29 | Before any computation occurs, data must be transferred from the host to the | |
30 | compute device. The generic [funcref boost::compute::copy copy()] function | |
31 | provides a simple interface for transfering data and the generic | |
32 | [classref boost::compute::vector vector<T>] class provides a container for | |
33 | storing data on a compute device. | |
34 | ||
35 | The following example shows how to transfer data from an array on the host to | |
36 | a [classref boost::compute::vector vector<T>] on the device and then back to | |
37 | a separate `std::vector<T>` on the host. At the end of the example both | |
38 | `host_array` and `host_vector` contain the same values which were copied | |
39 | through the memory on the compute device. | |
40 | ||
41 | [import ../example/copy_data.cpp] | |
42 | [copy_data_example] | |
43 | ||
44 | [endsect] [/ transferring data] | |
45 | ||
46 | [section Transforming Data] | |
47 | ||
48 | The following example shows how to calculate the square-root of a vector of | |
49 | `float`s on a compute device using the [funcref boost::compute::transform | |
50 | transform()] function. | |
51 | ||
52 | [import ../example/transform_sqrt.cpp] | |
53 | [transform_sqrt_example] | |
54 | ||
55 | [endsect] [/ transforming data] | |
56 | [endsect] [/ tutorial ] |