Parfor loop is slow
Show older comments
The following code is slower compared to the one without parfor! What is the reason?
numCores = 4; % Specify the number of cores to be used
maxNumCompThreads(numCores); % Set the maximum number of computational threads
.........
%where X,Y,Z are matrixes
Complex_data = zeros(Ns, n_iter);
iterationTimes = zeros(n_iter);
for i = 0:n_iter-1
% where X,Y,Z are matrixes
Z = Z_full(:,i*dec_samples+1:Ny+i*dec_samples);
[ la, lb, Ux, Uy, Uz, R ] = surfaspect( X, Y, Z, x0, y0, z0); % contains only vectorial operations,
% Create a vector to store the simulated echo spectra for all filters
E = facet2ndinterp( la, lb, Ux, Uy, Uz, R, fband + f0 ); % contains only vectorial operations, fband is a 1x1xn vector and E a m x p x n matrix
espectr = sum( sum( E ) );
espectr = espectr(:);
espectr = [espectr( 1 : Nf2 ); zeros(length( f )- Nf,1); espectr( end - Nf2 + 2 : end )];
Complex_data( : , i+1 ) = ifft(espectr);
% Store the execution time of the current iteration
iterationTimes(i+1) = toc;
fprintf('Sounding %d/%d completed. Execution time:%ds\n',i+1,100,iterationTimes(i+1))
end
Accepted Answer
More Answers (0)
Categories
Find more on Parallel Computing Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!