Skip to content

Commit

Permalink
Use monitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Feb 13, 2019
1 parent a0414ad commit 2d2c53a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/common/hist_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
namespace xgboost {
namespace common {

HistCutMatrix::HistCutMatrix() {
monitor_.Init("HistCutMatrix");
}

void HistCutMatrix::Init(DMatrix* p_fmat, uint32_t max_num_bins) {
monitor_.Start("Init");
const MetaInfo& info = p_fmat->Info();

// safe factor for better accuracy
Expand Down Expand Up @@ -54,6 +59,7 @@ void HistCutMatrix::Init(DMatrix* p_fmat, uint32_t max_num_bins) {
for (const auto &batch : p_fmat->GetRowBatches()) {
size_t group_ind = 0;
if (use_group_ind) {
monitor_.Start("search group");
size_t const base_rowid = batch.base_rowid;
using KIt = std::vector<bst_uint>::const_iterator;
KIt res = std::lower_bound(group_ptr.cbegin(), group_ptr.cend() - 1, base_rowid);
Expand All @@ -63,7 +69,9 @@ void HistCutMatrix::Init(DMatrix* p_fmat, uint32_t max_num_bins) {
LOG(FATAL) << "Row " << base_rowid << " does not lie in any group!\n";
}
group_ind = std::distance(group_ptr.cbegin(), res);
monitor_.Stop("search group");
}

#pragma omp parallel num_threads(nthread) firstprivate(group_ind, use_group_ind)
{
CHECK_EQ(nthread, omp_get_num_threads());
Expand Down Expand Up @@ -95,6 +103,7 @@ void HistCutMatrix::Init(DMatrix* p_fmat, uint32_t max_num_bins) {
}

Init(&sketchs, max_num_bins);
monitor_.Stop("Init");
}

void HistCutMatrix::Init
Expand Down
6 changes: 6 additions & 0 deletions src/common/hist_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "row_set.h"
#include "../tree/param.h"
#include "./quantile.h"
#include "./timer.h"
#include "../include/rabit/rabit.h"

namespace xgboost {
Expand All @@ -35,6 +36,11 @@ struct HistCutMatrix {
void Init(DMatrix* p_fmat, uint32_t max_num_bins);

void Init(std::vector<WXQSketch>* sketchs, uint32_t max_num_bins);

HistCutMatrix();

private:
Monitor monitor_;
};

/*! \brief Builds the cut matrix on the GPU */
Expand Down
2 changes: 2 additions & 0 deletions tests/cpp/common/test_hist_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ TEST(HistCutMatrix, Init) {
HistCutMatrix hmat;
// Don't throw when finding group
EXPECT_NO_THROW(hmat.Init(p_mat.get(), 4));

delete pp_mat;
}

} // namespace common
Expand Down

0 comments on commit 2d2c53a

Please sign in to comment.