Bucles for paralelos (parfor)
R2026bUtilizar el procesamiento paralelo ejecutando
parfor en workers de un grupo paralelo Parallel Computing Toolbox™ admite el cálculo paralelo interactivo y permite acelerar el flujo de trabajo mediante la ejecución en múltiples workers de un grupo paralelo. Utilice parfor para ejecutar iteraciones de bucles for en paralelo en workers de un grupo paralelo. Cuando haya perfilado el código e identificado bucles for lentos, pruebe parfor para aumentar el rendimiento. Desarrolle bucles parfor en el equipo de escritorio y escale a un cluster sin cambiar el código.
Funciones
Temas
Primeros pasos con parfor
- Decide When to Use parfor
Discover basic concepts of aparfor-loop, and decide when to use it. - Convertir for-bucles en parfor-bucles
Diagnosticar y solucionar problemas comunes deparfor. - Ensure That parfor-Loop Iterations Are Independent
Unlike afor-loop,parfor-loop Iterations have no guaranteed order. - Nested parfor and for-Loops and Other parfor Requirements
Learn how to deal with parallel nested loops. - Solucionar problemas de variables en parfor-Loops
Descubra los requisitos variables y la clasificación enparfor-loops. - Ejecute bucles de forma interactiva en paralelo usando parfor
Convierta un bucleforen un bucleparforescalable. - Resolve Issues in parfor-loops Using MATLAB Copilot
Use MATLAB® Copilot to explain Code Analyzer warnings and errors in the Editor or Live Editor. (Desde R2026b)
Ejecución de bucles parfor
- Improve parfor Performance
Create arrays inside or outsideparfor-loops to speed up code. - Use Objects and Handles in parfor-Loops
Discover how to use objects, handles, and sliced variables inparfor-loops. - Ensure Transparency in parfor-Loops or spmd Statements
All references to variables inparfor-loops must be visible in the body of the program. - Save Variables in parfor-Loops
This example shows how to use thesavefunction in aparfor-loop to save one or more variables to a file. (Desde R2024a) - Scale Up parfor-Loops to Cluster and Cloud
Developparfor-loops on your desktop, and scale up to a cluster without changing your code. - Use parfor-Loops for Reduction Assignments
You can useparfor-loops to calculate cumulative values that are updated by each iteration. - Repeat Random Numbers in parfor-Loops
This example shows how to control random number generation inparfor-loops by assigning a particular substream for each iteration. - Use parfor to Speed Up Monte-Carlo Code
This example shows how to speed up Monte-Carlo code by usingparfor-loops. - Interactively Import and Process Data in Parallel
This example shows how to import and process data simultaneously in an interactive parallel pool. (Desde R2023b) - Compare Performance of Multithreading and ProcessPool
Compare how fast functions run on the client and on aProcessPool. - Optimize Parallel Pools for Multithreaded Computations
Tune the number of workers and threads per worker to improve the computational performance of your parallel pool. (Desde R2026a) - Resolve Error: Client Lost Connection to Worker
Troubleshoot lost connection to worker error when running code on parallel pools. (Desde R2026a)
Aplicaciones
- Use parfor to Train Multiple Deep Learning Networks (Deep Learning Toolbox)
This example shows how to use aparforloop to perform a parameter sweep on a training option. - Monitor During Parallel Optimizations with parfor
Run multiple optimization problems in parallel using parfor, while monitoring solver progress in real time on the client using aDataQueue.


