iterlin and iterget

Linearize nested loops for smarter dispatch by parfor
275 download
Aggiornato 17 dic 2013

Visualizza la licenza

MATLAB does not allow nested parfor loops, resulting in idle time for workers at loop boundaries. In the following example, no loop is a good choice for conversion to parfor:

for plate = 1 : 3
for row = 2 : 7
for col = 4 : 9
% time-consuming computations here %
end
end
end

A solution for having workloads from within nested loops be dispatched to workers without idling is to linearize, but that approach becomes cumbersome if ranges do not start from one. Now, iterlin and iterget provide a simple pattern:

rng = [1, 3; 2, 7; 4, 9];
parfor k = iterlin(rng)
[plate, row, col] = iterget(rng, k);
% time-consuming computations here %
end

With the above pattern, you reduce idle time for workers, and no longer need to think about which loop to convert to parfor.

Cita come

Samuel Bandara (2025). iterlin and iterget (https://it.mathworks.com/matlabcentral/fileexchange/44561-iterlin-and-iterget), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2012b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Tag Aggiungi tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.2.0.0

Fix for earlier releases, going back at least to 2012b.

1.1.0.0

Added a specific usage example in the description.

1.0.0.0