]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/perf/perf_fill.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 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 //---------------------------------------------------------------------------//
13 #include <boost/compute/system.hpp>
14 #include <boost/compute/algorithm/fill.hpp>
15 #include <boost/compute/container/vector.hpp>
19 int main(int argc
, char *argv
[])
21 perf_parse_args(argc
, argv
);
22 std::cout
<< "size: " << PERF_N
<< std::endl
;
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
;
30 // create vector on the device (filled with zeros)
31 boost::compute::vector
<int> vec(PERF_N
, 0, queue
);
34 for(size_t trial
= 0; trial
< PERF_TRIALS
; trial
++){
36 boost::compute::fill(vec
.begin(), vec
.end(), int(trial
), queue
);
40 std::cout
<< "time: " << t
.min_time() / 1e6
<< " ms" << std::endl
;