| 24 | } |
| 25 | |
| 26 | int 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 | } |
nothing calls this directly
no test coverage detected