| 82 | } |
| 83 | |
| 84 | int main(int argc, char *argv[]) |
| 85 | { |
| 86 | // setup command line arguments |
| 87 | po::options_description options("options"); |
| 88 | options.add_options() |
| 89 | ("help", "show usage instructions") |
| 90 | ("size", po::value<size_t>()->default_value(8192), "input size") |
| 91 | ("trials", po::value<size_t>()->default_value(3), "number of trials to run") |
| 92 | ("tune", "run tuning procedure") |
| 93 | ; |
| 94 | po::positional_options_description positional_options; |
| 95 | positional_options.add("size", 1); |
| 96 | |
| 97 | // parse command line |
| 98 | po::variables_map vm; |
| 99 | po::store( |
| 100 | po::command_line_parser(argc, argv) |
| 101 | .options(options).positional(positional_options).run(), |
| 102 | vm |
| 103 | ); |
| 104 | po::notify(vm); |
| 105 | |
| 106 | const size_t size = vm["size"].as<size_t>(); |
| 107 | const size_t trials = vm["trials"].as<size_t>(); |
| 108 | std::cout << "size: " << size << std::endl; |
| 109 | |
| 110 | // setup context and queue for the default device |
| 111 | compute::device device = boost::compute::system::default_device(); |
| 112 | compute::context context(device); |
| 113 | compute::command_queue queue(context, device); |
| 114 | std::cout << "device: " << device.name() << std::endl; |
| 115 | |
| 116 | // create vector of random numbers on the host |
| 117 | std::vector<unsigned int> data(size); |
| 118 | std::generate(data.begin(), data.end(), rand); |
| 119 | |
| 120 | // run tuning proceure (if requested) |
| 121 | if(vm.count("tune")){ |
| 122 | tune_sort(data, trials, queue); |
| 123 | } |
| 124 | |
| 125 | // run sort benchmark |
| 126 | double t = perf_sort(data, trials, queue); |
| 127 | std::cout << "time: " << t / 1e6 << " ms" << std::endl; |
| 128 | |
| 129 | return 0; |
| 130 | } |