Skip to content

Commit

Permalink
Optimization/buildhist/hist util (#8218)
Browse files Browse the repository at this point in the history
* BuildHistKernel optimization

Co-authored-by: dmitry.razdoburdin <drazdobu@jfldaal005.jf.intel.com>
  • Loading branch information
razdoburdin and dmitry.razdoburdin committed Sep 2, 2022
1 parent b78bc73 commit deae99e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/common/hist_util.cc
Expand Up @@ -192,11 +192,14 @@ void BuildHistKernel(const std::vector<GradientPair> &gpair,
}
const BinIdxType *gr_index_local = gradient_index + icol_start;

// The trick with pgh_t buffer helps the compiler to generate faster binary.
const float pgh_t[] = {pgh[idx_gh], pgh[idx_gh + 1]};
for (size_t j = 0; j < row_size; ++j) {
const uint32_t idx_bin = two * (static_cast<uint32_t>(gr_index_local[j]) +
(any_missing ? 0 : offsets[j]));
hist_data[idx_bin] += pgh[idx_gh];
hist_data[idx_bin + 1] += pgh[idx_gh + 1];
auto hist_local = hist_data + idx_bin;
*(hist_local) += pgh_t[0];
*(hist_local + 1) += pgh_t[1];
}
}
}
Expand Down

0 comments on commit deae99e

Please sign in to comment.