This lesson is being piloted (Beta version)

High Performance Computing with MATLAB: Glossary

Key Points

Introduction to HPC in MATLAB
  • High-Performance Computing is all about expediting the computations.

  • MATLAB offers several in-built functions to exploit the various HPC architectures, for example: multi-threads, multi-cores and GPUs, available today.

  • MATLAB Parallel Computing Toolbox requires significantly less effort when compared with parallelisation in C, C++ and Fortran. But it comes at the cost of lower computing speeds.

Running MATLAB on Sunbird
  • Use ssh -Y uname@sunbird.swansea.ac.uk to access Sunbird HPC machine.

  • Use module load matlab/2019a to load MATLAB software on Sunbird.

  • Use matlab -nosplash -nodesktop -nodisplay -r "run(matlabtest.m); quit;" to run matlab script matlabtest.m from command line.

Vectorization
  • Vectorization in MATLAB is about replacing loops with appropriate array operations.

  • Vectorized code runs much faster than the code with loops.

  • Vectorization is concise and makes the code easier to understand and debug.

MATLAB Parallel Computing Toolbox
  • MATLAB Parallel Computing Toolbox supports us in parallelising our MATLAB code to take the advantage of multiple CPUs and GPUs.

  • MATLAB Parallel Server manages licenses, offloads jobs to HPC machines manages communication on HPC machines.

parfor
  • parfor-loop is the parallel version of the standard for-loop in MATLAB.

  • parfor-loop distributes the iterations among the workers in the parallel loop.

  • An understanding of array-slicing rules is important when working with arrays in parfor-loop.

  • Always parallel the outermost for-loop, unless you have a justifiable reason to parallel the inner for-loops

  • Direct nesting of parfor-loops is not supported in MATLAB

spmd
  • spmd offers a more flexible environment for parallel programming when compared with parfor.

  • All the workers in the pool execute the statements inside the spmd block.

  • Understanding of distributed arrays is essential for successfully developing parallel programs in MATLAB.

Profiling to improve performance
  • Always profile the code before working on optimisations for performance.

  • Use a minimalistic data set while profiling the code.

  • Choose between profiling the whole code or a block of code.

mpiprofile
  • Always profile your code before working on optimisations for performance.

  • Use a minimalistic data set while profiling your code.

  • Understanding communication pattern is key to understanding parallelisation.

  • Check communication and waiting times of each participating worker to identify potential bottlenecks and critical paths.

Summary

Glossary

MATLAB
MATrix LABoratory
HPC
High-Performance Computing