Fix span reverse iterator. (#7387)
* Fix span reverse iterator. * Disable `rbegin` on device code to avoid calling host function. * Add `trbegin` and friends.
This commit is contained in:
@@ -957,6 +957,16 @@ thrust::device_ptr<T> tend(xgboost::common::Span<T>& span) { // NOLINT
|
||||
return tbegin(span) + span.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
XGBOOST_DEVICE auto trbegin(xgboost::common::Span<T> &span) { // NOLINT
|
||||
return thrust::make_reverse_iterator(span.data() + span.size());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
XGBOOST_DEVICE auto trend(xgboost::common::Span<T> &span) { // NOLINT
|
||||
return trbegin(span) + span.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
thrust::device_ptr<T const> tcbegin(xgboost::common::Span<T> const& span) { // NOLINT
|
||||
return thrust::device_ptr<T const>(span.data());
|
||||
@@ -967,6 +977,16 @@ thrust::device_ptr<T const> tcend(xgboost::common::Span<T> const& span) { // NO
|
||||
return tcbegin(span) + span.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
XGBOOST_DEVICE auto tcrbegin(xgboost::common::Span<T> const &span) { // NOLINT
|
||||
return thrust::make_reverse_iterator(span.data() + span.size());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
XGBOOST_DEVICE auto tcrend(xgboost::common::Span<T> const &span) { // NOLINT
|
||||
return tcrbegin(span) + span.size();
|
||||
}
|
||||
|
||||
// This type sorts an array which is divided into multiple groups. The sorting is influenced
|
||||
// by the function object 'Comparator'
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user