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

Function main

perf/perf_binary_find.cpp:29–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29int main(int argc, char *argv[])
30{
31 perf_parse_args(argc, argv);
32 std::cout << "size: " << PERF_N << std::endl;
33
34 // setup context and queue for the default device
35 boost::compute::device device = boost::compute::system::default_device();
36 boost::compute::context context(device);
37 boost::compute::command_queue queue(context, device);
38 std::cout << "device: " << device.name() << std::endl;
39
40 // create vector of random numbers on the host
41 std::vector<int> host_vector(PERF_N);
42 std::generate(host_vector.begin(), host_vector.end(), rand_int);
43
44 // create vector on the device and copy the data
45 boost::compute::vector<int> device_vector(PERF_N, context);
46 boost::compute::copy(
47 host_vector.begin(), host_vector.end(), device_vector.begin(), queue
48 );
49
50 using boost::compute::_1;
51 boost::compute::partition(
52 device_vector.begin(), device_vector.end(), _1 < 20, queue
53 );
54
55 // just to be sure everything is finished before measuring execution time
56 // of binary_find algorithm
57 queue.finish();
58
59 perf_timer t;
60 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
61 t.start();
62 boost::compute::detail::binary_find(
63 device_vector.begin(), device_vector.end(), _1 >= 20, queue
64 );
65 queue.finish();
66 t.stop();
67 }
68 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
69
70 return 0;
71}

Callers

nothing calls this directly

Calls 12

perf_parse_argsFunction · 0.85
copyFunction · 0.85
partitionFunction · 0.85
binary_findFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
min_timeMethod · 0.80
generateFunction · 0.50
nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected