MCPcopy Create free account
hub / github.com/boostorg/compute / main

Function main

perf/perf_inner_product.cpp:27–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27int main(int argc, char *argv[])
28{
29 perf_parse_args(argc, argv);
30 std::cout << "size: " << PERF_N << std::endl;
31
32 boost::compute::device device = boost::compute::system::default_device();
33 boost::compute::context context(device);
34 boost::compute::command_queue queue(context, device);
35 std::cout << "device: " << device.name() << std::endl;
36
37 std::vector<int> h1(PERF_N);
38 std::vector<int> h2(PERF_N);
39 std::generate(h1.begin(), h1.end(), rand_int);
40 std::generate(h2.begin(), h2.end(), rand_int);
41
42 // create vector on the device and copy the data
43 boost::compute::vector<int> d1(PERF_N, context);
44 boost::compute::vector<int> d2(PERF_N, context);
45 boost::compute::copy(h1.begin(), h1.end(), d1.begin(), queue);
46 boost::compute::copy(h2.begin(), h2.end(), d2.begin(), queue);
47
48 int product = 0;
49 perf_timer t;
50 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
51 t.start();
52 product = boost::compute::inner_product(
53 d1.begin(), d1.end(), d2.begin(), int(0), queue
54 );
55 queue.finish();
56 t.stop();
57 }
58 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
59
60 // verify product is correct
61 int host_product = std::inner_product(
62 h1.begin(), h1.end(), h2.begin(), int(0)
63 );
64 if(product != host_product){
65 std::cout << "ERROR: "
66 << "device_product (" << product << ") "
67 << "!= "
68 << "host_product (" << host_product << ")"
69 << std::endl;
70 return -1;
71 }
72
73 return 0;
74}

Callers

nothing calls this directly

Calls 11

perf_parse_argsFunction · 0.85
generateFunction · 0.85
copyFunction · 0.85
inner_productFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
min_timeMethod · 0.80
nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected