From version 10, most optimization, sensitivity and Sensitivity2All runs are executed in parallel on multiple threads.
Parallel simulation is currently only available on Windows, but is in development for the Mac.
Feedback
We are extremely interested in your usage experience and requests for this new feature. Please email us, or visit us in the forum!
Usage
Normally, use of multithreading is automatic, though you may wish to experiment a little for maximum performance.
Sensitivity
Sensitivity2All and normal sensitivity runs execute in parallel, with a speedup that is nearly linear in the number of cores/threads used.
MCMC
Markov Chain Monte Carlo runs are also fully parallel, except for the chain initialization phase, and modestly higher overhead between generations.
Optimization
Hill-climbing optimization is more difficult to parallelize than most methods. For this reason we have preserved the existing MULTIPLE START = { OFF | RANDOM | RRANDOM } methods and added XPARALLEL and RPARALLEL options, which you must choose explicitly. We expect that they will quickly become the preferred choices.
The behavior currently implemented varies, depending on the particular options chosen:
•Powell optimizations with multiple-start = XParallel are similar to multiple-start = off, but with search directions delegated to multiple threads.
oEach thread begins at a different point in the direction set. The initial direction set is the same as the parameter list, so in effect the threads divide-and-conquer the parameters.
oIntermittently, each thread will construct a new direction oriented toward other threads' best points. This is much like direction updates in Differential Evolution. This also introduces some randomness, both explicitly (from random number generation) and from nondeterministic CPU timing.
oThe direction crossovers ensure that threads converge toward a common optimum, though a rough, multimodal payoff surface may confound this.
oPerformance depends on the degree of interaction of the parameters. In the best case, if parameter contributions are additive (like payoff = a + b + c), independent direction searches can be integrated and speedup is linear in cores. In the worst case, nonlinear interactions mean that progress in one direction spoils progress in another, so the speedup is small.
•Powell optimizations with multiple-start = RParallel are like Random and RRandom, but with independent searches delegated to each thread. Speedup is linear in the number of cores.
•Stochastic optimizations normally delegate their component sensitivity runs to multiple threads, unless the number of sensitivity runs is smaller than the number of threads.
•The optimizer sensitivity options (vector and grid searches) are not yet multithreaded.
Thread Control
You can control thread use by defining a special variable called MAX_THREADS in your model:
•If undefined, Vensim will automatically detect the number of logical processors on your system, and use all but 2 of those, up to a limit of 62. Normally this automatic value is sufficient.
•You can set MAX_THREADS to 0 to turn multithreading off.
•You can set it to a positive integer to use a specified number of threads, up to the limit. This may be useful if you want to reserve more threads for other processes, or if memory is constrained for a very large model.
On most CPUs, the number of logical processors is twice the number of physical cores, due to the use of simultaneous multithreading SMT), a.k.a. hyperthreading. On HPC computers or servers with high core counts, it may be advantageous to turn SMT/hyperthreads off in the system BIOS. This provides more cache per core and less communication overhead, particularly for parallel optimization.
Note that the very largest workstations and servers may exceed the usable thread limit at present. We are working to improve on this. Contact us for development status.
Compiling and External Functions
Compiled simulations are thread safe. Note that the compiled simulation support files changed at Version 9.4, so you may need to rerun the installer to update the resources.
External functions are available in parallel simulations, but you may need to verify that your functions are written in a thread safe way. Alternatively, you can set MAX THREADS=0 to suppress multithreading.