Unsure why parfor loop does not work in this case
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am in the process of converting my initial multilogic module (Multilogic_v4.m) into a parallel version (MultiLogic_v1_parallel.m). I use two functions: my own MAPR function and I use the permn function. I am mostly done but I cannot get the last line of code in the main module to work and I am not sure why. My guess is that parfors may have some kind of limitation with concatenating strings?
I would appreciate if anyone can take a look at my code and tell me what I seem to be doing wrong.
FYI - I disabled the "while" loop in the parallel version for debugging.
Thanks to the community!
Dave
0 Kommentare
Antworten (2)
Walter Roberson
am 22 Aug. 2022
Bearbeitet: Walter Roberson
am 22 Aug. 2022
N_New{h+1} = N{h+1}+1;
That is one update of N_New
N_New{h+1} = numel(SSet);
and that is a second update within the same parfor.
%while N_New{h+1} > N{h+1} && N_New{h+1} < MValU ^ (MValU ^ Arity)
Do not use N_New that way. Use a temporary variable and store the final results into N_New before the end of the parfor
0 Kommentare
Edric Ellis
am 23 Aug. 2022
The problematic variables appear to be both M and P. For M, you have multiple different "reads" from the variable after the initial assignment. Perhaps try
mVal = MAPR(MValU, Arity, OValU);
M{h+1} = mVal;
...
S{h+1} = mVal(:,j)'; % etc.
Likewise with P
pVal = permn(SSet,Arity);
P{h+1} = pVal;
...
V{h+1}{a,1} = dec2base(pVal(j,a),MValU,size(M{h+1},1));
3 Kommentare
Edric Ellis
am 24 Aug. 2022
Ah, with that updated code, you have a problem with V because there are two different indexing forms. You probably need the same trick again
vVal = dec2base(..);
V{h+1}{a,1} = vVal;
...
Q{h+1} = strcat(Q{h+1},vVal(k));
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!