Fix performance degradation of BuildHist on Windows (#2243)

Reported in issue #2165. Dynamic scheduling of OpenMP loops involve
implicit synchronization. To implement synchronization, libgomp uses futex
(fast userspace mutex), whereas MinGW uses kernel-space mutex, which is more
costly. With chunk size of 1, synchronization overhead may become prohibitive
on Windows machines.

Solution: use 'guided' schedule to minimize the number of syncs
This commit is contained in:
Philip Cho 2017-05-01 15:54:44 -07:00 committed by Tianqi Chen
parent da58f34ff8
commit d769b6bcb5

View File

@ -188,7 +188,7 @@ void GHistBuilder::BuildHist(const std::vector<bst_gpair>& gpair,
stat_buf_[i] = stat;
}
#pragma omp parallel for num_threads(nthread) schedule(dynamic)
#pragma omp parallel for num_threads(nthread) schedule(guided)
for (bst_omp_uint i = 0; i < nrows - rest; i += K) {
const bst_omp_uint tid = omp_get_thread_num();
const size_t off = tid * nbins_;