I am trying to parallelize a for loop. Here is a minimal working example of what I am trying to do at the moment.
nx = 96;ny = nx;Tk_all = zeros(nx,ny);Tkp_all = zeros(2*kmax+1,kmax+1,nx,ny);dim2 = 31;dim3 = 31;kmax = min(dim2,dim3);c = parcluster('local');c.NumWorkers = 24;parpool(c, c.NumWorkers);for kxi=-kmax:kmax parfor kyi=0:kmax Tk_entry = kxi*kyi*ones(nx,ny); % should be something more meaningful
Tk_all(nx/2+(kxi-1)+1,ny/2+(kyi-1)+1) = sum(reshape(Tk_entry,nx*ny,1)); Tkp_all(kmax+1+(kxi-1)+1,1+(kyi-1)+1,:,:) = Tk_entry; end Tk_all(nx/2-(kxi-1)+1,ny/2-([0:kmax]-1)+1) = Tk_all(nx/2+(kxi-1)+1,ny/2+([0:kmax]-1)+1);enddelete(gcp('nocreate'))
and I receive the error
Error: The variable Tk_all in a parfor cannot be classified.
I though I was satisfying the requirements from, for example here:
but clearly I am missing something. Any help?
I apologize if this question seems to be a duplicate of other existing questions, but I cannot seem to figure out my specific problem.
Thanks!
Best Answer