|
7 | 7 | #include <thrust/copy.h> // for copy |
8 | 8 | #include <thrust/iterator/counting_iterator.h> // for make_counting_iterator |
9 | 9 | #include <thrust/sort.h> // for stable_sort_by_key |
10 | | -#include <thrust/tuple.h> // for tuple, get |
11 | 10 |
|
12 | | -#include <cstddef> // size_t |
13 | | -#include <cstdint> // int32_t |
14 | | -#include <cub/cub.cuh> // DispatchSegmentedRadixSort,NullType,DoubleBuffer |
15 | | -#include <iterator> // distance |
16 | | -#include <limits> // numeric_limits |
17 | | -#include <type_traits> // conditional_t,remove_const_t |
| 11 | +#include <cstddef> // size_t |
| 12 | +#include <cstdint> // int32_t |
| 13 | +#include <cub/device/device_run_length_encode.cuh> // for DeviceRunLengthEncode |
| 14 | +#include <cub/device/dispatch/dispatch_radix_sort.cuh> // for DispatchSegmentedRadixSort |
| 15 | +#include <cub/util_type.cuh> // for NullType, DoubleBuffer |
| 16 | +#include <cuda/std/tuple> // for tuple |
| 17 | +#include <functional> // for plus, logical_and |
| 18 | +#include <iterator> // for distance |
| 19 | +#include <limits> // for numeric_limits |
| 20 | +#include <type_traits> // for conditional_t,remove_const_t |
18 | 21 |
|
19 | 22 | #include "common.h" // safe_cuda |
20 | 23 | #include "cuda_context.cuh" // CUDAContext |
@@ -175,30 +178,30 @@ template <typename SegIt, typename ValIt> |
175 | 178 | void SegmentedArgMergeSort(Context const *ctx, SegIt seg_begin, SegIt seg_end, ValIt val_begin, |
176 | 179 | ValIt val_end, dh::device_vector<std::size_t> *p_sorted_idx) { |
177 | 180 | auto cuctx = ctx->CUDACtx(); |
178 | | - using Tup = thrust::tuple<std::int32_t, float>; |
| 181 | + using Tup = cuda::std::tuple<std::int32_t, float>; |
179 | 182 | auto &sorted_idx = *p_sorted_idx; |
180 | 183 | std::size_t n = std::distance(val_begin, val_end); |
181 | 184 | sorted_idx.resize(n); |
182 | 185 | dh::Iota(dh::ToSpan(sorted_idx), cuctx->Stream()); |
183 | 186 | dh::device_vector<Tup> keys(sorted_idx.size()); |
184 | | - auto key_it = dh::MakeTransformIterator<Tup>(thrust::make_counting_iterator(0ul), |
185 | | - [=] XGBOOST_DEVICE(std::size_t i) -> Tup { |
186 | | - std::int32_t seg_idx; |
187 | | - if (i < *seg_begin) { |
188 | | - seg_idx = -1; |
189 | | - } else { |
190 | | - seg_idx = dh::SegmentId(seg_begin, seg_end, i); |
191 | | - } |
192 | | - auto residue = val_begin[i]; |
193 | | - return thrust::make_tuple(seg_idx, residue); |
194 | | - }); |
| 187 | + auto key_it = dh::MakeIndexTransformIter([=] XGBOOST_DEVICE(std::size_t i) -> Tup { |
| 188 | + std::int32_t seg_idx; |
| 189 | + if (i < *seg_begin) { |
| 190 | + seg_idx = -1; |
| 191 | + } else { |
| 192 | + seg_idx = dh::SegmentId(seg_begin, seg_end, i); |
| 193 | + } |
| 194 | + auto residue = val_begin[i]; |
| 195 | + return cuda::std::make_tuple(seg_idx, residue); |
| 196 | + }); |
195 | 197 | thrust::copy(ctx->CUDACtx()->CTP(), key_it, key_it + keys.size(), keys.begin()); |
196 | 198 | thrust::stable_sort_by_key(cuctx->TP(), keys.begin(), keys.end(), sorted_idx.begin(), |
197 | 199 | [=] XGBOOST_DEVICE(Tup const &l, Tup const &r) { |
198 | | - if (thrust::get<0>(l) != thrust::get<0>(r)) { |
199 | | - return thrust::get<0>(l) < thrust::get<0>(r); // segment index |
| 200 | + if (cuda::std::get<0>(l) != cuda::std::get<0>(r)) { |
| 201 | + // segment index |
| 202 | + return cuda::std::get<0>(l) < cuda::std::get<0>(r); |
200 | 203 | } |
201 | | - return thrust::get<1>(l) < thrust::get<1>(r); // residue |
| 204 | + return cuda::std::get<1>(l) < cuda::std::get<1>(r); // residue |
202 | 205 | }); |
203 | 206 | } |
204 | 207 |
|
@@ -331,7 +334,7 @@ template <typename InputIteratorT, typename OutputIteratorT, typename OffsetT> |
331 | 334 | void InclusiveSum(Context const *ctx, InputIteratorT d_in, OutputIteratorT d_out, |
332 | 335 | OffsetT num_items) { |
333 | 336 | #if CUB_VERSION >= 300000 |
334 | | - InclusiveScan(ctx, d_in, d_out, cuda::std::plus{}, num_items); |
| 337 | + InclusiveScan(ctx, d_in, d_out, std::plus{}, num_items); |
335 | 338 | #else |
336 | 339 | InclusiveScan(ctx, d_in, d_out, cub::Sum{}, num_items); |
337 | 340 | #endif |
@@ -370,7 +373,7 @@ AllOf(Policy policy, InputIt first, InputIt second, Chk &&check) { |
370 | 373 | auto n = std::distance(first, second); |
371 | 374 | auto it = |
372 | 375 | dh::MakeIndexTransformIter([=] XGBOOST_DEVICE(std::size_t i) { return check(first[i]); }); |
373 | | - return dh::Reduce(policy, it, it + n, true, thrust::logical_and<>{}); |
| 376 | + return dh::Reduce(policy, it, it + n, true, std::logical_and<>{}); |
374 | 377 | } |
375 | 378 | } // namespace xgboost::common |
376 | 379 | #endif // XGBOOST_COMMON_ALGORITHM_CUH_ |
0 commit comments