Sliced variables in parfor loop - any chance to optimize?
Show older comments
I'm trying to simulate image simulation in lithographic systems and was lucky to find the book "Computational Lithography" which provides some m-files as a base. Now I'm trying to implement my own code and optimize it for CPU-parallel computing. After hours of (more less) trial and error I thought, I could try to ask somebody who's more acknowledged.
My code so far:
tic
index_x = repmat(1:N_mask^2,[N_mask^2 1]);
index_x = index_x(:);
index_y = repmat(1:N_mask^2, 1, N_mask^2)';
index_1=mod(index_x-1,N_mask)+1;
index_2=floor((index_x-1)/N_mask)+1;
index_3=mod(index_y-1,N_mask)+1;
index_4=floor((index_y-1)/N_mask)+1;
index_m = (mod(index_1-index_3,N_mask) + 1)';
index_n = (mod(index_2-index_4,N_mask) + 1)';
aerial=zeros(N_mask,N_mask);
aerial_fre=zeros(N_mask,N_mask);
pz_fre=(fftshift(fft2(pz)));
for idx=1:N_mask^4
aerial_fre(index_m(idx),index_n(idx))=aerial_fre(index_m(idx),index_n(idx))+...
TCC(index_x(idx),index_y(idx))*(pz_fre(index_1(idx),index_2(idx)))*...
conj(pz_fre(index_3(idx),index_4(idx)));
end
toc
My idea was to parallelize the for-loop as a parfor, but it always gives errors with "sliced variables", no matter which way I use it. I've also tried the following: http://www.mathworks.com/matlabcentral/answers/76684-how-do-i-implement-parfor-loop-with-nested-for-loops
Any ideas? Thank you very much in advance
Accepted Answer
More Answers (0)
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!