MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / main

Function main

compute/perf/perf_sort_float.cpp:27–72  ·  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 // setup context and queue for the default device
33 boost::compute::device device = boost::compute::system::default_device();
34 boost::compute::context context(device);
35 boost::compute::command_queue queue(context, device);
36 std::cout << "device: " << device.name() << std::endl;
37
38 // create vector of random numbers on the host
39 std::vector<float> host_vector(PERF_N);
40 std::generate(host_vector.begin(), host_vector.end(), rand_float);
41
42 // create vector on the device and copy the data
43 boost::compute::vector<float> device_vector(PERF_N, context);
44 boost::compute::copy(
45 host_vector.begin(),
46 host_vector.end(),
47 device_vector.begin(),
48 queue
49 );
50
51 // sort vector
52 perf_timer t;
53 t.start();
54 boost::compute::sort(
55 device_vector.begin(),
56 device_vector.end(),
57 queue
58 );
59 queue.finish();
60 t.stop();
61 std::cout << "time: " << t.last_time() / 1e6 << " ms" << std::endl;
62
63 // verify vector is sorted
64 if(!boost::compute::is_sorted(device_vector.begin(),
65 device_vector.end(),
66 queue)){
67 std::cout << "ERROR: is_sorted() returned false" << std::endl;
68 return -1;
69 }
70
71 return 0;
72}

Callers

nothing calls this directly

Calls 12

perf_parse_argsFunction · 0.85
copyFunction · 0.85
sortFunction · 0.85
is_sortedFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
last_timeMethod · 0.80
generateFunction · 0.50
nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected