Is KNITRO.jl thread-safe

Hi everyone,

is it save to launch multiple instances of Knitro with JuMP at the same time?

I aim to solve a couple of problems at the same time for different parameter combinations on multiple Julia threads. I would define a new JuMP model on each thread and solve it with Knitro simultaneously. Do you see any issues with that?

Thanks!

1 Like

I don’t know that I’ve tested it, but I’m not aware of any reason why KNITRO.jl would not be thread-safe.

Did you try? Did it work?

1 Like

OK, thanks for the fast reply. I just read that there are issues with multithreading when Julia calls C libraries - Knitro.jl also disables all multithreading on Knitro’s C-side - and wanted to make sure I am not missing something obvious.

I am setting it up right now and will let you know if I encountered any issues.

1 Like

Update: My quick implementation seems to work fine. This is by no means a proof that there will never be any issues but my simple implementations with and without multi-threading produce exactly the same results.

High-level summary of what I did:

  • Solve a problem whose solution for the unknowns depends on parameters b which are kept fixed while solving the model.
  • Loop over a set of values for b.
  • In each loop:
    • Set up JuMP model given values for b
    • Optimize JuMP model with Knitro
    • Record results
  • Results seem to be exactly identical.
1 Like