1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 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 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #include <iostream>
12 #include <vector>
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/copy.hpp>
16 #include <boost/compute/algorithm/iota.hpp>
17 #include <boost/compute/container/vector.hpp>
18
19 namespace compute = boost::compute;
20
21 // this example demonstrates how to print the values in a vector
main()22 int main()
23 {
24 // get default device and setup context
25 compute::device gpu = compute::system::default_device();
26 compute::context context(gpu);
27 compute::command_queue queue(context, gpu);
28 std::cout << "device: " << gpu.name() << std::endl;
29
30 // create vector on the device and fill with the sequence 1..10
31 compute::vector<int> vector(10, context);
32 compute::iota(vector.begin(), vector.end(), 1, queue);
33
34 //[print_vector_example
35 std::cout << "vector: [ ";
36 boost::compute::copy(
37 vector.begin(), vector.end(),
38 std::ostream_iterator<int>(std::cout, ", "),
39 queue
40 );
41 std::cout << "]" << std::endl;
42 //]
43
44 return 0;
45 }
46