Error thrown in a parlor loop

5 次查看(过去 30 天)
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

采纳的回答

Edric Ellis
Edric Ellis 2014-7-10
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 个评论
Truman
Truman 2014-7-10
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by