1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Muhammad Junaid Muzammil <mjunaidmuzammil@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://kylelutz.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11
12 #include <boost/compute/random/threefry_engine.hpp>
13 #include <boost/compute/container/vector.hpp>
14 #include <boost/compute/command_queue.hpp>
15 #include <boost/compute/context.hpp>
16 #include <boost/compute/device.hpp>
17 #include <boost/compute/system.hpp>
18 #include <iostream>
19
main()20 int main()
21 {
22 using boost::compute::uint_;
23 boost::compute::device device = boost::compute::system::default_device();
24 boost::compute::context context(device);
25 boost::compute::command_queue queue(context, device);
26 boost::compute::threefry_engine<> rng(queue);
27 boost::compute::vector<uint_> vector_ctr(20, context);
28
29 uint32_t ctr[20];
30 for(int i = 0; i < 10; i++) {
31 ctr[i*2] = i;
32 ctr[i*2+1] = 0;
33 }
34 boost::compute::copy(ctr, ctr+20, vector_ctr.begin(), queue);
35 rng.generate(vector_ctr.begin(), vector_ctr.end(), queue);
36 boost::compute::copy(vector_ctr.begin(), vector_ctr.end(), ctr, queue);
37
38 for(int i = 0; i < 10; i++) {
39 std::cout << std::hex << ctr[i*2] << " " << ctr[i*2+1] << std::endl;
40 }
41 return 0;
42 }
43
44