tutorial.qbk 1.9 KB

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