Asynchronous Parallel Programming
parfeval
You can evaluate a function in the background without waiting for it to complete, usingparfeval
. 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, usingparfeval
orparfevalOnAll
. This can be useful if you want to be able to plot intermediate results. Note that this is different from usingparfor
, where you have to wait for the loop to complete.
Usesend
andpoll
together to send and poll for messages or data from different workers using a data queue. You can useafterEach
to add a function to call when new data is received from a data queue.
Topics
Evaluate Functions in the Background Using parfeval
Break out of a loop early and collect results as they become available.
Functions
Functions and Classes
parfeval |
Execute function asynchronously on parallel pool worker |
parfevalOnAll |
Execute function asynchronously on all workers in parallel pool |
ticBytes |
Start counting bytes transferred within parallel pool |
tocBytes |
Read how many bytes have been transferred since calling ticBytes |
send |
Send data from worker to client using a data queue |
poll |
Retrieve data sent from a worker |
afterEach |
Define a function to call when new data is received |
fetchOutputs (FevalFuture) |
Retrieve all output arguments from Future |
fetchNext |
Retrieve 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.Future |
Request function execution on parallel pool workers |
parallel.Pool |
Access parallel pool |
parallel.pool.DataQueue |
Class 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 |