-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Reset OpenMP thread number if num_threads <= 0 #4704
Conversation
Use |
The problem of infinite waiting in Windows is caused by #include <iostream>
#include <time.h>
#include <omp.h>
int OMP_NUM_THREADS() {
int ret = 1;
#pragma omp parallel
#pragma omp master
{ ret = omp_get_num_threads(); }
return ret;
}
int default_omp_num_threads = OMP_NUM_THREADS();
Then use the following python code to load it: import ctypes
dll_file = '''<path to the dll>'''
ctypes.cdll.LoadLibrary(dll_file) Then the code will be blocked forever. I have changed the implementation to use a static variable in function to resolve the problem caused by global variable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes LGTM. Thanks!
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
#4607 (comment)