• No results found

Coding in the Client

As with distributed jobs, you find a scheduler and create a scheduler object in your MATLAB client by using thefindResourcefunction. There are slight differences in the arguments forfindResource, depending on the scheduler you use, but using configurations to define as many properties as possible minimizes coding differences between the scheduler types.

You can create and configure the scheduler object with this code:

sched = findResource('scheduler', 'configuration', myconfig) set(sched, 'Configuration', myconfig)

wheremyconfig is a string variable with one of the following values, representing the type of scheduler you are using:

'jobmanager'

'ccs'

'lsf'

'mpiexec'

Any required differences for these various scheduling options are controlled in the configuration file. One configuration file can contain multiple configurations, one for each type of scheduler. For complete details, see

“Programming with User Configurations” on page 2-5. The configuration file delivered with the toolbox includes instructions on which properties are required for each type of scheduler to define a complete configuration. Edit the configuration file for your configurations according to the instructions of your system administrator.

6-5

6

Programming Parallel Jobs

When your scheduler object is defined, you create the job object with the createParallelJobfunction.

pjob = createParallelJob(sched);

The function filecolsum.m(created in “Coding the Task Function” on page 6-4) is on the MATLAB client path, but it has to be made available to the labs.

One way to do this is with the job’sFileDependenciesproperty.

set(pjob, 'FileDependencies', {'colsum.m'})

Here you might also set other properties on the job, for example, setting the number of workers to use. Again, configurations might be useful in your particular situation, especially if most of your jobs require many of the same property settings.

You create the job’s one task with the usualcreateTaskfunction. In this example, the task returns only one argument from each lab, and there are no input arguments to thecolsumfunction.

t = createTask(pjob, @colsum, 1, {})

Usesubmitto run the job.

submit(pjob)

Make the MATLAB client wait for the job to finish before collecting the results. The results consist of one value from each lab. Thegplusfunction in the task shares data between the labs, so that each lab has the same result.

waitForState(pjob)

results = getAllOutputArguments(pjob) results =

[136]

[136]

[136]

[136]

Using the Generic Scheduler Interface

Using the Generic Scheduler Interface

This section discusses programming parallel jobs using the generic scheduler interface. This interface lets you execute jobs on your cluster with any scheduler you might have.

• “Introduction” on page 6-7

• “Coding in the Client” on page 6-7

Introduction

The principles of using the generic scheduler interface for parallel jobs are the same as those for distributed jobs. The overview of the concepts and details of submit and decode functions for distributed jobs are discussed fully in “Using the Generic Scheduler Interface” on page 4-24 in the chapter on Programming Distributed Jobs.

Coding in the Client

Configuring the Scheduler Object

Coding a parallel job for a generic scheduler involves the same procedure as coding a distributed job.

1 Create an object representing your scheduler withfindResource. 2 Set the appropriate properties on the scheduler object. Because the

scheduler itself is often common to many users and applications, it is probably best to use a configuration for programming these properties. See “Programming with User Configurations” on page 2-5. A template configuration is provided with the toolbox in

matlabroot/toolbox/distcomp/user/distcompUserConfig.m, which accommodates generic schedulers.

Among the properties required for a parallel job isParallelSubmitFcn. The toolbox comes with several submit functions for various schedulers and platforms; see the following section, “Supplied Submit and Decode Functions” on page 6-8.

6-7

6

Programming Parallel Jobs

3 UsecreateParallelJobto create a parallel job object for your scheduler.

4 Create a task, run the job, and retrieve the results as usual.

Supplied Submit and Decode Functions

There are several submit and decode functions provided with the toolbox for your use with the generic scheduler interface. These files are in the directory

matlabroot/toolbox/distcomp/examples/integration

In this directory are subdirectories for each of several types of scheduler, containing wrappers, submit functions, and decode

functions for distributed and parallel jobs. For example, the directory matlabroot/toolbox/distcomp/examples/integration/pbscontains the following files for use with a PBS scheduler:

Filename Description

pbsSubmitFcn.m Submit function for a distributed job pbsDecodeFunc.m Decode function for a distributed job pbsParallelSubmitFcn.m Submit function for a parallel job pbsParallelDecode.m Decode function for a parallel job pbsWrapper.sh Script that is submitted to PBS to start

workers that evaluate the tasks of a distributed job

pbsParallelWrapper.sh Script that is submitted to PBS to start labs that evaluate the tasks of a parallel job

Depending on your network and cluster configuration, you might need to modify these files before they will work in your situation. Ask your system administrator for help.

As more files or solutions might become available at any time, visit the Support page for this product on the MathWorks Web site at

http://www.mathworks.com/support/product/product.html?product=DM. This page also provides contact information in case you have any questions.

Related documents