| 32 | ) |
| 33 | |
| 34 | int main(int argc, char *argv[]) |
| 35 | { |
| 36 | perf_parse_args(argc, argv); |
| 37 | |
| 38 | std::cout << "size: " << PERF_N << std::endl; |
| 39 | |
| 40 | bolt::cl::control ctrl = bolt::cl::control::getDefault(); |
| 41 | ::cl::Device device = ctrl.getDevice(); |
| 42 | std::cout << "device: " << device.getInfo<CL_DEVICE_NAME>() << std::endl; |
| 43 | |
| 44 | // create host vectors |
| 45 | std::vector<float> host_x(PERF_N); |
| 46 | std::vector<float> host_y(PERF_N); |
| 47 | std::generate(host_x.begin(), host_x.end(), rand); |
| 48 | std::generate(host_y.begin(), host_y.end(), rand); |
| 49 | |
| 50 | // create device vectors |
| 51 | bolt::cl::device_vector<float> device_x(PERF_N); |
| 52 | bolt::cl::device_vector<float> device_y(PERF_N); |
| 53 | |
| 54 | // transfer data to the device |
| 55 | bolt::cl::copy(host_x.begin(), host_x.end(), device_x.begin()); |
| 56 | bolt::cl::copy(host_y.begin(), host_y.end(), device_y.begin()); |
| 57 | |
| 58 | perf_timer t; |
| 59 | for(size_t trial = 0; trial < PERF_TRIALS; trial++){ |
| 60 | t.start(); |
| 61 | bolt::cl::transform( |
| 62 | device_x.begin(), device_x.end(), |
| 63 | device_y.begin(), |
| 64 | device_y.begin(), |
| 65 | saxpy_functor(2.5f) |
| 66 | ); |
| 67 | t.stop(); |
| 68 | } |
| 69 | std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl; |
| 70 | |
| 71 | // transfer data back to host |
| 72 | bolt::cl::copy(device_x.begin(), device_x.end(), host_x.begin()); |
| 73 | bolt::cl::copy(device_y.begin(), device_y.end(), host_y.begin()); |
| 74 | |
| 75 | return 0; |
| 76 | } |
nothing calls this directly
no test coverage detected