]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/doc/tutorial_vexcl_opencl.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / numeric / odeint / doc / tutorial_vexcl_opencl.qbk
1 [/============================================================================
2 Boost.odeint
3
4 Copyright 2012 Karsten Ahnert
5 Copyright 2012 Sylwester Arabas
6 Copyright 2012-2013 Mario Mulansky
7
8 Use, modification and distribution is subject to the Boost Software License,
9 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 http://www.boost.org/LICENSE_1_0.txt)
11 =============================================================================/]
12
13
14 [section Using OpenCL via VexCL]
15
16 [import ../examples/vexcl/lorenz_ensemble.cpp]
17
18 In the previous section the usage of odeint in combination with __thrust was shown. In this section we show how one can use OpenCL with odeint. The point of odeint is not to implement its own low-level data structures and algorithms, but to use high level libraries doing this task. Here, we will use the __vexcl framework to use OpenCL. __vexcl is a nice library for general computations and it uses heavily expression templates. With the help of __vexcl it is possible to write very compact and expressive application.
19
20 [note vexcl needs C++11 features! So you have to compile with C++11 support enabled.]
21
22 To use __vexcl one needs to include one additional header which includes the data-types and algorithms from vexcl and the adaption to odeint. Adaption to odeint means here only to adapt the resizing functionality of __vexcl to odeint.
23
24 [vexcl_includes]
25
26 To demonstrate the use of __vexcl we integrate an ensemble of Lorenz system. The example is very similar to the parameter study of the Lorenz system in the previous section except that we do not compute the Lyapunov exponents. Again, we vary the parameter R of the Lorenz system an solve a whole ensemble of Lorenz systems in parallel (each with a different parameter R). First, we define the state type and a vector type
27
28 [vexcl_state_types ]
29
30 The `vector_type` is used to represent the parameter R. The `state_type` is a multi-vector of three sub vectors and is used to represent. The first component of this multi-vector represent all `x` components of the Lorenz system, while the second all `y` components and the third all `z` components. The components of this vector can be obtained via
31
32 ``
33 auto &x = X(0);
34 auto &y = X(1);
35 auto &z = X(2);
36 ``
37
38 As already mentioned __vexcl supports expression templates and we will use them to implement the system function for the Lorenz ensemble:
39
40 [vexcl_system]
41
42 It's very easy, isn't it? These three little lines do all the computations for
43 you. There is no need to write your own OpenCL kernels. __vexcl does
44 everything for you. Next we have to write the main application. We initialize
45 the vector of parameters (R) and the initial state. Note that __vexcl requires
46 the `vector_space_algebra`, but that is automatically deduced and configured
47 by odeint internally, so we only have to specify the `state_type` when
48 instantiating the stepper and we are done:
49
50 [vexcl_main]
51
52
53 [endsect]