]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/perf/perf_bolt_inner_product.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2015 Jakub Szuppe <j.szuppe@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 //---------------------------------------------------------------------------//
15 #include <bolt/cl/inner_product.h>
16 #include <bolt/cl/copy.h>
17 #include <bolt/cl/device_vector.h>
21 int main(int argc
, char *argv
[])
23 perf_parse_args(argc
, argv
);
25 std::cout
<< "size: " << PERF_N
<< std::endl
;
27 bolt::cl::control ctrl
= bolt::cl::control::getDefault();
28 ::cl::Device device
= ctrl
.getDevice();
29 std::cout
<< "device: " << device
.getInfo
<CL_DEVICE_NAME
>() << std::endl
;
31 // create host vectors
32 std::vector
<int> host_x
= generate_random_vector
<int>(PERF_N
);
33 std::vector
<int> host_y
= generate_random_vector
<int>(PERF_N
);
35 // create device vectors
36 bolt::cl::device_vector
<int> device_x(PERF_N
);
37 bolt::cl::device_vector
<int> device_y(PERF_N
);
39 // transfer data to the device
40 bolt::cl::copy(host_x
.begin(), host_x
.end(), device_x
.begin());
41 bolt::cl::copy(host_y
.begin(), host_y
.end(), device_y
.begin());
45 for(size_t trial
= 0; trial
< PERF_TRIALS
; trial
++){
47 product
= bolt::cl::inner_product(
48 device_x
.begin(), device_x
.end(), device_y
.begin(), 0
52 std::cout
<< "time: " << t
.min_time() / 1e6
<< " ms" << std::endl
;
53 std::cout
<< "product: " << product
<< std::endl
;