Parfor loop hangs in R2021b
19 views (last 30 days)
Show older comments
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 Comments
Edric Ellis
on 21 Apr 2022
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.
Answers (1)
Mitch Lautigar
on 21 Apr 2022
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 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!