User Tools

Site Tools


parfor_tricks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
parfor_tricks [2012/12/07 16:04]
fowlkes
parfor_tricks [2013/10/12 14:35] (current)
bhkong
Line 1: Line 1:
- 
- 
- 
 MATLAB creates a local process pool with some default name.  If you fire up a second copy of MATLAB on the same machine, it will use that same default pool so the two different copies will compete/​conflict. MATLAB creates a local process pool with some default name.  If you fire up a second copy of MATLAB on the same machine, it will use that same default pool so the two different copies will compete/​conflict.
- 
  
 Here is a bit of MATLAB code that will create a pool whose info is stored in a specified directory and hence won't conflict: Here is a bit of MATLAB code that will create a pool whose info is stored in a specified directory and hence won't conflict:
-====== ​ 
-====== ​ 
-====== ​ 
-''​mkdir('/​tmp/​fowlkes.1'​);''​ 
  
-''​schd = findResource('​scheduler',​ '​configuration',​ defaultParallelConfig);''​+<​code>​ 
 +mkdir('/​tmp/​fowlkes.1'); 
 +schd = findResource('​scheduler',​ '​configuration',​ defaultParallelConfig);​ 
 +schd.DataLocation = '/​tmp/​fowlkes.1' 
 +matlabpool(schd);​ 
 +</​code>​
  
-''​schd.DataLocation = '/​tmp/​fowlkes.1'''​+It should be noted that when a process pool is started, each worker switches to single-threaded modeMeaning workers will not be able to take advantage of multithreaded computations built into many of the MATLAB functions.
  
-''​matlabpool(schd);''​ +One way to get around this, is to run the command ​''​pctRunOnAll maxNumCompThreads(#)''​. This command will be executed on all workers in the pool and specifies the max number of threads each worker is allowed to use. Using the function ''​maxNumCompThreads''​ is really just a stop gap measure as it is slated for removal in the future. A better solution might be to just create a process pool right before using parfor and then tearing it down right after finishing.
-====== +
-======  +
-====== ​+
parfor_tricks.1354925069.txt.gz · Last modified: 2012/12/07 16:04 by fowlkes