Create communicating job on cluster
job = createCommunicatingJob(cluster)
job = createCommunicatingJob(...,'p1',v1,'p2',v2,...)
job = createCommunicatingJob(...,'Type','pool',...)
job = createCommunicatingJob(...,'Type','spmd',...)
job = createCommunicatingJob(...,'Profile','profileName',...)
job = createCommunicatingJob(cluster)
creates
a communicating job object for the identified cluster.
job = createCommunicatingJob(...,'p1',v1,'p2',v2,...)
creates
a communicating job object with the specified property values. For
a listing of the valid properties of the created object, see the parallel.Job
object reference page.
The property name must be in the form of a string, with the value
being the appropriate type for that property. In most cases, the values
specified in these property-value pairs override the values in the
profile. But when you specify AttachedFiles
or AdditionalPaths
at
the time of creating a job, the settings are combined with those specified
in the applicable profile. If an invalid property name or property
value is specified, the object will not be created.
job = createCommunicatingJob(...,'Type','pool',...)
creates
a communicating job of type 'pool'
. This is the
default if 'Type'
is not specified. A 'pool'
job
runs the specified task function with a parallel pool available to
run the body of parfor
loops or spmd
blocks.
Note that only one worker runs the task function, and the rest of
the workers in the cluster form the parallel pool. So on a cluster
of N workers for a 'pool'
type job, only N-1 workers
form the actual pool that performs the spmd
and parfor
code
found within the task function.
job = createCommunicatingJob(...,'Type','spmd',...)
creates
a communicating job of type 'spmd'
, where the specified
task function runs simultaneously on all workers, and lab*
functions
can be used for communication between workers.
job = createCommunicatingJob(...,'Profile','profileName',...)
creates a communicating job object with the property values specified
in the profile 'profileName'
. If no profile is
specified and the cluster object has a value specified in its 'Profile'
property,
the cluster's profile is automatically applied.
Pool Type Communicating Job
Consider the function 'myFunction'
which
uses a parfor
loop:
function result = myFunction(N) result = 0; parfor ii=1:N result = result + max(eig(rand(ii))); end end
Create a communicating job object to evaluate myFunction
on
the default cluster:
myCluster = parcluster; j = createCommunicatingJob(myCluster,'Type','pool');
Add the task to the job, supplying an input argument:
createTask(j, @myFunction, 1, {100});
Set the number of workers required for parallel execution:
j.NumWorkersRange = [5 10];
Run the job.
submit(j);
Wait for the job to finish and retrieve its results:
wait(j) out = fetchOutputs(j)
Delete the job from the cluster.
delete(j);
createJob
| createTask
| findJob
| parcluster
| recreate
| submit