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

Function main

compute/perf/perf_bolt_merge.cpp:21–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include "perf.hpp"
20
21int main(int argc, char *argv[])
22{
23 perf_parse_args(argc, argv);
24
25 std::cout << "size: " << PERF_N << std::endl;
26
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;
30
31 // create vector of random numbers on the host
32 std::vector<int> host_vec1 = generate_random_vector<int>(std::floor(PERF_N / 2.0));
33 std::vector<int> host_vec2 = generate_random_vector<int>(std::ceil(PERF_N / 2.0));
34 // sort them
35 std::sort(host_vec1.begin(), host_vec1.end());
36 std::sort(host_vec2.begin(), host_vec2.end());
37
38 // create device vectors
39 bolt::cl::device_vector<int> device_vec1(PERF_N);
40 bolt::cl::device_vector<int> device_vec2(PERF_N);
41 bolt::cl::device_vector<int> device_vec3(PERF_N);
42
43 // transfer data to the device
44 bolt::cl::copy(host_vec1.begin(), host_vec1.end(), device_vec1.begin());
45 bolt::cl::copy(host_vec2.begin(), host_vec2.end(), device_vec2.begin());
46
47 perf_timer t;
48 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
49 t.start();
50 bolt::cl::merge(
51 device_vec1.begin(), device_vec1.end(),
52 device_vec2.begin(), device_vec2.end(),
53 device_vec3.begin()
54 );
55 t.stop();
56 }
57 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
58
59 return 0;
60}

Callers

nothing calls this directly

Calls 9

perf_parse_argsFunction · 0.85
sortFunction · 0.85
copyFunction · 0.85
mergeFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
min_timeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected