parallel processing - Parfor sliced variable cause Matlab crash -


i'm trying prove code run in parallel, code works except when i'm assiging data sliced variable, believe i'm respecting matlab's parfor restrictions, , in fact runs smoothly parfor iterations point matlab crashs asking exiting.

the problem in last line when asigning values "features" (i've tried cells same problem):

if (matlabpool('size')==0)      matlabpool(); end   %prepare iterations numtrain = size(xnorm(1000:1250,:),1); numfeatures = size(xnorm,2); classdata=y(1000:1250,:);  %linear space grid zz = linspace(0.1,20,10); zsize=length(zz);  %definitions use inside parfor features=zeros(numfeatures,1); fmax=@(x) max(x);  parfor = 1:numfeatures      %internal variables definition     cscross=zeros(zsize,1);     sigmacsmax=zeros(zsize,1);      fprintf('\nfeature:%i...',i);      j=1:zsize      %precompute kernel         k =  [ (1:numtrain)' , gpukernel(xnorm(1000:1250,i),zz(j)) ];          iter = 1:zsize              options = sprintf('-c %d -t 4 -v 10 -q',zz(iter));             model = svmtrain(classdata, k, options);             cscross(iter)=model;          end          sigmacsmax(j)=fmax(cscross);     end    temp=fmax(sigmacsmax);     %%% here error caused. when removed code runs smoothly    features(i)=temp;  end 

any suggestion it? doing wrong? (just code works without parfor)

thanks in advance,

sergi

i found way make work. predefine "features" features=[] (without predefined size), let parfor build entire array. surprisingly result respect order. here code (i've omitted initial part): [.....]

%here define , empty array features=[];   parfor = 1:numfeatures      %internal variables definition     cscross=zeros(zsize,1);     sigmacsmax=zeros(zsize,1);     temp=0;      fprintf('\nfeature:%i...',i);      j=1:zsize      %precompute kernel         k =  [ (1:numtrain)' , gpukernel(xnorm(1000:1250,i),zz(j)) ];          iter = 1:zsize              options = sprintf('-c %d -t 4 -v 10 -q',zz(iter));             model = svmtrain(classdata, k, options);             cscross(iter)=model;          end          sigmacsmax(j)=fmax(cscross);     end    temp=fmax(sigmacsmax);     %%% every iteration add new results     features=[features,temp];  end 

find here more detailed explanation why works: http://www.mathworks.es/es/help/distcomp/getting-started-with-parfor.html#brdqn6p-1

hope may help.

sergi


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -