How to run MATLAB (or execute some algorithm) on specific number of cores on a computer?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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))
0 comentarios
Respuestas (2)
Walter Roberson
el 24 de En. de 2013
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 comentario
Matt J
el 24 de En. de 2013
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
el 24 de En. de 2013
Editada: Jason Ross
el 24 de En. de 2013
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
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Parallel Server en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!