Hi guys,
I've been playing around with LTSpice and trying to speed it up and I thought I'd show you the results.
The tests were done on a reasonably hefty machine (i7-8700, running at ~4.3GHz (dynamic clock change, but this is the max. frequency), 16 GB of RAM, SSD disk), running Windows 10 with all of the latest updates. Nothing of note aside from LTSpice was running during the test. LTSpice version XVII(x64), Dec 5 2019. I was running the simulation attached. The simulation itself is a small-ish sized simulation of a DC DC converter, pretty much the test jig for the device, only with saturable inductors (I'm not sure I've done them properly) and a second filter - basically I was just messing around. The circuit itself is not very interesting and was just used for testing the simulation. Simulation file:
LTSpiceTest.asc (4.9 kB - downloaded 105 times.)
The total duration of the simulation was taken from the generated .log file, line: Total elapsed time: xx.xxx seconds. The CPU load was eyeballed from Windows Task Manager. The base load was around 1-2%. There is some repeatability there, but it's not exactly 100%. Trying one simulation 3 times yielded 43 to 45 seconds simulation time with the same settings. Not sure why.
I've tried setting different amounts of Max threads in the Settings->SPICE->Max threads for the SPICE system.
Results:The fastest simulation is with 4 or 5 threads. The CPU I use has 6 cores, both supporting 2 threads, but this is not the same as having 12 cores. At 6 threads the speed drops off and afterwards it slows down further. Interestingly enough, at 12 threads, the simulation speed is comparable to the speed we get by using just
1 thread. I also tried the Alternate solver, but it's around 2x slower than the normal one.
My guess is that at some point the overhead overtakes the benefits of having more threads available. Due to the fact that there are only 6 real cores on the chip, adding more threads does not add FLOPS or anything similar. I noticed this with OpenEMS as well - when dealing with serious number crunching, the extra 'thread' on the CPU is useless, or worse it adds to the overhead without actually contributing anything good.
Simulation duration:
CPU load:
I have also tried other options when running @5 threads.
Tweak Sim duration
Reference value 45
Thread priority: High 44.039Disable 1st order compression 43.399Matrix compiler: Pseudocode 45.306
Matrix compiler: (off) 46.865
Disable 2nd order compression 44.708
ASCII files 118.79
The only tweaks/settings that improve simulation speed are setting a high thread priority and disabling compression. Anything else worsens the result.
Conclusion: Don't assume that more threads will get you the best results. Experiment a lot. I'm going to be doing lots of simulations now, as such I have reason to try to tweak it as much as possible. Please take all of this with a grain of salt.
Best regards,
David
Raw data:
Normal solver:
Threads Sim duration CPU load
1 54.632 13
2 49.359 25
3 45.628 36
4 44.055 46
5 43.911 58
6 45.898 70
7 49.625 80
8 54.504 92
9 54.195 93
10 55.585 93
11 52.423 92
12 52.626 91
Alt solver:
Threads Sim duration CPU load
1 97.08 14
2 81.327 25
3 73.169 35
4 73.022 46
5 68.785 58
6 72.091 69
7 77.426 80
8 89.132 91
9 85.823 91
10 80.848 91
11 81.095 91
12 84.796 92