gpt4 book ai didi

parallel-processing - Julia:如何剖析并行代码

转载 作者:行者123 更新时间:2023-12-04 18:06:52 25 4
gpt4 key购买 nike

在 julia 中分析并行代码的合适方法是什么?当我运行时

@profile foo(...) 

foo 是我的函数,我得到

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

最佳答案

不知道它是否可行,但您可能想考虑让工作人员调用一个看起来像这样的函数:

function profile_function(func, args...)
Profile.clear()
ret = @profile apply(func, args)
pdata = Profile.retrieve()
ret, pdata
end

pdata 应包含来自该工作人员的分析数据。您应该能够在 ProfileView 中查看它。

关于parallel-processing - Julia:如何剖析并行代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24411199/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com