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

Function main

perf/perf_next_permutation.cpp:28–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28int main(int argc, char *argv[])
29{
30 perf_parse_args(argc, argv);
31 std::cout << "size: " << PERF_N << std::endl;
32
33 // setup context and queue for the default device
34 boost::compute::device device = boost::compute::system::default_device();
35 boost::compute::context context(device);
36 boost::compute::command_queue queue(context, device);
37 std::cout << "device: " << device.name() << std::endl;
38
39 // create vector of random numbers on the host
40 std::vector<int> host_vector(PERF_N);
41 std::generate(host_vector.begin(), host_vector.end(), rand_int);
42 std::sort(host_vector.begin(), host_vector.end(), std::greater<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 perf_timer t;
51 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
52 t.start();
53 boost::compute::next_permutation(
54 device_vector.begin(), device_vector.end(), queue
55 );
56 queue.finish();
57 t.stop();
58 boost::compute::prev_permutation(
59 device_vector.begin(), device_vector.end(), queue
60 );
61 }
62 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
63
64 return 0;
65}

Callers

nothing calls this directly

Calls 13

perf_parse_argsFunction · 0.85
sortFunction · 0.85
copyFunction · 0.85
next_permutationFunction · 0.85
prev_permutationFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
min_timeMethod · 0.80
generateFunction · 0.50
nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected