]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/example/copy_data.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
15 #include <boost/compute/algorithm/copy.hpp>
16 #include <boost/compute/container/vector.hpp>
18 namespace compute
= boost::compute
;
22 // get default device and setup context
23 compute::device device
= compute::system::default_device();
24 compute::context
context(device
);
25 compute::command_queue
queue(context
, device
);
27 // create data array on host
28 int host_data
[] = { 1, 3, 5, 7, 9 };
30 // create vector on device
31 compute::vector
<int> device_vector(5, context
);
33 // copy from host to device
35 host_data
, host_data
+ 5, device_vector
.begin(), queue
38 // create vector on host
39 std::vector
<int> host_vector(5);
41 // copy data back to host
43 device_vector
.begin(), device_vector
.end(), host_vector
.begin(), queue