scan.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@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. #ifndef BOOST_COMPUTE_ALGORITHM_DETAIL_SCAN_HPP
  11. #define BOOST_COMPUTE_ALGORITHM_DETAIL_SCAN_HPP
  12. #include <boost/compute/device.hpp>
  13. #include <boost/compute/algorithm/detail/scan_on_cpu.hpp>
  14. #include <boost/compute/algorithm/detail/scan_on_gpu.hpp>
  15. namespace boost {
  16. namespace compute {
  17. namespace detail {
  18. template<class InputIterator, class OutputIterator, class T, class BinaryOperator>
  19. inline OutputIterator scan(InputIterator first,
  20. InputIterator last,
  21. OutputIterator result,
  22. bool exclusive,
  23. T init,
  24. BinaryOperator op,
  25. command_queue &queue)
  26. {
  27. const device &device = queue.get_device();
  28. if(device.type() & device::cpu){
  29. return scan_on_cpu(first, last, result, exclusive, init, op, queue);
  30. }
  31. else {
  32. return scan_on_gpu(first, last, result, exclusive, init, op, queue);
  33. }
  34. }
  35. } // end detail namespace
  36. } // end compute namespace
  37. } // end boost namespace
  38. #endif // BOOST_COMPUTE_ALGORITHM_DETAIL_SCAN_HPP