Use thrust functions instead of custom functions (#5544)

This commit is contained in:
Rory Mitchell
2020-04-16 21:41:16 +12:00
committed by GitHub
parent 6a169cd41a
commit e268fb0093
6 changed files with 82 additions and 306 deletions

View File

@@ -44,7 +44,7 @@ class CudfAdapterBatch : public detail::NoMetaInfo {
size_t Size() const { return num_elements_; }
__device__ COOTuple GetElement(size_t idx) const {
size_t column_idx =
dh::UpperBound(column_ptr_.data(), column_ptr_.size(), idx) - 1;
thrust::upper_bound(thrust::seq,column_ptr_.begin(), column_ptr_.end(), idx) - column_ptr_.begin() - 1;
auto& column = columns_[column_idx];
size_t row_idx = idx - column_ptr_[column_idx];
float value = column.valid.Data() == nullptr || column.valid.Check(row_idx)

View File

@@ -49,7 +49,9 @@ __global__ void CompressBinEllpackKernel(
int ncuts = cut_rows[feature + 1] - cut_rows[feature];
// Assigning the bin in current entry.
// S.t.: fvalue < feature_cuts[bin]
bin = dh::UpperBound(feature_cuts, ncuts, fvalue);
bin = thrust::upper_bound(thrust::seq, feature_cuts, feature_cuts + ncuts,
fvalue) -
feature_cuts;
if (bin >= ncuts) {
bin = ncuts - 1;
}