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

Function main

perf/perf_bolt_max_element.cpp:26–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26int main(int argc, char *argv[])
27{
28 perf_parse_args(argc, argv);
29
30 std::cout << "size: " << PERF_N << std::endl;
31
32 bolt::cl::control ctrl = bolt::cl::control::getDefault();
33 ::cl::Device device = ctrl.getDevice();
34 std::cout << "device: " << device.getInfo<CL_DEVICE_NAME>() << std::endl;
35
36 // create host vector
37 std::vector<int> host_vec = generate_random_vector<int>(PERF_N);
38
39 // create device vectors
40 bolt::cl::device_vector<int> device_vec(PERF_N);
41
42 // transfer data to the device
43 bolt::cl::copy(host_vec.begin(), host_vec.end(), device_vec.begin());
44
45 bolt::cl::device_vector<int>::iterator max_iter = device_vec.begin();
46 perf_timer t;
47 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
48 t.start();
49 max_iter = bolt::cl::max_element(device_vec.begin(), device_vec.end());
50 t.stop();
51 }
52
53 int device_max = *max_iter;
54 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
55 std::cout << "max: " << device_max << std::endl;
56
57 // verify max is correct
58 int host_max = *std::max_element(host_vec.begin(), host_vec.end());
59 if(device_max != host_max){
60 std::cout << "ERROR: "
61 << "device_max (" << device_max << ") "
62 << "!= "
63 << "host_max (" << host_max << ")"
64 << std::endl;
65 return -1;
66 }
67
68 return 0;
69}

Callers

nothing calls this directly

Calls 8

perf_parse_argsFunction · 0.85
copyFunction · 0.85
max_elementFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
min_timeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected