Child pages
  • Hyak MATLAB programming

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For interactive use of matlab:

ssh -X abc@hyakabc@mox.washingtonhyak.uw.edu

srun -p xyz -A xyz --nodes=1 --ntasks-per-node=28  --time=2:00:00 --mem=100G --pty /bin/bash

...

export TZ="America/Los_Angeles"

module load matlab_2015b2018a

matlab

After the above step, you can continue with your matlab commands at the matlab command line.

...

export TZ="America/Los_Angeles"

module load matlab_2015b2018a
matlab -nosplash -nodisplay -r myfunction

...

taskIDnumber = str2num(taskIDstring);

 

 



Matlab toolboxes on hyak:

...

export TZ="America/Los_Angeles"

module load matlab_2015b2018a
matlab -nosplash -nodisplay
At the matlab prompt enter below command to find the list of toolboxes:

...

Matlab parallel programming on hyak:

Do not use the build node for matlab parallel programming. The build node is for single core use. Hence, for the build node, the matlab command "feature('numcores')" will return 1.

For interactive use:

At the matlab prompt enter below command to start the parallel pool

...

(If your run parpool without giving the number of cores, then the default number of cores is 12. It is not the number of cores on the machine.

numCores above is the number of cores allocated to your job by slurm)


For scripting:

Below xyz is your group name and abc is your userid.

Add below lines to your slurm script before the matlab command. This creates a temporary directory which Matlab will use to store its cluster information.

mkdir -p /gscratch/xyz/abc/$SLURM_JOB_ID

 

The file trypar.m contains below code:. A semicolon after a matlab command means that matlab will not print the output of that command. (For the most common type of nodes on mox, numcores=28 assuming you had access to this node model type and needed the entire node. The argument should match what you request in your job for core count.


% create a local cluster object

myCluster = parcluster('local') ;

% Set the JobStorageLocation to the temporary directory that was created in your slurm script

myCluster.JobStorageLocation = strcat('/gscratch/xyz/abc/', getenv('SLURM_JOB_ID')) ;

numCores = feature('numcores');

parpool(numCores);

parfor i=1:1000000
A(i)=i*i;
end
A
quit

...

You can run trypar.m in parallel at the prompt of an hyak interactive node:

export TZ="America/Los_Angeles"

module load matlab_2015b 2018a
matlab -nodisplay -nosplash -r trypar

 


You can run trypar.m in parallel using below lines in your slurm script. Here xyz is the name of your group, abc is your userid, mydir is the directory which contains trypar.m and trypar.pbs.

 
export TZ="America/Los_Angeles"
module load matlab_2015b2018a
matlab -nodisplay -nosplash -r trypar

 


Matlab STDOUT, STDERR, STDIN

In fprintf( ), fileID=1 is for printing to STDOUT and fileID=2 is for printing to STDERR

See below for more information on fprintf():

https://www.mathworks.com/help/matlab/ref/fprintf.html

See below for more information on disp():

https://www.mathworks.com/help/matlab/ref/disp.html

Use below to get data from STDIN

x = input('', 's')

See below for more information on input():

https://www.mathworks.com/help/matlab/ref/input.html


Matlab Code Performance:

https://www.mathworks.com/help/matlab/code-performance.html

Matlab Memory Usage:

https://www.mathworks.com/help/matlab/memory.html

Matlab Java Memory Usage:

https://www.mathworks.com/help/matlab/matlab_external/java-heap-memory-preferences.html

 

 


======== Ignore below text. It is here for historical reasons. ===========

myCluster.NumWorkers = 28; 
saveProfile(myCluster);