Optimization/buildhist/hist util (#8218)

* BuildHistKernel optimization

Co-authored-by: dmitry.razdoburdin <drazdobu@jfldaal005.jf.intel.com>
This commit is contained in:
Dmitry Razdoburdin 2022-09-02 13:39:45 +02:00 committed by GitHub
parent b78bc734d9
commit deae99e662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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];
}
}
}