performance - Matlab parfor, cannot run "due to the way P is used" -
i have quite time consuming task perform in loop. each iteration independent others figured out use parfor
loop , benefit i7 core of machine.
the serial loop is:
i=1 : size(datacoord,1) %p matrix: person_number x z or p(i,1) = datacoord(i,1); %pn p(i,4) = datacoord(i,5); %or p(i,3) = predict(barea2, datacoord(i,4)); %distance (z) dist = round(p(i,3)); %round distance how many cells x = ceil(datacoord(i,2) / (im_w / ncell(1,dist))); p(i,2) = pos(dist, x); %x end
reading around parfor, doubt had use dist , x indexes calculated inside loop, heard problem. error matlab way p matrix used though. how it? if remember correcly parallel computing courses , interpret correcly parfor documentation, should work switching for
parfor
.
any input appreciated, thanks!
unfortunately, in parfor loop, 'sliced' variables such you'd p
cannot indexed in multiple different ways. simplest solution build single row, , make single assignment p
, this:
parfor i=1 : size(datacoord,1) %p matrix: person_number x z or p_tmp = nan(1, 4); p_tmp(1) = datacoord(i,1); %pn p_tmp(4) = datacoord(i,5); %or p_tmp(3) = predict(barea2, datacoord(i,4)); %distance (z) dist = round(p_tmp(3)); %round distance how many cells x = ceil(datacoord(i,2) / (im_w / ncell(1,dist))); p_tmp(2) = pos(dist, x); %x p(i, :) = p_tmp; end
Comments
Post a Comment