本文介绍了如何在Matlab中将Core i3与PARFOR并行运行4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有适用于Ubuntu 64位的Matlab R2012b.我有一个Intel Core i3 CPU M 330 @ 2.13GHz×4.

I have Matlab R2012b for Ubuntu 64 bits. I have a Intel Core i3 CPU M 330 @ 2.13GHz × 4.

我想使用 parfor 同时并行化4个循环.因为Intel Core i3具有2个内核和4个线程,所以我使用以下代码:

I want to use parfor to parallelize 4 loops at same time. Because Intel Core i3 has 2 Cores and 4 Threads I use this code:

if matlabpool('size') == 0 % checking to see if my pool is already open
    matlabpool(4)
else
    matlabpool close
    matlabpool(4)
end

并且我收到以下错误:

错误:

为什么?我的计算机中NumWorkers的默认值为2,但是如果我可以同时执行4个循环,该如何获取呢?

Why? The default value of NumWorkers in my machine is 2 but if I can do 4 loops at the same time, how do I get it?

推荐答案

要增加默认值NumWorkers,请打开群集配置文件管理器"(并行"->管理群集配置文件").选择local配置文件,单击编辑",然后将NumWorkers增大到最大可能值(在您的情况下为4).现在,可以创建一个matlabpool,其工人数多于计算机上的物理核心.

To increase the default NumWorkers, open the Cluster Profile Manager (Parallel->Manage Cluster Profiles). Pick the localprofile, click edit, and increase NumWorkers to the maximum possible value (in your case 4). Now it is possible to create a matlabpool with more workers than physical cores on your machine.

但是,请注意,与具有与核心相同数量的工人相比,使用多于核心的工人可能会导致性能下降.

However, note that using more workers than cores might lead to decreased performance as compared to having the same number of workers as cores.

这篇关于如何在Matlab中将Core i3与PARFOR并行运行4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 18:33