Thread local memory allocation for BuildHist (#6358)
* thread mem locality * fix apply * cleanup * fix lint * fix tests * simple try * fix * fix * apply comments * fix comments * fix * apply simple comment Co-authored-by: ShvetsKS <kirill.shvets@intel.com>
This commit is contained in:
@@ -35,7 +35,7 @@ void ParallelGHistBuilderReset() {
|
||||
for(size_t inode = 0; inode < kNodesExtended; inode++) {
|
||||
collection.AddHistRow(inode);
|
||||
}
|
||||
|
||||
collection.AllocateAllData();
|
||||
ParallelGHistBuilder<GradientSumT> hist_builder;
|
||||
hist_builder.Init(kBins);
|
||||
std::vector<GHistRow<GradientSumT>> target_hist(kNodes);
|
||||
@@ -91,7 +91,7 @@ void ParallelGHistBuilderReduceHist(){
|
||||
for(size_t inode = 0; inode < kNodes; inode++) {
|
||||
collection.AddHistRow(inode);
|
||||
}
|
||||
|
||||
collection.AllocateAllData();
|
||||
ParallelGHistBuilder<GradientSumT> hist_builder;
|
||||
hist_builder.Init(kBins);
|
||||
std::vector<GHistRow<GradientSumT>> target_hist(kNodes);
|
||||
|
||||
@@ -32,6 +32,8 @@ TEST(PartitionBuilder, BasicTest) {
|
||||
for(size_t j = 0; j < tasks[nid]; ++j) {
|
||||
size_t begin = kBlockSize*j;
|
||||
size_t end = kBlockSize*(j+1);
|
||||
const size_t id = builder.GetTaskIdx(nid, begin);
|
||||
builder.AllocateForTask(id);
|
||||
|
||||
auto left = builder.GetLeftBuffer(nid, begin, end);
|
||||
auto right = builder.GetRightBuffer(nid, begin, end);
|
||||
|
||||
@@ -274,6 +274,7 @@ class QuantileHistMock : public QuantileHistMaker {
|
||||
RealImpl::InitData(gmat, gpair, fmat, tree);
|
||||
GHistIndexBlockMatrix dummy;
|
||||
this->hist_.AddHistRow(nid);
|
||||
this->hist_.AllocateAllData();
|
||||
this->BuildHist(gpair, this->row_set_collection_[nid],
|
||||
gmat, dummy, this->hist_[nid]);
|
||||
|
||||
@@ -315,7 +316,7 @@ class QuantileHistMock : public QuantileHistMaker {
|
||||
|
||||
RealImpl::InitData(gmat, row_gpairs, *dmat, tree);
|
||||
this->hist_.AddHistRow(0);
|
||||
|
||||
this->hist_.AllocateAllData();
|
||||
this->BuildHist(row_gpairs, this->row_set_collection_[0],
|
||||
gmat, quantile_index_block, this->hist_[0]);
|
||||
|
||||
@@ -411,7 +412,7 @@ class QuantileHistMock : public QuantileHistMaker {
|
||||
cm.Init(gmat, 0.0);
|
||||
RealImpl::InitData(gmat, row_gpairs, *dmat, tree);
|
||||
this->hist_.AddHistRow(0);
|
||||
|
||||
this->hist_.AllocateAllData();
|
||||
RealImpl::InitNewNode(0, gmat, row_gpairs, *dmat, tree);
|
||||
|
||||
const size_t num_row = dmat->Info().num_row_;
|
||||
@@ -449,6 +450,8 @@ class QuantileHistMock : public QuantileHistMaker {
|
||||
RealImpl::partition_builder_.Init(1, 1, [&](size_t node_in_set) {
|
||||
return 1;
|
||||
});
|
||||
const size_t task_id = RealImpl::partition_builder_.GetTaskIdx(0, 0);
|
||||
RealImpl::partition_builder_.AllocateForTask(task_id);
|
||||
this->template PartitionKernel<uint8_t>(0, 0, common::Range1d(0, kNRows),
|
||||
split, cm, tree);
|
||||
RealImpl::partition_builder_.CalculateRowOffsets();
|
||||
|
||||
Reference in New Issue
Block a user