Parfor loop hangs in R2021b
19 次查看(过去 30 天)
显示 更早的评论
I have a parfor loop that runs fine in R2021a. The same exact parfor loop in R2021b hangs and I have to CTRL + C to stop it. When I do that, I get the following error:
So the getCompleteIntervals function seems to be the one hanging. Any ideas?
Thanks,
Alex.
3 个评论
Edric Ellis
2022-4-21
From what you've shown here, it's not straightforward to tell what changed to cause the problem. The function getCompleteIntervals is what your desktop MATLAB does while it is waiting for the workers to complete their work, so the fact that it is waiting there is completely expected.
Unfortunately, problems like this can be tricky to diagnose. You could try sprinkling disp statements through the body of your parfor loop. Or, you could contact MathWorks support who can help you gather diagnostic logging information which should help get to the bottom of this.
回答(1 个)
Mitch Lautigar
2022-4-21
parfor is a for loop that runs in parallel to your base process. Because of that, there are a bunch of things the issue could be. I've tried to list them down below in the forms of my comments.
- Parallel Processes: MATLAB is running your parfor loop in a partitioned section of the code. If your parfor loop is taking too long, it is likely to be very memory intensive. If possible, I recommend running your code in a regular for loop with the inputs you expect, and then change the for loop to be a parfor loop.
- The error you are seeing is completely logical. When you stop the code, MATLAB is stating that it was currently waiting in distributed_execution, and that it was also in runSweep on line 38. I recommend putting a break point before the parfor loop, manually setting "ii", and then copying your code into the command window one line at a time to see if you can find the line it's hanging up on. More than likely, since you are using structures/classes (I noticed the p.function name) you have some point in your parfor loop that is a very memory intensive command and figuring out what this line is will solve your problem (or at the very least, give you a starting point).
Hope this helps! If you post more of your code, i'm sure we (MATLAB forums) can help more.
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!