| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Parallel Computing Toolbox |
| Contents | Index |
| Learn more about Parallel Computing Toolbox |
| On this page… |
|---|
For jobs that require more control than the functionality offered by dfeval, you have to program all the steps for creating and running the job. Using the local scheduler lets you create and test your jobs without using the resources of your cluster. Distributing tasks to workers that are all running on your client machine might not offer any performance enhancement, so this feature is provided primarily for code development, testing, and debugging.
Note Workers running from a local scheduler on a Microsoft Windows operating system can display Simulink graphics as well as the output from certain functions such as uigetfile and uigetdir. (With other platforms or schedulers, workers cannot display any graphical output.) This behavior is subject to removal in a future release. |
This section details the steps of a typical programming session with Parallel Computing Toolbox software using a local scheduler:
Note that the objects that the client session uses to interact with the scheduler are only references to data that is actually contained in the scheduler's data location, not in the client session. After jobs and tasks are created, you can close your client session and restart it, and your job is still stored in the data location. You can find existing jobs using the findJob function or the Jobs property of the scheduler object.
You use the findResource function to create an object in your local MATLAB session representing the local scheduler.
sched = findResource('scheduler','type','local');You create a job with the createJob function. This statement creates a job in the scheduler's data location, creates the job object job1 in the client session, and if you omit the semicolon at the end of the command, displays some information about the job.
job1 = createJob(sched)
Job ID 1 Information
====================
UserName : eng864
State : pending
SubmitTime :
StartTime :
Running Duration :
- Data Dependencies
FileDependencies : {}
PathDependencies : {}
- Associated Task(s)
Number Pending : 0
Number Running : 0
Number Finished : 0
TaskID of errors : You can use the get function to see all the properties of this job object.
get(job1)
Configuration: ''
Name: 'Job1'
ID: 1
UserName: 'eng864'
Tag: ''
State: 'pending'
CreateTime: 'Mon Jan 08 15:40:18 EST 2007'
SubmitTime: ''
StartTime: ''
FinishTime: ''
Tasks: [0x1 double]
FileDependencies: {0x1 cell}
PathDependencies: {0x1 cell}
JobData: []
Parent: [1x1 distcomp.localscheduler]
UserData: []Note that the job's State property is pending. This means the job has not yet been submitted (queued) for running, so you can now add tasks to it.
The scheduler's display now indicates the existence of your job, which is the pending one.
sched
Local Scheduler Information
===========================
Type : local
ClusterOsType : pc
DataLocation : C:\WINNT\Profiles\eng864\App...
HasSharedFilesystem : true
- Assigned Jobs
Number Pending : 1
Number Queued : 0
Number Running : 0
Number Finished : 0
- Local Specific Properties
ClusterMatlabRoot : D:\apps\matlabAfter you have created your job, you can create tasks for the job using the createTask function. Tasks define the functions to be evaluated by the workers during the running of the job. Often, the tasks of a job are all identical. In this example, five tasks will each generate a 3-by-3 matrix of random numbers.
createTask(job1, @rand, 1, {{3,3} {3,3} {3,3} {3,3} {3,3}});The Tasks property of job1 is now a 5-by-1 matrix of task objects.
get(job1,'Tasks')
ans =
distcomp.task: 5-by-1To run your job and have its tasks evaluated, you submit the job to the scheduler with the submit function.
submit(job1)
The local scheduler starts up to eight workers and distributes the tasks of job1 to its workers for evaluation.
The results of each task's evaluation are stored in that task object's OutputArguments property as a cell array. After waiting for the job to complete, use the function getAllOutputArguments to retrieve the results from all the tasks in the job.
waitForState(job1) results = getAllOutputArguments(job1);
Display the results from each task.
results{1:5}
0.9501 0.4860 0.4565
0.2311 0.8913 0.0185
0.6068 0.7621 0.8214
0.4447 0.9218 0.4057
0.6154 0.7382 0.9355
0.7919 0.1763 0.9169
0.4103 0.3529 0.1389
0.8936 0.8132 0.2028
0.0579 0.0099 0.1987
0.6038 0.0153 0.9318
0.2722 0.7468 0.4660
0.1988 0.4451 0.4186
0.8462 0.6721 0.6813
0.5252 0.8381 0.3795
0.2026 0.0196 0.8318The local scheduler runs in the MATLAB client session, so you do not have to start any separate scheduler process for the local scheduler. When you submit a job for evaluation to the local scheduler, the scheduler starts a MATLAB worker for each task in the job, but only up to as many workers as the scheduler is configured to allow. If your job has more tasks than allowed workers, the scheduler waits for one of the current tasks to complete before starting another MATLAB worker to evaluate the next task. You can modify the number of allowed workers in the local scheduler configuration, up to a maximum of eight. If not configured, the default is to run only as many workers as computational cores on the machine.
The local scheduler has no interaction with any other scheduler, nor with any other workers that might also be running on your client machine under the mdce service. Multiple MATLAB sessions on your computer can each start its own local scheduler with its own eight workers, but these groups do not interact with each other, so you cannot combine local groups of workers to increase your local cluster size.
When you end your MATLAB client session, its local scheduler and any workers that happen to be running at that time also stop immediately.
![]() | Programming Distributed Jobs | Using a Job Manager | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |