MATLAB: Parfor Vs muliple matlab session

parallel computingparfor

I need to run my code multiple times with different parameters. What I've done so far is to open several matlab windows (until my CPU was full) and on each one I run the code with different parameters. I'm wondering if this is a good solution or whether parfor mey do a better job, especially with regard to the time consuming.
Each execution can take several hours and even one or two days.

Best Answer

parfor ought to be considerably more convenient than manually opening multiple MATLAB windows and ensuring they're all working on different things. It might also turn out to complete sooner, as the parfor infrastructure attempts to load-balance across the workers.
One additional thing to be aware of: if you run multiple desktop MATLAB instances, by default each will run in multi-threaded mode, whereas the default for Parallel Computing Toolbox workers is to use only a single computational thread. Whether or not this has any influence on your program is highly dependent on how well MATLAB can intrinsically multi-thread it. (However, if you're seeing speed-up by running multiple desktop MATLAB instance, that pretty much implies that implicit multi-threading is of limited benefit to your program).
If you want to work out whether MATLAB's implicit multi-threading is giving your program any performance benefits, you can try disabling it (temporarily) by running