Parfor loop is slow
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Parallel Computing Fundamentals dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!