* Revert " Optimize ‘hist’ for multi-core CPU (#4529)"

This reverts commit 4d6590be3c.

* Fix build
This commit is contained in:
Philip Hyunsu Cho
2019-11-12 09:35:03 -08:00
committed by GitHub
parent 1733c9e8f7
commit f4e7b707c9
9 changed files with 787 additions and 1318 deletions

View File

@@ -27,10 +27,10 @@ class RowSetCollection {
// id of node associated with this instance set; -1 means uninitialized
Elem()
= default;
Elem(const size_t* begin_,
const size_t* end_,
int node_id_)
: begin(begin_), end(end_), node_id(node_id_) {}
Elem(const size_t* begin,
const size_t* end,
int node_id)
: begin(begin), end(end), node_id(node_id) {}
inline size_t Size() const {
return end - begin;
@@ -42,10 +42,6 @@ class RowSetCollection {
std::vector<size_t> right;
};
size_t Size(unsigned node_id) {
return elem_of_each_node_[node_id].Size();
}
inline std::vector<Elem>::const_iterator begin() const { // NOLINT
return elem_of_each_node_.begin();
}
@@ -55,12 +51,12 @@ class RowSetCollection {
}
/*! \brief return corresponding element set given the node_id */
inline Elem operator[](unsigned node_id) const {
const Elem e = elem_of_each_node_[node_id];
inline const Elem& operator[](unsigned node_id) const {
const Elem& e = elem_of_each_node_[node_id];
CHECK(e.begin != nullptr)
<< "access element that is not in the set";
return e;
}
// clear up things
inline void Clear() {
elem_of_each_node_.clear();
@@ -85,29 +81,38 @@ class RowSetCollection {
const size_t* end = dmlc::BeginPtr(row_indices_) + row_indices_.size();
elem_of_each_node_.emplace_back(Elem(begin, end, 0));
}
// split rowset into two
inline void AddSplit(unsigned node_id,
size_t iLeft,
const std::vector<Split>& row_split_tloc,
unsigned left_node_id,
unsigned right_node_id) {
Elem e = elem_of_each_node_[node_id];
const Elem e = elem_of_each_node_[node_id];
const auto nthread = static_cast<bst_omp_uint>(row_split_tloc.size());
CHECK(e.begin != nullptr);
size_t* all_begin = dmlc::BeginPtr(row_indices_);
size_t* begin = all_begin + (e.begin - all_begin);
size_t* begin = const_cast<size_t*>(e.begin);
size_t* split_pt = begin + iLeft;
size_t* it = begin;
for (bst_omp_uint tid = 0; tid < nthread; ++tid) {
std::copy(row_split_tloc[tid].left.begin(), row_split_tloc[tid].left.end(), it);
it += row_split_tloc[tid].left.size();
}
size_t* split_pt = it;
for (bst_omp_uint tid = 0; tid < nthread; ++tid) {
std::copy(row_split_tloc[tid].right.begin(), row_split_tloc[tid].right.end(), it);
it += row_split_tloc[tid].right.size();
}
if (left_node_id >= elem_of_each_node_.size()) {
elem_of_each_node_.resize((left_node_id + 1)*2, Elem(nullptr, nullptr, -1));
elem_of_each_node_.resize(left_node_id + 1, Elem(nullptr, nullptr, -1));
}
if (right_node_id >= elem_of_each_node_.size()) {
elem_of_each_node_.resize((right_node_id + 1)*2, Elem(nullptr, nullptr, -1));
elem_of_each_node_.resize(right_node_id + 1, Elem(nullptr, nullptr, -1));
}
elem_of_each_node_[left_node_id] = Elem(begin, split_pt, left_node_id);
elem_of_each_node_[right_node_id] = Elem(split_pt, e.end, right_node_id);
elem_of_each_node_[node_id] = Elem(begin, e.end, -1);
elem_of_each_node_[node_id] = Elem(nullptr, nullptr, -1);
}
// stores the row indices in the set