Parallel MATLAB

MathWorks’ MATLAB computational software with the Distributed Computing Engine and Parallel Computing Toolbox is currently installed on the HPC Linux cluster.

To access the software, run source on the setup script for Matlab.

source /usr/usc/matlab/default/setup.sh

It is also recommended that you include the following line in your job script

export TZ=America/Los_Angeles

which will suppress timezone warnings.

To use a parallel Matlab environment copy the files located in /usr/usc/matlab/default/parallel_scripts to your ~/matlab directory. You may have to create this if it doesn’t already exist. After you have these files, follow these steps:

Single Node

  1. Modify lines 4 and 6 in get_LOCAL_cluster.m so that they read:

    evalc('system(''mkdir -p <job_storage_path>'')'); c.JobStorageLocation='<job_storage_path>';

    Where <job_storage_path> is a path to where you want Matlab to store job output and logs.

  2. To start a cluster object you can add the following line to your Matlab script:

    cluster=get_LOCAL_cluster

  3. Include the command parpool(<N>) in your Matlab program to start a pool of N workers.

Multi Node

  1. Modify lines 5 and 6 in get_SLURM_cluster.m so that they read:

    evalc('system(''mkdir -p <job_storage_path>'')'); cluster = parallel.cluster.Generic('JobStorageLocation', '<job_storage_path>');

    Where <job_storage_path> is a path to where you want Matlab to store job output and logs.

  2. To create a cluster object you can add the following line to your Matlab script:

    cluster=get_SLURM_cluster('--time=HH:MM:SS')

    Where HH:MM:SS represents the hours, minutes, and seconds, you want to allocate resources for.

  3. Include the command parpool(<N>)in your Matlab program to start a pool of N workers. You don’t have to add requests for –ntasks as the get_SLURM_cluster.m will do that for you based on the parpool arguments.

Additional Options

You may wish to experiment with other options in order to accomplish your specific goals. If you need to submit jobs to a specific partition, or have certain memory requirements you can specify them as parameters in the get_SLURM_CLUSTER function.

Getting Help

For additional information on MATLAB, please visit the Mathworks help website. For any questions related specifically to using Parallel MATLAB on HPC, send an email to hpc@usc.edu.