| 23 | } |
| 24 | |
| 25 | int main(int argc, char *argv[]) |
| 26 | { |
| 27 | perf_parse_args(argc, argv); |
| 28 | std::cout << "size: " << PERF_N << std::endl; |
| 29 | |
| 30 | // create vector of random numbers on the host |
| 31 | std::vector<int> host_vector(PERF_N); |
| 32 | std::generate(host_vector.begin(), host_vector.end(), rand_int); |
| 33 | |
| 34 | // trying to find element that isn't in vector (worst-case scenario) |
| 35 | int wanted = rand_int_max + 1; |
| 36 | |
| 37 | // result |
| 38 | std::vector<int>::iterator host_result_it; |
| 39 | |
| 40 | perf_timer t; |
| 41 | for(size_t trial = 0; trial < PERF_TRIALS; trial++){ |
| 42 | t.start(); |
| 43 | host_result_it = std::find(host_vector.begin(), host_vector.end(), wanted); |
| 44 | t.stop(); |
| 45 | } |
| 46 | std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl; |
| 47 | |
| 48 | // verify |
| 49 | if(host_result_it != host_vector.end()){ |
| 50 | std::cout << "ERROR: " |
| 51 | << "host_result_iterator != " |
| 52 | << "host_vector.end()" |
| 53 | << std::endl; |
| 54 | return -1; |
| 55 | } |
| 56 | |
| 57 | return 0; |
| 58 | } |