1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@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 <algorithm>
12 #include <iostream>
13 #include <vector>
14 
15 #include <boost/compute/system.hpp>
16 #include <boost/compute/container/vector.hpp>
17 #include <boost/compute/random/default_random_engine.hpp>
18 #include <boost/compute/random/discrete_distribution.hpp>
19 
20 #include "perf.hpp"
21 
22 namespace compute = boost::compute;
23 
main(int argc,char * argv[])24 int main(int argc, char *argv[])
25 {
26     perf_parse_args(argc, argv);
27     std::cout << "size: " << PERF_N << std::endl;
28 
29     compute::device device = compute::system::default_device();
30     compute::context context(device);
31     compute::command_queue queue(context, device);
32 
33     compute::vector<compute::uint_> vector(PERF_N, context);
34 
35     int weights[] = {1, 1};
36 
37     compute::default_random_engine rng(queue);
38     compute::discrete_distribution<compute::uint_> dist(weights, weights+2);
39 
40     perf_timer t;
41     t.start();
42     dist.generate(vector.begin(), vector.end(), rng, queue);
43     queue.finish();
44     t.stop();
45     std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
46 
47     return 0;
48 }
49