Error thrown in a parlor loop

7 views (last 30 days)
Truman
Truman on 9 Jul 2014
Commented: Truman on 10 Jul 2014
I am trying to speed up some computations using the parallel toolbox - particularly replacing a far loop with a parfor loop. I have made each iteration of the loop independent and debugged it using a normal for instead of parlor. There are 8 captured signal buffers. I want to find the time of arrival of a given signal in each buffer. The loop is 8 long - one for each buffer.
I first using a correlation procedure find the coarse TOA in a buffer and then using a different algorithm find the fine TOA and fill in the fields of a structure with the data. The results is an 8 dimensional structure array (already memory allocated). I have verbose debugging print out in the loop. When I run it with for - is is fine. When I run it with parfor it will do 3 and blow up one time and 6 and blow up the next time. The error is thrown during parfor gives me no clue to where the true error was. I put a try/catch around the contents of the loop but that did work either.
The specific error is "Subscripted assignment between dissimilar structures.
"Error in calc_SRS_pseudo_ranges_Ver_P (line 96) parfor n=1:num_int;"
Line 96 is the start of the parfor statement so this tells me nothing. Two questions - why will it work for some number properly and they blow up and any idea on how I better hone in on the actual line of code that is causing this?
Any help or suggestions will be appreciated.
Thank You Truman Prevatt

Accepted Answer

Edric Ellis
Edric Ellis on 10 Jul 2014
Have you tried debugging the loop when running it as a PARFOR? You can force the PARFOR to run locally in your desktop MATLAB instance by changing
parfor idx = 1:N
to
parfor (idx = 1:N, 0)
I suspect that the problem is that some structure that you're building inside the loop changes form somehow as the loop progresses.
  1 Comment
Truman
Truman on 10 Jul 2014
Thank you, that was what I was looking for. I expect from the error message you are correct since I am working with some large structure arrays. In for loops you can build structures and arrays dynamically in parfors that can present problems. This is my first adventure with the Parallel Toolbox. If I can find it I can fix it.
Thanks again.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!