How to run MATLAB (or execute some algorithm) on specific number of cores on a computer?

1 次查看(过去 30 天)
Hello,
I am trying to study the performance (in terms of execution time) of my some algorithm by varying the number of cores to be used on my machine. Any pointers, how to do it?
Thanks in advance.
PS: (I have a 16 core machine in the dept (OS:Red Hat, MATLAB 2011 a))

回答(2 个)

Walter Roberson
Walter Roberson 2013-1-24
Make sure that hardware hyperthreading is off. Then use matlabpool() with the number of cores you want.
Watch out for a core being used by the operating system for whatever (e.g., virus checking).
  1 个评论
Matt J
Matt J 2013-1-24
matlabpool sets the number of workers. I'm not sure that guarantees that each worker will be assigned a single core. On a 16-core machine, I suspect that a pool of 4 workers would get 4 cores each, for example.

请先登录,再进行评论。


Jason Ross
Jason Ross 2013-1-24
编辑:Jason Ross 2013-1-24
A matlabpool will give you a number of worker processes, with a single computational thread each. The actual placement of workers is left up to the operating system, so there's not a guarantee which core will recieve which process.
It would be much easier to vary the number of MATLAB workers in your matlabpool and chart execution time as the number changes if you are using an algorithm that can be parallelized. For an example, see Benchmarking A\b
If you aren't using something that can be parallelized, you might want to try varying the maxNumCompThreads setting.
As with any benchmarking or performance analysis, take care to minimize variables that can cause variation. In general, I find it most useful to have all of the resources local to the machine under test as possible. This eliminates networking latency, which depending on the speed of your network and storage infrastucture, can introduce enormous variations into your results. It's also worth taking the time to repeat runs, as well -- and have run times that are long enough to be meaningful.
In addition to CPU performance, you also likely want to keep an eye on memory utilization, network utilization, and disk performance to fully understand why your algorithm may perform differently under different circumstances.
There is also an interesting paper on the File Exchange on this topic: http://www.mathworks.com/matlabcentral/fileexchange/18510-matlab-performance-measurement

类别

Help CenterFile Exchange 中查找有关 Speed Up Statistical Computations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by