Julia:Parallel For循环,具有大数据移动

bde*_*vic 5 parallel-processing dictionary for-loop julia

我想运行并行for循环.我需要我的每一个过程,以有机会获得2个大词典,gene_dicttranscript_dict.这是我先试过的

@everywhere( function EM ... end )

generefs  = [ @spawnat i genes for i in 2:nprocs()]
dict1refs = [ @spawnat i gene_dict for i in 2:nprocs()]
dict2refs = [ @spawnat i transcript_dict for i in 2:nprocs()]

result = @parallel (vcat) for i in 1:length(genes)
  EM(genes[i], gene_dict, transcript_dict)
end
Run Code Online (Sandbox Code Playgroud)

但我在所有进程(不仅仅是5)上得到以下错误:

exception on 5: ERROR: genes not defined
 in anonymous at no file:1514
 in anonymous at multi.jl:1364
 in anonymous at multi.jl:820
 in run_work_thunk at multi.jl:593
 in run_work_thunk at multi.jl:602
 in anonymous at task.jl:6
UndefVarError(:genes)
Run Code Online (Sandbox Code Playgroud)

我想@spawnat会将我需要的三个数据结构移动到所有进程中.我的第一个想法是,这个移动需要一段时间,并行for循环尝试在数据传输完成之前运行.

And*_*ack 7

数据移动@spawnat但不绑定到与主节点上的名称同名的变量.而是将数据保存在工人的相当隐藏的Dict命名中Base.PGRP.要访问这些值,您必须使用在您的情况下类似fetchRemoteRefs

result = @parallel (vcat) for i in 1:length(genes) EM(fetch(genes[i]), fetch(gene_dict[i]), fetch(transcript_dict[i])) end