Work around a compiler bug in MacOS AppleClang 11 (#6103)
* Workaround a compiler bug in MacOS AppleClang * [CI] Run C++ test with MacOS Catalina + AppleClang 11.0.3 * [CI] Migrate cmake_test on MacOS from Travis CI to GitHub Actions * Install OpenMP runtime * [CI] Use CMake to locate lz4 lib
This commit is contained in:
committed by
GitHub
parent
9338582d79
commit
d0ccb13d09
@@ -109,7 +109,7 @@ class BlockedSpace2d {
|
||||
|
||||
|
||||
// Wrapper to implement nested parallelism with simple omp parallel for
|
||||
template<typename Func>
|
||||
template <typename Func>
|
||||
void ParallelFor2d(const BlockedSpace2d& space, int nthreads, Func func) {
|
||||
const size_t num_blocks_in_space = space.Size();
|
||||
nthreads = std::min(nthreads, omp_get_max_threads());
|
||||
@@ -118,7 +118,8 @@ void ParallelFor2d(const BlockedSpace2d& space, int nthreads, Func func) {
|
||||
dmlc::OMPException omp_exc;
|
||||
#pragma omp parallel num_threads(nthreads)
|
||||
{
|
||||
omp_exc.Run([&]() {
|
||||
omp_exc.Run(
|
||||
[](size_t num_blocks_in_space, const BlockedSpace2d& space, int nthreads, Func func) {
|
||||
size_t tid = omp_get_thread_num();
|
||||
size_t chunck_size =
|
||||
num_blocks_in_space / nthreads + !!(num_blocks_in_space % nthreads);
|
||||
@@ -128,7 +129,7 @@ void ParallelFor2d(const BlockedSpace2d& space, int nthreads, Func func) {
|
||||
for (auto i = begin; i < end; i++) {
|
||||
func(space.GetFirstDimension(i), space.GetRange(i));
|
||||
}
|
||||
});
|
||||
}, num_blocks_in_space, space, nthreads, func);
|
||||
}
|
||||
omp_exc.Rethrow();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user