Skip to content

Commit

Permalink
Remove weird set thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Nov 8, 2021
1 parent a9f36fd commit 58f62e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/common/threading_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ class BlockedSpace2d {
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());
nthreads = std::max(nthreads, 1);
CHECK_GE(nthreads, 1);

dmlc::OMPException exc;
#pragma omp parallel num_threads(nthreads)
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/tree/test_approx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ TEST(Approx, PredictionCache) {
auto Xy = RandomDataGenerator{n_samples, n_features, 0}.GenerateDMatrix(true);

{
omp_set_num_threads(1);
GenericParameter ctx;
ctx.InitAllowUnknown(Args{});
ctx.InitAllowUnknown(Args{{"nthread", "8"}});
std::unique_ptr<TreeUpdater> approx{
TreeUpdater::Create("grow_global_approx_histmaker", &ctx, ObjInfo{ObjInfo::kRegression})};
RegTree tree;
Expand Down

0 comments on commit 58f62e8

Please sign in to comment.