Choose Batch Processing Function
Batch processing workflows allow you to offload work to a compute cluster and free up your MATLAB® client to carry out other tasks, or submit long running code for later execution. When you offload work to a remote compute cluster, you can close the MATLAB client session while the job is processing and retrieve information from a batch job later or in a new client session.
To develop and test your code, you can offload work to a local cluster on your client machine. If you close your MATLAB session, any batch jobs using the local cluster also stop immediately.
Batch Parallel Job Types
Parallel Computing Toolbox™ packages the MATLAB code you want to execute offline into jobs and tasks. To find out more about how Parallel Computing Toolbox runs a job, see How Parallel Computing Software Runs a Job.
There are two types of jobs you can run in a batch workflow:
Independent Jobs – execute a task in isolation on a worker, with no communication between workers.
Typically, if your code does not require a parallel pool, then you can use an independent job.
Communicating Jobs – one worker acts as the client and the other workers run the noninteractive pool. The workers can communicate with each other during the execution of their tasks.
Typically, if your code calls functions that require a parallel pool such as
parfor
,parfeval
,spmd
, ordistributed
, then it is a communicating job.
Parallel Computing Toolbox provides the following functions to run your MATLAB code in a batch process:
Tip
For a simpler function to run communicating jobs, use the
batch
function instead of the
createCommunicatingJob
function.
The following diagram shows when to use the batch
and
createJob
functions.
Select Batch Function
To decide which batch processing function is right for you, consult this table.
Example Applications | Functions and Approach | Examples |
---|---|---|
You want to execute a MATLAB script in the background on a cluster. | Use the | |
You want to use a noninteractive pool on an onsite or cloud cluster to run code including one or more of:
| Use the | |
You have multiple independent MATLAB function calls to run in the background on a cluster. Each function does not require a parallel pool of workers. | Use the You can create an independent task for each function call. When a task is complete, the worker moves on to the next task on the list without waiting for the other tasks to finish. You can also access intermediate results from the completed tasks. |
See Also
batch
| createJob
| createCommunicatingJob
| createTask