【发布时间】:2017-01-05 20:16:08
【问题描述】:
据我所知,Matlab 中的并行编程,我们可以准确地指定什么 worker 做什么;使用:
if labindex == x
%some computations
end
我们还可以并行运行for 循环;使用:
parfor i1 = x:y
%some computations
end
我正在使用一个有几个节点的集群,每个节点有 8 个核心。
我想运行 2 个函数,每个函数都包含一个 parfor 循环,每个函数都由工作人员执行,我的代码是这样的:
spmd
if labindex == 1
alpha = forward( some parameters );
end
if labindex == 2
beta = backward( some parameters );
end
end
我希望这 2 个函数由 2 个不同的节点同时执行。
但 Matlab 会抛出此错误:
PARFOR or SPMD can not be used inside an SPMD block.
为什么会这样? 有什么想法吗?
【问题讨论】:
-
在 Matlab 文档中添加了相关指针。您的代码似乎不应该抛出错误(至少不是根据最新的 Matlab 文档),因此如果您想在这里获得进一步的帮助,您应该提供 MCVE。
标签: matlab parallel-processing parfor spmd