| 24 | } |
| 25 | |
| 26 | int main(int argc, char *argv[]) |
| 27 | { |
| 28 | perf_parse_args(argc, argv); |
| 29 | std::cout << "size: " << PERF_N << std::endl; |
| 30 | |
| 31 | // setup context and queue for the default device |
| 32 | boost::compute::device device = boost::compute::system::default_device(); |
| 33 | boost::compute::context context(device); |
| 34 | boost::compute::command_queue queue(context, device); |
| 35 | std::cout << "device: " << device.name() << std::endl; |
| 36 | |
| 37 | // create vector of random numbers on the host |
| 38 | std::vector<int> host_vector(PERF_N); |
| 39 | std::generate(host_vector.begin(), host_vector.end(), rand_int); |
| 40 | |
| 41 | perf_timer t; |
| 42 | for(size_t trial = 0; trial < PERF_TRIALS; trial++){ |
| 43 | boost::compute::vector<int> device_vector( |
| 44 | host_vector.begin(), host_vector.end(), queue |
| 45 | ); |
| 46 | |
| 47 | t.start(); |
| 48 | device_vector.erase( |
| 49 | boost::compute::remove( |
| 50 | device_vector.begin(), device_vector.end(), 4, queue |
| 51 | ), |
| 52 | device_vector.end(), |
| 53 | queue |
| 54 | ); |
| 55 | queue.finish(); |
| 56 | t.stop(); |
| 57 | } |
| 58 | std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl; |
| 59 | |
| 60 | return 0; |
| 61 | } |