Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[BUGFIX] Fix CI slowdown issue after removing 3rdparty/openmp #20367

Merged
merged 2 commits into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/operator/tensor/broadcast_reduce-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,17 @@ void seq_reduce_compute(const size_t N, const size_t M, const bool addto,
const Shape<ndim> sshape, const Shape<ndim> rshape,
const Shape<ndim> rstride) {
const int thread_count = engine::OpenMP::Get()->GetRecommendedOMPThreadCount();
#pragma omp parallel for num_threads(thread_count) if (N >= thread_count)
for (index_t idx = 0; idx < static_cast<index_t>(N); ++idx) {
seq_reduce_assign<Reducer, ndim, AType, DType, OType, OP, IndexOP>
(idx, M, addto, big, small, bshape, sshape, rshape, rstride, N < thread_count);
if (N >= thread_count) {
#pragma omp parallel for num_threads(thread_count)
for (index_t idx = 0; idx < static_cast<index_t>(N); ++idx) {
seq_reduce_assign<Reducer, ndim, AType, DType, OType, OP, IndexOP>
(idx, M, addto, big, small, bshape, sshape, rshape, rstride, false);
}
} else {
for (index_t idx = 0; idx < static_cast<index_t>(N); ++idx) {
seq_reduce_assign<Reducer, ndim, AType, DType, OType, OP, IndexOP>
(idx, M, addto, big, small, bshape, sshape, rshape, rstride, true);
}
}
}

Expand Down