Please help with "parfor" not working!!! Don't know what's wrong!

15 ビュー (過去 30 日間)
Evan
Evan 2012 年 12 月 21 日
Hello,
I've got 4 nested for loops, with the outside loop as the parfor. I know a little bit about parfor sliced variables, so I got a different function with 2 nested loops (total of 2 loops) to work. But this version with 4 total loops doesn't work. Below is the modified code (for simplicity). I thought I'd taken care of the variable classifications and assignments, but
it's still giving me the error "Parfor cannot be run because of the way temp_up is used."
=========== CODE ===============
%Initialize Variables;
result_up = zeros( length( Z ), length( A ), length( B ), length( C ) );
temp_up = zeros( length( A ), length( B ), length( C ) );
%Start Parallel Loop
parfor Z_COUNT = 1 : length( Z )
Z_CURRENT = Z( Z_COUNT );
for A_COUNT = 1 : length( A )
some_var_up = some_function1( Z_CURRENT, A( A_COUNT ) );
for B_COUNT= 1 : length( B)
for C_COUNT = 1 : length( C)
return_up = some_function2( some_var, B( B_COUNT ), C( C_COUNT );
temp_up( A, B, C) = return_up;
end
end
end
result_up( Z_COUNT, :, :, : ) = temp_up;
end
====== END CODE ======
I've replaced all of the code with Z, A, B, C, etc for simplicity. For the Love of God, someone please help me with this!
  1 件のコメント
Evan
Evan 2012 年 12 月 21 日
Ah......
Got it fixed.
I just had to move the "temp_up" variable from outside of the parfor loop, to just inside it so that each instance of the parfor loop can create the variable.
...
TT

サインインしてコメントする。

採用された回答

Doug Hull
Doug Hull 2012 年 12 月 21 日
From the comments:
Ah......
Got it fixed.
I just had to move the "temp_up" variable from outside of the parfor loop, to just inside it so that each instance of the parfor loop can create the variable.
...
TT

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by