From d769b6bcb5fc9970f19a34ae7f63942e6aeceeff Mon Sep 17 00:00:00 2001 From: Philip Cho Date: Mon, 1 May 2017 15:54:44 -0700 Subject: [PATCH] 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 --- src/common/hist_util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/hist_util.cc b/src/common/hist_util.cc index 58ea57f6e..9c8228ab9 100644 --- a/src/common/hist_util.cc +++ b/src/common/hist_util.cc @@ -188,7 +188,7 @@ void GHistBuilder::BuildHist(const std::vector& 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_;