• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
13 #include <boost/compute/system.hpp>
14 #include <boost/compute/algorithm/fill.hpp>
15 #include <boost/compute/container/vector.hpp>
16 
17 #include "perf.hpp"
18 
main(int argc,char * argv[])19 int main(int argc, char *argv[])
20 {
21     perf_parse_args(argc, argv);
22     std::cout << "size: " << PERF_N << std::endl;
23 
24     // setup context and queue for the default device
25     boost::compute::device device = boost::compute::system::default_device();
26     boost::compute::context context(device);
27     boost::compute::command_queue queue(context, device);
28     std::cout << "device: " << device.name() << std::endl;
29 
30     // create vector on the device (filled with zeros)
31     boost::compute::vector<int> vec(PERF_N, 0, queue);
32 
33     perf_timer t;
34     for(size_t trial = 0; trial < PERF_TRIALS; trial++){
35         t.start();
36         boost::compute::fill(vec.begin(), vec.end(), int(trial), queue);
37         queue.finish();
38         t.stop();
39     }
40     std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
41 
42     return 0;
43 }
44