Parallel Computing Toolbox™ and MATLAB® Distributed Computing Server™ software let you solve computationally and data-intensive problems using MATLAB and Simulink® on multicore and multiprocessor computers. Parallel processing constructs such as parallel for-loops and code blocks, distributed arrays, parallel numerical algorithms, and message-passing functions let you implement task-parallel and data-parallel algorithms at a high level in MATLAB without programming for specific hardware and network architectures.
A job is some large operation that you need to perform in your MATLAB session. A job is broken down into segments called tasks. You decide how best to divide your job into tasks. You could divide your job into identical tasks, but tasks do not have to be identical.
The MATLAB session in which the job and its tasks are defined is called the client session. Often, this is on the machine where you program MATLAB. The client uses Parallel Computing Toolbox software to perform the definition of jobs and tasks and to run them on a cluster local to your machine. MATLAB Distributed Computing Server software is the product that performs the execution of your job on a cluster of machines.
The MATLAB job scheduler (MJS) is the process that coordinates the execution of jobs and the evaluation of their tasks. The MJS distributes the tasks for evaluation to the server's individual MATLAB sessions called workers. Use of the MJS to access a cluster is optional; the distribution of tasks to cluster workers can also be performed by a third-party scheduler, such as Microsoft® Windows® HPC Server (including CCS) or Platform LSF®.
See the Glossary for definitions of the parallel computing terms used in this manual.
Basic Parallel Computing Setup
The MJS can be run on any machine on the network. The MJS runs jobs in the order in which they are submitted, unless any jobs in its queue are promoted, demoted, canceled, or deleted.
Each worker is given a task from the running job by the MJS, executes the task, returns the result to the MJS, and then is given another task. When all tasks for a running job have been assigned to workers, the MJS starts running the next job on the next available worker.
A MATLAB Distributed Computing Server software setup usually includes many workers that can all execute tasks simultaneously, speeding up execution of large MATLAB jobs. It is generally not important which worker executes a specific task. In an independent job, the workers evaluate tasks one at a time as available, perhaps simultaneously, perhaps not, returning the results to the MJS. In a communicating job, the workers evaluate tasks simultaneously. The MJS then returns the results of all the tasks in the job to the client session.
For testing your application locally or other purposes, you can configure a single computer as client, worker, and MJS host. You can also have more than one worker session or more than one MJS session on a machine.
Interactions of Parallel Computing Sessions
A large network might include several MJSs as well as several client sessions. Any client session can create, run, and access jobs on any MJS, but a worker session is registered with and dedicated to only one MJS at a time. The following figure shows a configuration with multiple MJSs.
Cluster with Multiple Clients and MJSs
A feature of Parallel Computing Toolbox software is the ability to run a local cluster of workers on the client machine, so that you can run jobs without requiring a remote cluster or MATLAB Distributed Computing Server software. In this case, all the processing required for the client, scheduling, and task evaluation is performed on the same computer. This gives you the opportunity to develop, test, and debug your parallel applications before running them on your network cluster.
As an alternative to using the MJS, you can use a third-party scheduler. This could be a Microsoft Windows HPC Server (including CCS), Platform LSF scheduler, PBS Pro® scheduler, TORQUE scheduler, or a generic scheduler.
Choosing Between a Third-Party Scheduler and an MJS. You should consider the following when deciding to use a third-party scheduler or the MATLAB job scheduler (MJS) for distributing your tasks:
Does your cluster already have a scheduler?
If you already have a scheduler, you may be required to use it as a means of controlling access to the cluster. Your existing scheduler might be just as easy to use as an MJS, so there might be no need for the extra administration involved.
Is the handling of parallel computing jobs the only cluster scheduling management you need?
The MJS is designed specifically for MathWorks® parallel computing applications. If other scheduling tasks are not needed, a third-party scheduler might not offer any advantages.
Is there a file sharing configuration on your cluster already?
The MJS can handle all file and data sharing necessary for your parallel computing applications. This might be helpful in configurations where shared access is limited.
Are you interested in batch mode or managed interactive processing?
When you use an MJS, worker processes usually remain running at all times, dedicated to their MJS. With a third-party scheduler, workers are run as applications that are started for the evaluation of tasks, and stopped when their tasks are complete. If tasks are small or take little time, starting a worker for each one might involve too much overhead time.
Are there security concerns?
Your own scheduler might be configured to accommodate your particular security requirements.
How many nodes are on your cluster?
If you have a large cluster, you probably already have a scheduler. Consult your MathWorks representative if you have questions about cluster size and the MJS.
Who administers your cluster?
The person administering your cluster might have a preference for how jobs are scheduled.
Do you need to monitor your job's progress or access intermediate data?
A job run by the MJS supports events and callbacks, so that particular functions can run as each job and task progresses from one state to another.
Parallel Computing Toolbox software and MATLAB Distributed Computing Server software are supported on Windows, UNIX®, and Macintosh operating systems. Mixed platforms are supported, so that the clients, MJS, and workers do not have to be on the same platform. Other limitations are described at System Requirements.
In a mixed-platform environment, system administrators should be sure to follow the proper installation instructions for the local machine on which you are installing the software.
If you are using the MJS, every machine that hosts a worker or MJS session must also run the mdce service.
The mdce service controls the worker and MJS sessions and recovers them when their host machines crash. If a worker or MJS machine crashes, when the mdce service starts up again (usually configured to start at machine boot time), it automatically restarts the MJS and worker sessions to resume their sessions from before the system crash. More information about the mdce service is available in the MATLAB Distributed Computing Server documentation.
A client session communicates with the MJS by calling methods and configuring properties of an MJS cluster object. Though not often necessary, the client session can also access information about a worker session through a worker object.
When you create a job in the client session, the job actually exists in the MJS job storage location. The client session has access to the job through a job object. Likewise, tasks that you define for a job in the client session exist in the MJS data location, and you access them through task objects.
When you create and run a job, it progresses through a number
of stages. Each stage of a job is reflected in the value of the job
State property, which can be
finished. Each of these stages is briefly described
in this section.
The figure below illustrates the stages in the life cycle of
a job. In the MJS (or other scheduler), the jobs are shown categorized
by their state. Some of the functions you use for managing a job are
Stages of a Job
The following table describes each stage in the life cycle of a job.
You create a job on the scheduler with the
When you execute the
When a job reaches the top of the queue, the scheduler
distributes the job's tasks to worker sessions for evaluation. The
job’s state is now
When all of a job’s tasks have been evaluated,
the job is moved to the
When using a third-party scheduler, a job might fail if the scheduler encounters an error when attempting to execute its commands or access necessary files.
When a job’s data has been removed from its data
location or from the MJS with the
Note that when a job is finished, its data remains in the MJS’s
even if you clear all the objects from the client session. The MJS
or scheduler keeps all the jobs it has executed, until you restart
the MJS in a clean state. Therefore, you can retrieve information
from a job later or in another client session, so long as the MJS
has not been restarted with the
You can permanently remove completed jobs from the MJS or scheduler's
storage location using the Job Monitor GUI or the