This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Asynchronous Parallel Programming

Evaluate functions in the background using parfeval

You can evaluate a function in the background without waiting for it to complete, using parfeval. In many cases, it can be convenient to break out of a for loop early. For example, in an optimization procedure, you can stop the loop early when the result is good enough. You can do this on one or all parallel pool workers, using parfeval or parfevalOnAll. This can be useful if you want to be able to plot intermediate results. Note that this is different from using parfor, where you have to wait for the loop to complete.

Use send and poll together to send and poll for messages or data from different workers using a data queue. You can use afterEach to add a function to call when new data is received from a data queue.


Evaluate Functions in the Background Using parfeval

Break out of a loop early and collect results as they become available.


parfevalExecute function asynchronously on parallel pool worker
parfevalOnAllExecute function asynchronously on all workers in parallel pool
ticBytesStart counting bytes transferred within parallel pool
tocBytesRead how many bytes have been transferred since calling ticBytes
sendSend data from worker to client using a data queue
poll Retrieve data sent from a worker
afterEachDefine a function to call when new data is received
fetchOutputs (FevalFuture)Retrieve all output arguments from Future
fetchNextRetrieve next available unread FevalFuture outputs
cancel (FevalFuture)Cancel queued or running future
isequal (FevalFuture)True if futures have same ID
wait (FevalFuture)Wait for futures to complete
parallel.FutureRequest function execution on parallel pool workers
parallel.PoolAccess parallel pool
parallel.pool.DataQueueClass that enables sending and listening for data between client and workers
parallel.pool.PollableDataQueue Class that enables sending and polling for data between client and workers

Featured Examples

Was this topic helpful?