Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle OMP_THREAD_LIMIT in environment. #7390

Merged
merged 9 commits into from Nov 3, 2021

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Nov 2, 2021

Fixes R win builder.

cc @hetong007

Details, OMP_THREAD_LIMIT is an environment variable defined by OpenMP standard. Users can set it to limit the number of threads in each thread group. However, the omp_get_max_threads() function used by XGBoost is not affected by this env var. So when the env var is set, XGBoost naively thought it can obtain omp_get_max_threads() number of threads, while the received number of threads is much smaller.

I ran it on win builder for a quick test https://win-builder.r-project.org/vCrjkrlXZE0l/00check.log we should run it again after backporting to 1.5 branch.

@trivialfis trivialfis mentioned this pull request Nov 2, 2021
8 tasks
@trivialfis
Copy link
Member Author

Also, the cause of #7156 is now known. This would be proper fix.

@trivialfis
Copy link
Member Author

cc @hcho3 I feel like I just did the impossible. Please review. ;-)

@hcho3
Copy link
Collaborator

hcho3 commented Nov 2, 2021

Nicely done!

@trivialfis
Copy link
Member Author

trivialfis commented Nov 2, 2021

Hmm, msvc doesn't implement this environment variable.

https://docs.microsoft.com/en-us/cpp/parallel/openmp/reference/openmp-environment-variables?view=msvc-160

@trivialfis trivialfis merged commit 57a4b4f into dmlc:master Nov 3, 2021
@trivialfis trivialfis deleted the fix-omp-thread-limit branch November 3, 2021 07:44
trivialfis added a commit to trivialfis/xgboost that referenced this pull request Nov 3, 2021
trivialfis added a commit to trivialfis/xgboost that referenced this pull request Nov 3, 2021
trivialfis added a commit that referenced this pull request Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants