-
Notifications
You must be signed in to change notification settings - Fork 16
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
Julia threads and HiGHS threads
interaction
#181
Comments
See #130 (comment) |
are there any changes we ought to suggest to the HiGHS devs directly? |
They're aware of the issue. I don't know if there is the desire or engineering time to change it. |
@odow Sorry for taking such a long time to answer. I was a little swamped with work! |
Yes, set the option 'threads' to 1. There should be little noticeable performance degradation as parallelism is only used in symmetry detection in the MIP solver. If this is done before a call to 'Highs::run()' then the scheduler is initialised to use one thread. The default value for 'threads' of 0 results in half the possible machine threads being initialised for use by HiGHS |
Hmm that's what @bachdavi had tried to do. I'll take a look at this next week. |
@odow and @jajhall To clarify, I can set the number of threads to I'm running the following in an
I'm wondering if that is intended or expected :) |
@bachdavi what about something like this: function __init__()
_set_all_highs_threads_to_serial()
return
end
function _set_all_highs_threads_to_serial()
HiGHS.Highs_resetGlobalScheduler(1)
Threads.@threads :static for _ in 1:Threads.threadpoolsize()
_set_thread_local_highs_threads_to_serial()
end
return
end
"""
_set_thread_local_highs_threads_to_serial()
Set the number of threads used by HiGHS to `1`. This applies to the current
_Julia_ thread only!
HiGHS will by default initialize its task executor with half the available
threads on a machine, but won't use them to solve LPs:
https://ergo-code.github.io/HiGHS/dev/parallel/.
Set the number of threads to 1 to avoid it. This is a _Julia_ thread-local
setting and can only be changed after calling `Highs_resetGlobalScheduler`.
"""
function _set_thread_local_highs_threads_to_serial()
highs = HiGHS.Highs_create()
HiGHS.Highs_setIntOptionValue(highs, "threads", 1)
HiGHS.Highs_destroy(highs)
return
end |
@odow I tried your suggestion, but I think the In any case, I think #182 is a good addition to the README. I'll close this issue, thank you :) |
Hello again :)
I have a question about the interaction between Julia threads and the HiGHS
threads
option. It appears that HiGHS initializes itself for each Julia thread where I'm optimizing a model. Is that intended behavior?Some background:
Via
gdb
we have recently observed a large number of logical threads associated with HiGHS (HighsTaskExecutor::HighsTaskExecutor
). We are solving a linear program that via the documentation does not use any parallelism. By default, HiGHS will initialize its scheduler with half the machine threads, which we want to avoid.HiGHS supports the
threads
option, which we can set viaMOI.RawOptimizerAttribute("threads")
orMOI.NumberOfThreads()
. The documentation mentioned that this is a global setting and can only be changed after callingresetGlobalScheduler
.I can set the number of threads to
1
and can observe the expected increase of threads in the process. Here is a simple example:If I change
1
to2
, HiGHS mentions the need to reset the global scheduler.But if I run the above snippet, with the changed threads count, in another Julia thread, via
Threads.@spawn
HiGHS sets the number of threads, apparently initializing a new scheduler. I can also observe an increase in the thread count of the Julia process.Thank you very much for helping us out!
The text was updated successfully, but these errors were encountered: