Matlab在函数内部嵌套parfor循环,如果外层循环小,是否会使用所有worker?

Matlab nested parfor loops inside functions, will all workers be used if the outer loop is small?

如果我对文档的理解正确,我可以在另一个 parfor 循环中有一个 parfor 循环,只要内部循环在一个单独的函数调用中,这在我的例子中是正确的。

我的问题很简单:

在某些情况下,我的外循环只使用 2 threads/workers。我的并行池中有 6 个工人。

内部 parfor 循环会利用 4 个未使用的 worker 吗?

来自 MATLAB 自己的文档 (http://www.mathworks.com/help/distcomp/nesting-and-flow-in-parfor-loops.html):

The body of a parfor-loop cannot contain another parfor-loop. But it can call a function that contains another parfor-loop.

However, because a worker cannot open a parallel pool, a worker cannot run the inner nested parfor-loop in parallel. This means that only one level of nested parfor-loops can run in parallel. If the outer loop runs in parallel on a parallel pool, the inner loop runs serially on each worker. If the outer loop runs serially in the client (e.g., parfor specifying zero workers), the function that contains the inner loop can run the inner loop in parallel on workers in a pool.

由于 worker 不能自己打开池,内部 parfor 循环将以串行方式工作。