0

I run on my computer very often Matlab programs compiled using mcc, in which I execute parfor. Each program has slow startup time, I think because the parallel worker pool is created (it takes about 20 seconds just to startup the parallel pool). It would be more efficient for me if the pool could remain open all the time in the background. For example when opening a parpool in the matlab interface, it says that the parpool will remain open for 30 minutes and so there is no need to open a parpool for each matlab script. Is something like that possible also when the code is compiled, or are there other solutions?

David
  • 157
  • 1
  • 2
  • 7

1 Answers1

0

You could increase the time for which the pool is opened. During testing, you can type

>> preferences

and choosing Parallel Computing Toolbox settings on left menu . Preferences Menu

You can achieve the same result adding to the code

 p = parpool
 p.IdleTimeout = 120 %minutes

If you have the pool opened for a longer time you should be able to run multiple scripts without the need for opening and closing it multiple times.

I would avoid leaving it opened permanently.

roadRunner
  • 100
  • 1
  • 9
  • Well yes ok this works when working in Matlab. The problem occurs after compiling the code. If you compile the code and launch it on a terminal, each time you launch the code you have to open a new parpool because it won't remain opended after code execution and it takes each time at least 20 seconds in order to open the pool. Can you solve this? What I need is the parpool to remain opened also when the code is compiled using mcc. – David Feb 21 '17 at 18:25
  • What's the structure of your programme? You mentioned multiple scripts, try to open a longer lasting parpool in a separate script, call all the others while the parpool is still open. – roadRunner Feb 21 '17 at 18:28
  • It is not possible for me because I have launch each script separately. The pool has to remain opened even when a script finishes. This works in Matlab interface, but not when the code is compiled. – David Feb 22 '17 at 09:22