Use constexpr in dh::CopyIf. (#6828)
This commit is contained in:
parent
b65e3c4444
commit
f294c4e023
@ -1292,14 +1292,14 @@ void InclusiveScan(InputIteratorT d_in, OutputIteratorT d_out, ScanOpT scan_op,
|
|||||||
|
|
||||||
template <typename InIt, typename OutIt, typename Predicate>
|
template <typename InIt, typename OutIt, typename Predicate>
|
||||||
void CopyIf(InIt in_first, InIt in_second, OutIt out_first, Predicate pred) {
|
void CopyIf(InIt in_first, InIt in_second, OutIt out_first, Predicate pred) {
|
||||||
// We loop over batches because thrust::copy_if cant deal with sizes > 2^31
|
// We loop over batches because thrust::copy_if can't deal with sizes > 2^31
|
||||||
// See thrust issue #1302, #6822
|
// See thrust issue #1302, XGBoost #6822
|
||||||
size_t max_copy_size = std::numeric_limits<int>::max() / 2;
|
size_t constexpr kMaxCopySize = std::numeric_limits<int>::max() / 2;
|
||||||
size_t length = std::distance(in_first, in_second);
|
size_t length = std::distance(in_first, in_second);
|
||||||
XGBCachingDeviceAllocator<char> alloc;
|
XGBCachingDeviceAllocator<char> alloc;
|
||||||
for (size_t offset = 0; offset < length; offset += max_copy_size) {
|
for (size_t offset = 0; offset < length; offset += kMaxCopySize) {
|
||||||
auto begin_input = in_first + offset;
|
auto begin_input = in_first + offset;
|
||||||
auto end_input = in_first + std::min(offset + max_copy_size, length);
|
auto end_input = in_first + std::min(offset + kMaxCopySize, length);
|
||||||
out_first = thrust::copy_if(thrust::cuda::par(alloc), begin_input,
|
out_first = thrust::copy_if(thrust::cuda::par(alloc), begin_input,
|
||||||
end_input, out_first, pred);
|
end_input, out_first, pred);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user