User Tools

Site Tools


matlab

Matlab

Matlab is a matrix-oriented computing language. UA/Fayetteville has a campus-wide license. We have permission from Mathworks to serve this program to in-state users but not to users outside of Arkansas who are not affiliated with UAF.

The GUI version of Matlab is best accessed via interactive batch job on OpenOnDemand (pinnacle-portal). The text version may be accessed via batch job or interactive batch job with terminal.

Usually the latest installed version is the best, though multiple older versions are installed.

module load matlab/r2022a
Benchmarks

Matlab in recent years has recently added a number of modern features such as GPU support, big data analysis and machine learning. A simple benchmark follows for CPU vs GPU code to find the eigenvalues of a fairly large matrix.

$ cat eigcpu.m
a=rand(32768,32768);
b=zeros(size(a));
tic;
b = eig(a);
toc;
$ matlab -nodesktop -nosplash < eigcpu.m

This requires about 2700 sec on 32-core Intel nodes and 5300 sec on 64-core AMD nodes. Matlab matrix functions make extensive use of Intel MKL and are often more performant on Intel systems. To what degree that is deliberate on the part of Intel is disputed. Also Intel AVX512 functions not present on AMD may be significant. With an older version of Matlab and MKL, that time on AMD is reduced to 4400 sec.

module load mkl/19.0.5 matlab/R2019b

Matlab doesn't use module-loaded MKL (it has its own copy) but mkl versions < 20 on AMD in our module set this environment variable, see https://www.mathworks.com/matlabcentral/answers/330889-does-matlab-perform-well-on-amd-ryzen

MKL_DEBUG_CPU_TYPE=5

which improves the performance on AMD of MKL versions less than 20, which correspond to Matlab versions less than 2020.

GPU computing

The GPU version is selected in code, commands are the same. Initializing the first array as gpuArray is sufficient to use the available GPU functions, see https://www.mathworks.com/help/parallel-computing/gpu-computing-in-matlab.html GPU and CPU multithreading are much more effective on functions such as eig() than in serial Matlab code, which mostly requires changes such as parfor() for speedup.

$ cat eiggpu.m
a=gpuArray(rand(32768,32768));
b=zeros(size(a));
tic;
b = eig(a);
toc;
$ matlab -nodesktop -nosplash < eiggpu.m

This requires about 850 seconds on V100 gpu nodes and 700 seconds on A100 single gpu nodes.

Parallel Computing

Matlab has several forms of parallel computing. Many functions are multithreaded. Many matrix functions are implemented in Intel MKL which is also multithreaded. Explicit parallel computing is available with parallel toolbox/parallel server, see https://www.nrel.gov/hpc/eagle-software-matlab-pct.html for an example on a similarly-configured cluster. The configuration is simpler on a single node (to Matlab, parallel toolbox or the local cluster) as in the NREL example.

See also https://www.cs.usask.ca/~spiteri/CMPT851/notes/parallelMatlab.pdf

https://research.unsw.edu.au/document/UNSW_Parallel%20Computing%20with%20MATLAB.pdf

https://www.hpc.iastate.edu/guides/using-matlab-parallel-server

matlab.txt · Last modified: 2022/06/05 19:44 by root