Programación paralela asincrónica
parfeval
Puede evaluar una función en segundo plano sin esperar a que se complete, usando parfeval
. En muchos casos, puede resultar conveniente salir temprano de un bucle for. Por ejemplo, en un procedimiento de optimización, puede detener el ciclo antes de tiempo cuando el resultado sea lo suficientemente bueno. Puede hacer esto en uno o todos los workers del grupo paralelo, usando parfeval
o parfevalOnAll
. Esto puede resultar útil si desea poder representar resultados intermedios. Tenga en cuenta que esto es diferente a usar parfor
, donde debe esperar a que se complete el ciclo.
Utilice send
y poll
juntos para enviar y sondear mensajes o datos de diferentes workers utilizando una cola de datos. Puede usar afterEach
para agregar una función para llamar cuando se reciben nuevos datos de una cola de datos.
Utilice afterEach
y afterAll
para invocar automáticamente funciones después de que se complete cada uno o después de que se completen todos los elementos de un arreglo Future
. Esta arreglo puede contener futuros devueltos por parfeval
, parfevalOnAll
, afterEach
o afterAll
.
Funciones
Temas
- Evaluate Functions in the Background Using parfeval
Break out of an optimizing loop early and collect results as they become available.
- Query and Cancel parfeval Futures
This example shows how to query the state of
parfeval
futures and cancel them. - Use afterEach and afterAll to Run Callback Functions
Automatically run functions after
Future
objects finish running on parallel pools. - Plot During Parameter Sweep with parfeval
This example shows how to perform a parallel parameter sweep with
parfeval
and send results back during computations with aDataQueue
object. - Update User Interface Asynchronously Using afterEach and afterAll
This example shows how to update a user interface as computations complete.
- 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.
- 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 use
parfeval
to perform a parameter sweep on the depth of the network architecture for a deep learning network and retrieve data during training. - Choose Between spmd, parfor, and parfeval
Compare and contrast
spmd
against other parallel computing functionality such asparfor
andparfeval
. - 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)