User`s guide
7 Program Independent Jobs
7-12
Alternatively, you can create the five tasks with one call to createTask by providing a
cell array of five cell arrays defining the input arguments to each task.
T = createTask(job1, @rand, 1, {{3,3} {3,3} {3,3} {3,3} {3,3}});
In this case, T is a 5-by-1 matrix of task objects.
Submit a Job to the Job Queue
To run your job and have its tasks evaluated, you submit the job to the job queue with
the submit function.
submit(job1)
The job manager distributes the tasks of job1 to its registered workers for evaluation.
Each worker performs the following steps for task evaluation:
1
Receive AttachedFiles and AdditionalPaths from the job. Place files and
modify the path accordingly.
2
Run the jobStartup function the first time evaluating a task for this job. You can
specify this function in AttachedFiles or AdditionalPaths. When using an MJS,
ff the same worker evaluates subsequent tasks for this job, jobStartup does not
run between tasks.
3
Run the taskStartup function. You can specify this function in AttachedFiles
or AdditionalPaths. This runs before every task evaluation that the worker
performs, so it could occur multiple times on a worker for each job.
4
If the worker is part of forming a new parallel pool, run the poolStartup function.
(This occurs when executing parpool or when running other types of jobs that form
and use a parallel pool, such as batch.)
5
Receive the task function and arguments for evaluation.
6
Evaluate the task function, placing the result in the task’s OutputArguments
property. Any error information goes in the task’s Error property.
7
Run the taskFinish function.
Retrieve Job Results
The results of each task's evaluation are stored in that task object’s OutputArguments
property as a cell array. Use the function fetchOutputs to retrieve the results from all
the tasks in the job.