perf_bolt_fill.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2015 Jakub Szuppe <j.szuppe@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #include <iostream>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <bolt/cl/fill.h>
  14. #include <bolt/cl/copy.h>
  15. #include <bolt/cl/device_vector.h>
  16. #include "perf.hpp"
  17. int main(int argc, char *argv[])
  18. {
  19. perf_parse_args(argc, argv);
  20. std::cout << "size: " << PERF_N << std::endl;
  21. bolt::cl::control ctrl = bolt::cl::control::getDefault();
  22. ::cl::Device device = ctrl.getDevice();
  23. std::cout << "device: " << device.getInfo<CL_DEVICE_NAME>() << std::endl;
  24. // create device vector (filled with zeros)
  25. bolt::cl::device_vector<int> d_vec(PERF_N, 0);
  26. perf_timer t;
  27. for(size_t trial = 0; trial < PERF_TRIALS; trial++){
  28. t.start();
  29. bolt::cl::fill(d_vec.begin(), d_vec.end(), int(trial));
  30. t.stop();
  31. }
  32. std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
  33. return 0;
  34. }