From a17bcfdced14f36acfec9eaf141120bd5413f7c0 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 30 Oct 2023 09:10:02 +1300 Subject: [PATCH] Add note on thread-safety to README (#182) --- 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.