ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

Documentation how to run simulations in parallel missing

Open ufechner7 opened this issue 2 years ago • 3 comments

Running simulations in parallel can save a lot of time if you need to run the same model with different parameters. This sometimes works well, and sometimes not at all. It is not documented under which conditions it works well.

ufechner7 avatar Nov 12 '23 03:11 ufechner7

Can you give more information on what's missing from https://docs.sciml.ai/DiffEqDocs/stable/features/ensemble/ ?

ChrisRackauckas avatar Nov 12 '23 05:11 ChrisRackauckas

I did not know about "ensemble", and I do not know yet if it would be useful for my purpose or just make things more complicated. I would write something like this:

Speeding up simulations by multithreading is effective under a number of conditions:

  • all simulations are using the same model, only different parameters
  • a steady state solver is used to find the initial conditions
  • the MKL linear algebra library is used
  • the limiting factor is the garbage collection, therefore it is important to enable parallel garbage collection when starting Julia, e.g. using the parameter
    -t 8 --gcthreads=4,1 for 8 threads and 4+1 garbage collector threads.
    As a rule of thumb, use the number of real cores for the number of threads and half of it for the gc threads.

Small reminder: My simulations are 1000 times faster than Simulink when running single threaded and at least 5000 times faster than Simulink when using multi-threading...

Currently, that is more than good enough for my research, even without using the ensemble feature...

ufechner7 avatar Nov 12 '23 18:11 ufechner7

I need to think about the right way to document this. Indeed ModelingToolkit's documentation is doing two things: it's a modeling compiler, and it's a front end for many industrial modelers. If you look at for example Catalyst.jl, https://docs.sciml.ai/Catalyst/stable/, its documentation has all sorts of "not actually Catalyst.jl stuff" like inverse problems which is really just showing the user how to use Catalyst.jl and ModelingToolkit.jl effectively in the domain of computational biology. The ModelingToolkit.jl documentation as a documentation for the MTK system and compiler focuses largely on the core MTK, how to build models and run its transformations. However, there is definitely space for it to grow into including things like how to use MTK effectively in industrial scale modeling and simulation, including things that are in other docs like DifferentialEquations.jl to really narrow down on what's required in this domain. But with MTK's docs focusing on MTK proper, there is a bit of tension on how to fit it all in here.

ChrisRackauckas avatar Nov 14 '23 07:11 ChrisRackauckas