matlab - Matlab的parfor中的worker数量

标签 matlab parallel-processing parfor

我正在使用 MATLAB 的 parfor 函数运行 for 循环。我的 CPU 规范是

enter image description here

我将首选工作线程数设置为 24。但是,MATLAB 将此数字设置为 6。工作线程数是受核心数量还是受(核心数量)x(处理器数量=6x12)限制?

最佳答案

Matlab 更愿意将工作线程数量限制为核心数量(在您的情况下为 6 个)。 您的 CPU ( intel i7-9750H ) 具有超线程,即每个核心可以运行多个(此处为 2 个)线程。但是,如果您想在满负载下运行它们,这没有任何用处,这意味着根本没有可用的资源来切换到不同的任务(附加线程实际上是什么)。

请参阅documentation .

Restricting to one worker per physical core ensures that each worker has exclusive access to a floating point unit, which generally optimizes performance of computational code. If your code is not computationally intensive, for example, it is input/output (I/O) intensive, then consider using up to two workers per physical core. Running too many workers on too few resources may impact performance and stability of your machine.

请注意,Matlab 需要将数据流式传输到每个内核才能运行分布式代码。这是某种初始化工作,也是为什么如果将核心/工作线程数量增加一倍,则无法将运行时间减少一半的原因。这也是为什么 Matlab 没有使用超线程的原因。这只是意味着在没有任何加速的情况下增加初始流工作 - 事实上,核心可能会迫使 matlab 保存中间结果并不时切换到其他任务......这与以前的任务相同;)

关于matlab - Matlab的parfor中的worker数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59156515/

相关文章:

matlab - Parfor切片变量导致Matlab崩溃

scala - 如何控制scala并行集合的并发度

matlab - 在 Matlab 中使用命令行验证集群配置文件

matlab - 在字符串周围添加方括号

perl - 在 Matlab 中实时显示 Perl 脚本的输出

matlab - 如何用零随机替换非零元素?

matlab - 使用 Parallel Computing Toolbox 窃取工作

c++ - OpenMP 并行峰值

MATLAB 帕福尔 : memory management: shared memory or not?

matlab - 神经网络训练matlab parfor问题