From 5256b3f5e1e10a14ba16a56ccaa343b2e8a7e69f Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 11 Oct 2023 11:24:42 +0200 Subject: [PATCH] Add note on thread-safety to README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 90da3fe..03d2ea8 100644 --- a/README.md +++ b/README.md @@ -90,3 +90,20 @@ for a full list of the available options. The C API can be accessed via `HiGHS.Highs_xxx` functions, where the names and arguments are identical to the C API. + +## Threads + +HiGHS uses a global scheduler that is shared between threads. + +Before changing the number of theads using `MOI.Threads()`, you must call +`Highs_resetGlobalScheduler(1)`: +```julia +using JuMP, HiGHS +model = Model(HiGHS.Optimizer) +Highs_resetGlobalScheduler(1) +set_attribute(model, MOI.NumberOfThreads(), 1) +``` + +If modifying the number of HiGHS threads across different Julia threads, be sure +to read the docstring of `Highs_resetGlobalScheduler`. In particular, resetting +the scheduler is not thread-safe.