21 #ifndef ROCPRIM_DETAIL_MERGE_PATH_HPP_ 22 #define ROCPRIM_DETAIL_MERGE_PATH_HPP_ 24 #include "../config.hpp" 28 BEGIN_ROCPRIM_NAMESPACE
40 ROCPRIM_DEVICE ROCPRIM_INLINE constexpr
unsigned int count1()
const 45 ROCPRIM_DEVICE ROCPRIM_INLINE constexpr
unsigned int count2()
const 51 template<
class KeysInputIterator1,
class KeysInputIterator2,
class OffsetT,
class BinaryFunction>
52 ROCPRIM_DEVICE ROCPRIM_INLINE OffsetT merge_path(KeysInputIterator1 keys_input1,
53 KeysInputIterator2 keys_input2,
54 const OffsetT input1_size,
55 const OffsetT input2_size,
57 BinaryFunction compare_function)
59 using key_type_1 =
typename std::iterator_traits<KeysInputIterator1>::value_type;
60 using key_type_2 =
typename std::iterator_traits<KeysInputIterator2>::value_type;
62 OffsetT begin = diag < input2_size ? 0u : diag - input2_size;
63 OffsetT end =
min(diag, input1_size);
67 OffsetT a = (begin + end) / 2;
68 OffsetT b = diag - 1 - a;
69 key_type_1 input_a = keys_input1[a];
70 key_type_2 input_b = keys_input2[b];
71 if(!compare_function(input_b, input_a))
84 template<
class KeyType,
unsigned int ItemsPerThread,
class BinaryFunction>
85 ROCPRIM_DEVICE ROCPRIM_INLINE
void serial_merge(KeyType* keys_shared,
86 KeyType (&outputs)[ItemsPerThread],
87 unsigned int (&index)[ItemsPerThread],
89 BinaryFunction compare_function)
91 KeyType a = keys_shared[range.begin1];
92 KeyType b = keys_shared[range.begin2];
95 for(
unsigned int i = 0; i < ItemsPerThread; ++i)
97 bool compare = (range.begin2 >= range.end2)
98 || ((range.begin1 < range.end1) && !compare_function(b, a));
99 unsigned int x = compare ? range.begin1 : range.begin2;
101 outputs[i] = compare ? a : b;
104 KeyType c = keys_shared[++x];
119 template<
class KeyType,
unsigned int ItemsPerThread,
class BinaryFunction>
120 ROCPRIM_DEVICE ROCPRIM_INLINE
void serial_merge(KeyType* keys_shared,
121 KeyType (&outputs)[ItemsPerThread],
123 BinaryFunction compare_function)
125 KeyType a = keys_shared[range.begin1];
126 KeyType b = keys_shared[range.begin2];
129 for(
unsigned int i = 0; i < ItemsPerThread; ++i)
131 bool compare = (range.begin2 >= range.end2)
132 || ((range.begin1 < range.end1) && !compare_function(b, a));
133 unsigned int x = compare ? range.begin1 : range.begin2;
135 outputs[i] = compare ? a : b;
137 KeyType c = keys_shared[++x];
152 template<
class KeyType,
class ValueType,
unsigned int ItemsPerThread,
class BinaryFunction>
153 ROCPRIM_DEVICE ROCPRIM_INLINE
void serial_merge(KeyType* keys_shared,
154 KeyType (&outputs)[ItemsPerThread],
155 ValueType* values_shared,
156 ValueType (&values)[ItemsPerThread],
158 BinaryFunction compare_function)
160 KeyType a = keys_shared[range.begin1];
161 KeyType b = keys_shared[range.begin2];
164 for(
unsigned int i = 0; i < ItemsPerThread; ++i)
166 bool compare = (range.begin2 >= range.end2)
167 || ((range.begin1 < range.end1) && !compare_function(b, a));
168 unsigned int x = compare ? range.begin1 : range.begin2;
170 outputs[i] = compare ? a : b;
171 values[i] = values_shared[x];
173 KeyType c = keys_shared[++x];
190 END_ROCPRIM_NAMESPACE
192 #endif // ROCPRIM_DETAIL_MERGE_PATH_HPP_ ROCPRIM_HOST_DEVICE constexpr T min(const T &a, const T &b)
Returns the minimum of its arguments.
Definition: functional.hpp:63
Deprecated: Configuration of device-level scan primitives.
Definition: block_histogram.hpp:62
ROCPRIM_DEVICE ROCPRIM_INLINE void syncthreads()
Synchronize all threads in a block (tile)
Definition: thread.hpp:216
Definition: merge_path.hpp:33