Subscripted assignment between dissimilar structures in parfor but not for
2 views (last 30 days)
Show older comments
I have a bit of code I wanted to parallelize. A different question showed me how to get my code in basic shape for parallelization (eg. don't try to access array elements by anything other than the loop index) . The code below runs fine with for, but fails using parfor:
function boxes = det_fast(im,model,thresh)
...
% parfor requires next 3 lines for some reason...
po = gcp();
addAttachedFiles(po,{'det_fast.m'})
addAttachedFiles(po,{'det.m'})
temparray=cell(numparts);
level=0
parfor k = 1:numparts
disp(['loop started, k=' num2str(k)]);
indices(k)=0
emptyflag=0
f = parts(k).filterid;
level = rlevel-parts(k).scale*interval; %
if isempty(resp{level})
temp = fconv(pyra.feat{level},filters,1,length(filters));
temparray{k}=temp;
indices(k)=level;
emptyflag=1
end
for fi = 1:length(f)
if emptyflag == 1
parts(k).score(:,:,fi) = temp{f(fi)};
else
parts(k).score(:,:,fi) = resp{level}{f(fi)};
end
end
parts(k).level = level;
disp(['loop ended, k=' num2str(k)]);
end
this hits a snag only when run using parfor , which I haven't been able to grok:
loop started, k=17
loop ended, k=17
[17-Nov-2015 11:46:23] Error:f_calculator: 1 / 1
Error using det_fast>(parfor consume) (line 1)
Subscripted assignment between dissimilar structures.
Error in det_fast (line 40)
parfor k = 1:numparts
Error in p.estimate>process (line 38)
box = det_fast(im, model, detector_threshold);
Error in p.estimate (line 21)
boxes{i} = process(model, samples{i}, scale, nms_threshold);
Error in p_calc.apply (line 24)
samples(i).(config.output) = p.estimate(config.model, ...
Error in f_calculator.apply (line 25)
sample = calculators{j}(config{j}, sample, varargin{:}, 'Encode', false);
Error in pd_parfor (line 29)
result = f_calculator.apply(config, input_sample)
From the debug lines sprinkled in there it seems that the fail is not within that section of code (as the code always reaches the 'loop ended'). Does anyone recognize the "Error using det_fast>(parfor consume)" or have any other clues for me? TIA, JR
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!