parfeval
Run function on parallel pool worker
Description
schedules the function F = parfeval(fcn,numFcnOut,X1,...,Xm)fcn to be run. MATLAB® runs the function using a parallel pool if one is available. Otherwise, it
runs the function in serial.
You can share your parallel code that uses this syntax with MATLAB users who do not have Parallel Computing Toolbox™.
MATLAB asynchronously evaluates the function fcn on each worker
with the specified input arguments X1,…Xm, and returns
numFcnOut output arguments.
MATLAB returns the Future object F before the
function fcn finishes running. You can use fetchOutputs to
retrieve the results from the future. To stop running the function fcn,
use the cancel
function. For more information about futures, see Future.
If a parallel pool is open, MATLAB uses that parallel pool to run the function fcn.
If a parallel pool is not open, the behavior depends on whether automatic pool creation is enabled.
Automatic pool creation is enabled — MATLAB starts a parallel pool using the default cluster profile, then uses that parallel pool to run the function
fcn. Automatic pool creation is enabled by default.You can manually force this behavior by specifying
parpoolto the pool argumentpool.Automatic pool creation is disabled — MATLAB runs the function
fcnusing deferred execution.You can manually force this behavior by specifying
parallel.Pool.emptyto the pool argumentpool.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2013bSee Also
parfeval | cancel | ticBytes | tocBytes | afterEach | afterAll | fetchNext | fetchOutputs | parallel.pool.Constant | parfevalOnAll | parpool | wait | Future | pctRunOnAll

