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 13The hello world example gives a simple application that prints the name of 14the default compute device on the system. 15 16The [classref boost::compute::system] class provides access to the OpenCL 17platforms and devices present on the host system. 18 19Compute 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 29Before any computation occurs, data must be transferred from the host to the 30compute device. The generic [funcref boost::compute::copy copy()] function 31provides a simple interface for transfering data and the generic 32[classref boost::compute::vector vector<T>] class provides a container for 33storing data on a compute device. 34 35The following example shows how to transfer data from an array on the host to 36a [classref boost::compute::vector vector<T>] on the device and then back to 37a 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 39through 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 48The 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 50transform()] function. 51 52[import ../example/transform_sqrt.cpp] 53[transform_sqrt_example] 54 55[endsect] [/ transforming data] 56[endsect] [/ tutorial ] 57