How workers share cores and use threads?
45 views (last 30 days)
Show older comments
Hi, I am using the PCT to run a parfor loop in a "aggregated" memory/cpus machine with 92 cores. I would like to know how the workers in a distributed job, such us parfor, would share these cores. I know that the short answers is "the cpu will be smart and share then in some way," but I would like to know more details. Specially, I am trying to understand how a workers process is set up when it is launched from the Matlab client, and how many threads each workers is set up to use by ''default". Also, I would like to know if it is possible to modify the way workers are launched so that I could define how many threads each worker should use and possibly the set the threads-to-cores affinity.
0 Comments
Answers (3)
Titus Edelhofer
on 13 May 2011
Hi,
per default each worker is started in single thread mode: this is motivated by a rule of thumb, namely, "start one worker per core". Let's say you have a machine with four quad-cores, then starting 16 single threaded workers probably be the best option. Next best I guess would be 8 workers with 2 threads each. Until now you could possibly use maxNumCompThreads on each worker to achieve this, but it is discouraged, because in larger installations multithreaded applications (using more cores then "allowed" by cluster controller) are prohibited anyway.
To make the long answer short: use as many workers as cores (as long as not restricted by number of worker licenses). The distribution of "which worker uses which core" is totally up to the operating system and out of MATLABs control.
Hope this helps,
Titus
0 Comments
Titus Edelhofer
on 13 May 2011
Hi Camilo,
maxNumCompThreads is a function. If you want to give it a try: when you have you matlabpool open, do
pctRunOnAll maxNumCompThreads(4)
to tell all workers (and your Client by the way) to use 4 threads. But keep in mind, this will go away (on purpose). I would be interested to see a result from you like 16 workers singlethreaded = TimeX, 4 workers 4-threaded (what an english) = TimeY.
Titus
0 Comments
See Also
Categories
Find more on MATLAB Parallel Server in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!