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