Julia 中嵌套循环的并行处理

Sou*_*ral 3 julia

我正在尝试为嵌套循环实现并行处理。但是我收到以下语法错误。

我正在修改这里的示例(Julia 中的并行计算 - 在多个内核上运行简单的 for 循环

这有效

for N in 1:5:20, H in 1:5:20
           println("The N of this iteration in $N, $H")
end
Run Code Online (Sandbox Code Playgroud)

这是给语法错误

using Distributed

@distributed for N in 1:5:20, H in 1:5:20
           println("The N of this iteration in $N, $H")
       end

Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Prz*_*fel 5

@distributed宏仅支持迭代一个参数。因此你可以这样做:

@distributed for (N,H) in collect(Iterators.product(1:5:20,1:5:20))
    println("The N of this iteration in $N, $H")
end
Run Code Online (Sandbox Code Playgroud)

另一种选择当然是使用嵌套循环。在这种情况下,只有一个循环应该是@distributed.