Julia:如何分析并行代码 [英] Julia: How to profile parallel code
本文介绍了Julia:如何分析并行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Julia 中分析并行代码的合适方法是什么?当我跑步时
Whats an appropriate way to profile parallel code in julia? When I run
@profile foo(...)
foo 是我的函数,我得到了
where foo is my function, I get
julia> Profile.print()
1234 task.jl; anonymous; line: 23
4 multi.jl; remotecall_fetch; line: 695
2 multi.jl; send_msg_; line: 172
2 serialize.jl; serialize; line: 74
2 serialize.jl; serialize; line: 299
2 serialize.jl; serialize; line: 130
2 serialize.jl; serialize; line: 299
1 dict.jl; serialize; line: 369
1 serialize.jl; serialize_type; line: 278
1 serialize.jl; serialize; line: 199
1 serialize.jl; serialize; line: 227
1 serialize.jl; serialize; line: 160
1 serialize.jl; serialize; line: 160
1 serialize.jl; serialize; line: 299
1 serialize.jl; serialize; line: 294
1 io.jl; write; line: 47
1 ./iobuffer.jl; write; line: 234
1 ./iobuffer.jl; ensureroom; line: 151
1 ./array.jl; resize!; line: 503
2 multi.jl; send_msg_; line: 178
2 stream.jl; write; line: 724
1230 multi.jl; remotecall_fetch; line: 696
1230 ./multi.jl; wait_full; line: 595
1230 ./task.jl; wait; line: 189
1229 ./task.jl; wait; line: 269
1229 ./stream.jl; process_events; line: 529
1 ./task.jl; wait; line: 282
1 ./stream.jl; process_events; line: 529
402 task.jl; anonymous; line: 95
402 REPL.jl; eval_user_input; line: 53
401 profile.jl; anonymous; line: 14
401 ...mba/src/model/mcmc.jl; mcmc; line: 314
401 ./task.jl; sync_end; line: 306
401 task.jl; wait; line: 48
401 ./task.jl; wait; line: 189
401 ./task.jl; wait; line: 269
401 ./stream.jl; process_events; line: 529
1 profile.jl; anonymous; line: 16
217 task.jl; task_done_hook; line: 83
217 ./task.jl; wait; line: 269
217 ./stream.jl; process_events; line: 529
推荐答案
不知道是否可行,但您可能需要考虑让工作人员调用如下所示的函数:
Don't know if it will work, but you might want to consider having the workers call a function that looks something like this:
function profile_function(func, args...)
Profile.clear()
ret = @profile apply(func, args)
pdata = Profile.retrieve()
ret, pdata
end
pdata
应该包含来自该工作人员的分析数据.您应该可以在 ProfileView 中查看它.
pdata
should contain the profiling data from that worker. You should be able to view it in ProfileView.
这篇关于Julia:如何分析并行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文