How do I use Matlab's Distributed Computing features?

Matlab Distributed Computing Server (MDCS) is installed for Matlab versions R2014a, R2015a, R2015b, R2016a, R2017a, R2018a and R2018b.

NOTE: the commands used to submit jobs has changed with R2017a. This page describes the commands for R2017a and later. See this guide for earlier versions.  

With this you can e.g. submit jobs directly to our job queue scheduler, without having to use slurm's commands directly. To do this login to the cluster's login node (e.g. with SSH (X-forwarding enabled), or perhaps more efficiently with Thinlinc (see our Thinlinc guide). 

When logged in you load the matlab module with e.g. "module load matlab/R2018b", and launch the GUI with just "matlab".

Begin by running the command "configCluster" in Matlab to choose a cluster configuration. Matlab will set up a configuration and will then print out some instructions. Follow them. 

A simple test case that can be run is the following:

>> configCluster
   [1] rackham
   [2] snowy
Select a cluster [1-2]: 1
>> c = parcluster('rackham');
>> c.AdditionalProperties.AccountName = 'snic2019-1-234';
>> c.AdditionalProperties.QueueName = 'node';
>> c.AdditionalProperties.WallTime = '00:10:00';
>> c.saveProfile
>> job = c.batch(@parallel_example, 1, {90, 5}, 'pool', 19)
>> job.wait
>> job.fetchOutputs{:}

where parallel_example.m is a file with the following matlab function:

function t = parallel_example(nLoopIters, sleepTime) 
  t0 = tic; 
  parfor idx = 1:nLoopIters 
    A(idx) = idx; 
  t = toc(t0); 

This will schedule a 20 tasks node-job (19 + 1) on Rackham under the given project (so you'll have to change this to your project name). For the moment jobs are hard coded to be node jobs. This means that if you request 21 tasks instead (20 + 1) you will get a 2 node job, but only 1 core will be used on the second node. In this case you'd obviously request 40 tasks (39 + 1) instead.

The second argument in the call to c.batch(), 1 in this example, is the number of output arguments expected from the function to be called. Function that returns no arguments needs a 0 here instead.

The curly brackets {90, 5} in the example contain the input arguments for the function to be called, in this example nLoopIters=90 and sleepTime=5.

To see the output to screen from jobs, use job.Tasks.Diary. Output from the submitted function is fetched with fetchOutputs().

For more information about Matlab's Distributed Computing features please see Matlab's HPC Portal.