Search code examples
matlabparallel-processingparfor

Paralell computing opening and closing with calling parfor in MATLAB R2014a


I have a program that call a m-file that contains parfor for calculation. You know that in MATLAB R2014a we don't need open parallel computing using parpool or something likes that and parfor doing the same.

My question is about closing parallel computing. If i have this structure ( only parfor ) MATLAB closing parallel computing after ending process of parfor? I'm calling this parfor every 10 seconds. I don't want MATLAB close the pool in every iteration of my system.

Thanks.


Solution

  • From the documentation of parpool:

    If you set your parallel preferences to automatically create a parallel pool when necessary, you do not need to explicitly call the parpool command. You might explicitly create a pool to control when you incur the overhead time of setting it up, so the pool is ready for subsequent parallel language constructs.

    It is true that we don't have to use parpool, but it makes sense to use it if you want to control the overhead it causes.

    As for your question - take a look at the Parallel Computing Toolbox Preferences:

    How to make sure that the pool doesn't shut itself down spontaneously.

    I believe that the highlighted option is what was bothering you. If the default timeout is too short, you could either postpone it or disable it altogether.