Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy data from Ellpack to GHist. (#8215)
- Loading branch information
1 parent
7ee10e3
commit 441ffc0
Showing
16 changed files
with
459 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*! | ||
* Copyright 2022 by XGBoost Contributors | ||
*/ | ||
#pragma once | ||
|
||
#include <thrust/binary_search.h> // thrust::upper_bound | ||
#include <thrust/execution_policy.h> // thrust::seq | ||
|
||
#include "xgboost/base.h" | ||
#include "xgboost/span.h" | ||
|
||
namespace xgboost { | ||
namespace common { | ||
namespace cuda { | ||
template <typename It> | ||
size_t XGBOOST_DEVICE SegmentId(It first, It last, size_t idx) { | ||
size_t segment_id = thrust::upper_bound(thrust::seq, first, last, idx) - 1 - first; | ||
return segment_id; | ||
} | ||
|
||
template <typename T> | ||
size_t XGBOOST_DEVICE SegmentId(Span<T> segments_ptr, size_t idx) { | ||
return SegmentId(segments_ptr.cbegin(), segments_ptr.cend(), idx); | ||
} | ||
} // namespace cuda | ||
} // namespace common | ||
} // namespace xgboost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*! | ||
* Copyright 2022 by XGBoost Contributors | ||
*/ | ||
#pragma once | ||
#include <algorithm> // std::upper_bound | ||
#include <cinttypes> // std::size_t | ||
|
||
namespace xgboost { | ||
namespace common { | ||
template <typename It, typename Idx> | ||
auto SegmentId(It first, It last, Idx idx) { | ||
std::size_t segment_id = std::upper_bound(first, last, idx) - 1 - first; | ||
return segment_id; | ||
} | ||
} // namespace common | ||
} // namespace xgboost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.