use all cores in parfor loop

2 次查看(过去 30 天)
arnaud ensberg
arnaud ensberg 2016-1-31
please;
how can I do to use all cores in parfor loop
feature('numCores')
MATLAB detected: 2 physical cores.
MATLAB detected: 4 logical cores.
MATLAB was assigned: 4 logical cores by the OS.
MATLAB is using: 2 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
ans =
2
should i disable a hyper-threading to do this ?

回答(1 个)

Walter Roberson
Walter Roberson 2016-2-1
If you were to disable hyperthreading then your system would have 2 cores available, the two physical cores. That is the same number as MATLAB is giving you with hyperthreading turned on. There would be no advantage to turning hyperthreading off.
Your system only has two physical cores. Hyperthreading is a mechanism that allows one physical core to be used by two processes at the same time, with one of the processes automatically be allowed to run when the other process has to momentarily wait for something such as reading from disk. It is a task switching mechanism that is like normal time sharing mechanisms, except that it happens to have some hardware support so it has less overhead. But using it effectively depends on the main process not using the whole computing capacity of the core due to outside interactions. When you are running a heavy MATLAB calculation that fits entirely in memory, there is no spare computing capacity for the core, so the second process on the core would only get time by stealing it from the main process. That is not any more efficient.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by