File indexing completed on 2025-01-18 09:29:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_DETAIL_FIND_EXTREMA_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_DETAIL_FIND_EXTREMA_HPP
0013
0014 #include <boost/compute/detail/iterator_range_size.hpp>
0015 #include <boost/compute/algorithm/detail/find_extrema_on_cpu.hpp>
0016 #include <boost/compute/algorithm/detail/find_extrema_with_reduce.hpp>
0017 #include <boost/compute/algorithm/detail/find_extrema_with_atomics.hpp>
0018 #include <boost/compute/algorithm/detail/serial_find_extrema.hpp>
0019
0020 namespace boost {
0021 namespace compute {
0022 namespace detail {
0023
0024 template<class InputIterator, class Compare>
0025 inline InputIterator find_extrema(InputIterator first,
0026 InputIterator last,
0027 Compare compare,
0028 const bool find_minimum,
0029 command_queue &queue)
0030 {
0031 size_t count = iterator_range_size(first, last);
0032
0033
0034 if(count == 0 || count == 1){
0035 return first;
0036 }
0037
0038 const device &device = queue.get_device();
0039
0040
0041 if(device.type() & device::cpu) {
0042 return find_extrema_on_cpu(first, last, compare, find_minimum, queue);
0043 }
0044
0045
0046
0047 if(count < 512)
0048 {
0049 return serial_find_extrema(first, last, compare, find_minimum, queue);
0050 }
0051
0052 if(find_extrema_with_reduce_requirements_met(first, last, queue))
0053 {
0054 return find_extrema_with_reduce(first, last, compare, find_minimum, queue);
0055 }
0056
0057
0058
0059 #ifndef BOOST_COMPUTE_CL_VERSION_1_1
0060 return serial_find_extrema(first, last, compare, find_minimum, queue);
0061 #endif
0062
0063 return find_extrema_with_atomics(first, last, compare, find_minimum, queue);
0064 }
0065
0066 }
0067 }
0068 }
0069
0070 #endif