Implement thread management for parallel simulations #206
arnaudgabas
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
|
looks nice. My remarks:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I have to share with you a feature that I think would be very beneficial in the way parallel simulations are handled with spicelib.
Context
Most SPICE simulators provide a feature that allows the user to specify the maximum number of threads allowed for the simulation. LTspice has this feature, but only in the GUI, in the SPICE "Engine" parameters:
Two problems rises from that:
.optiondirective, or with a command line switch ;This means that even if you run a single simulation with the library, you can't really limit the number of threads/resources used by the LTspice process.
Why is it bad?
If the user wants to use the parallel simulation feature (SimRunner.run(parallel_sims=8) for example), each LTspice process created will try to use as many threads as possible, resulting in slower speed. As a result, the parallel simulation feature cannot really be fully exploited.
My suggestion
My suggestion would be to change the way LTspice processes are created in the
simulator.py run_function()function. Instead of launching the LTspice batch command withsubprocess.run(), each process invocation would be allocated a certain number of threads, and release them when the simulation is complete. This can be done withpsutiland some thread allocate/release functions withthreading. The function can still return a "retcode" with this method. I've made a first prototype of that, which seems to work correctly:This method applies no thread restrictions to the main script.
Also, with this prototype, if there are no more threads available to run a simulation, the LTspice process will run without any thread restriction. This implies that the thread management (and therefore the number of parallel simulations) should be more restricted so that each process (or simulation, whatever you want to call it) runs with a specific number of allocated threads.
Of course, this
run_functionprototype generates exceptions which are handled in theRunTask.runfunction.What do you think of that?
Beta Was this translation helpful? Give feedback.
All reactions