How can I degug inside a parfor loop?
36 次查看(过去 30 天)
显示 更早的评论
When I insert breakpoints inside a parfor loop it is never stopped. In this case how can I debug inside a parfor loop?
2 个评论
KALYAN ACHARJYA
2017-10-26
Please show your code, have you use break statement within parfor loop with a condition?
Check it out, it may be helpful
https://in.mathworks.com/matlabcentral/answers/4942-break-in-a-parfor-loop-processing-time-example-to-compare-it-with-a-for-loop
采纳的回答
Edric Ellis
2017-10-30
You can debug code called from the body of a parfor loop if no parallel pool is open, but unfortunately you cannot debug the body of a parfor loop itself. You can force the parfor loop to run in the desktop MATLAB by appending the optional "number of workers" argument, like so:
parfor (idx = 1:10, 0)
out(idx) = myFcn(idx);
end
With that code, you can set breakpoints inside myFcn.
更多回答(2 个)
NAGAVARSHINI MAYAKKANNAN
2020-6-21
Change the parfor to for debug it and then change for to parfor
0 个评论
zhehao.nkd
2022-8-5
For those who are seeking for the solution, there is another possible option by using parfor and try-catch:
parfor k = 1: len
try
% your code
catch ME
% record the iteration index,k
end
end
% Then youy know which iteration caused a bug alert
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!