Programación paralela asíncrona
R2026bparfevalPuede evaluar una función en segundo plano con parfeval sin esperar a que termine. En muchos casos, puede resultar útil salir de un bucle for antes de tiempo. Por ejemplo, en un procedimiento de optimización, puede detener el bucle antes de tiempo cuando el resultado sea lo suficientemente bueno. Puede hacerlo en uno o en todos los workers del grupo paralelo con parfeval o parfevalOnAll. Esto puede resultar útil si desea representar resultados intermedios. Utilizar parfeval o parfevalOnAll es diferente de utilizar parfor, donde es necesario esperar a que el bucle termine.
Utilice send y poll conjuntamente para enviar y sondear mensajes o datos de distintos workers mediante una cola de datos. Puede utilizar afterEach para agregar una función a la que se llame cuando se reciban datos nuevos de una cola de datos.
Utilice afterEach y afterAll para invocar funciones automáticamente después de que termine cada elemento o todos los elementos de un arreglo Future. Este arreglo puede contener datos devueltos por parfeval, parfevalOnAll, afterEach o afterAll.
Funciones
Temas
Primeros pasos con la programación paralela asíncrona
- Evaluate Functions in the Background Using parfeval
Break out of an optimizing loop early and collect results as they become available. - Use afterEach and afterAll to Run Callback Functions
Automatically run functions afterFutureobjects finish running on parallel pools. - Query and Cancel parfeval Futures
This example shows how to query the state ofparfevalfutures and cancel them. - Actualice la interfaz de usuario de forma asincrónica usando afterEach y afterAll
Este ejemplo muestra cómo actualizar una interfaz de usuario a medida que se completan los cálculos. - Choose Between spmd, parfor, and parfeval
Compare and contrastspmdagainst other parallel computing functionality such asparforandparfeval.
Aplicaciones
- Representar durante el barrido de parámetros con parfeval
Este ejemplo muestra cómo realizar un barrido de parámetros paralelo conparfevaly enviar resultados durante los cálculos con un objetoDataQueue. - Perform Webcam Image Acquisition in Parallel with Postprocessing
This example shows how to perform frame acquisition from a webcam in parallel with data postprocessing. - Perform Image Acquisition and Parallel Image Processing
This example shows how to perform image acquisition from a webcam and postprocess data in parallel. - Send Messages to Workers Using Pollable Data Queues
This example shows how to use pollable data queues to send data or instructions to workers during asynchronous function evaluations withparfeval. (Desde R2025a) - Transfer Data Between Workers Using Pollable Data Queues
This example shows how to use a pollable data queue to transfer data between workers during asynchronous function evaluations withparfeval. (Desde R2025a) - Train Deep Learning Networks in Parallel (Deep Learning Toolbox)
This example shows how to run multiple deep learning experiments on your local machine. - Use parfeval to Train Multiple Deep Learning Networks (Deep Learning Toolbox)
This example shows how to useparfevalto perform a parameter sweep on the depth of the network architecture for a deep learning network and retrieve data during training. - Receive Communication on Workers
This example shows how to set up a data queue on the workers to receive data. (Desde R2023b) - Interactively Import and Process Data in Parallel
This example shows how to import and process data simultaneously in an interactive parallel pool. (Desde R2023b) - Perform Data Acquisition and Processing on Pool Workers
This example shows how to implement a parallel data acquisition and processing pipeline on an interactive parallel pool. (Desde R2025a) - Control Hardware and Acquire Data in Parallel
This example shows how to simultaneously control hardware and perform data acquisition on parallel workers. (Desde R2025a) - Monitor During Parallel Optimizations with parfeval
Perform multiple optimizations in parallel withparfevaland monitor the progress on the client. - Monitor and Stop Optimization Running On Worker
Run an optimization on a parallel worker and stop it early from the client without losing intermediate results.




