Distributed Computing Server (parallel job)¶
The MATLAB Parallel Computing Toolbox (PCT) enables a parallel job via the MATLAB Distributed Computing Server (DCS). The tasks of a parallel job are identical, run simultaneously on several MATLAB workers, or labs, and communicate with each other.
This example illustrates an MPI-like program.
The example shows how to submit a small MATLAB parallel job with four workers running one MPI-like task to a batch queue. The MATLAB program broadcasts an integer to four workers and gathers the names of the compute nodes running the workers and the lab IDs of the workers.
This example uses the job submission command to submit a MATLAB script with a user-defined cluster profile. The profile scatters the MATLAB workers onto different compute nodes.
This method uses:
- the MATLAB interpreter
- the Parallel Computing Toolbox
- the Distributed Computing Server
It requires and checks out six licenses:
- one MATLAB license for the client running on the compute node
- one Parallel Computing Toolbox license
- four Distributed Computing Server licenses
Four DCS licenses run the four copies of the parallel job.
This job is completely off the front end.
MATLAB Script¶
Prepare a MATLAB script named myscript.m:
SLURM Job Submission File¶
Prepare a job submission file. In this example, the file is named myjob.sub.
Run with the name of the script:
Set the Default Parallel Configuration¶
Run MATLAB to set the default parallel configuration to your appropriate profile:
Then, inside MATLAB:
Submit the Job¶
Submit the job as a single compute node with one processor core.
Once this job starts, a second job submission is made.
Example Output¶
The output may look similar to this:
The output shows the name of one compute node, gilbreth-a006, that processed the job submission file myjob.sub.
The job submission scattered four processor cores, or four MATLAB labs, among four different compute nodes:
gilbreth-a006gilbreth-a007gilbreth-a008gilbreth-a009
These nodes processed the four parallel regions.
Scaling Up¶
To scale this method for a real application:
- Increase the wall time in the submission command to accommodate a longer-running job.
- Increase the wall time of
myslurmprofileby using the MATLAB Cluster Profile Manager. - In the Cluster Profile Manager, use the
Parallelmenu to enter a new wall time in theSubmitArgumentsproperty.