wiki:cypress/RunningMATLABwithXeonPhi

Version 1 (modified by fuji, 8 days ago) ( diff )

--

Running MATLAB with Automatic Offload

This feature is no longer available since MATLAB R2020a.

Internally, MATLAB uses Intel MKL Basic Linear Algebra Subroutines (BLAS) and Linear Algebra package (LAPACK) routines to perform the underlying computations when running on Intel processors.

Intel MKL includes the Automatic Offload (AO) feature that enables computationally intensive Intel MKL functions to offload partial workload to attached Intel Xeon Phi coprocessors automatically and transparently.

As a result, MATLAB performance can benefit from Intel Xeon Phi coprocessors via the Intel MKL AO feature when problem sizes are large enough to amortize the cost of transferring data to the coprocessors.

In SLURM script, make sure that option --gres=mic:1 is set and intel-psxe module as well as the MATLAB module has been loaded.

#!/bin/bash
#SBATCH --qos=normal            # Quality of Service
#SBATCH --job-name=matlabAO     # Job Name
#SBATCH --time=1:00:00          # WallTime
#SBATCH --nodes=1               # Number of Nodes
#SBATCH --ntasks-per-node=1     # Number of tasks (MPI processes)
#SBATCH --cpus-per-task=1       # Number of threads per task (OMP threads)
#SBATCH --gres=mic:1            # Number of Co-Processors

module load matlab
module load intel-psxe

export MKL_MIC_ENABLE=1
matlab  -nodesktop -nodisplay -nosplash -r "MatTest; exit;"

Note that

export MKL_MIC_ENABLE=1

enables Intel MKL Automatic Offload (AO).

The sample code is below:

%
% Matrix test "MatTest.m"
%
A = rand(10000, 10000);
B = rand(10000, 10000);
tic;
C = A * B;
realT = toc;
fprintf('Real Time = %f(sec)\n',realT);

See https://wiki.hpc.tulane.edu/trac/wiki/cypress/Matlab#CompiledMatlab

#!/bin/bash
#SBATCH --qos=normal            # Quality of Service
#SBATCH --job-name=matlabAO     # Job Name
#SBATCH --time=1:00:00          # WallTime
#SBATCH --nodes=1               # Number of Nodes
#SBATCH --ntasks-per-node=1     # Number of tasks (MPI processes)
#SBATCH --cpus-per-task=1       # Number of threads per task (OMP threads)
#SBATCH --gres=mic:1            # Number of Co-Processors

module load matlab
module load intel-psxe
mcc -m MatTest.m
export MKL_MIC_ENABLE=1
./MatTest

To generate the offload report at run time,

export OFFLOAD_REPORT=2
  • Setting OFFLOAD_REPORT to 0 (or not setting it) results in no offload report.
  • Setting OFFLOAD_REPORT to 1 results in a report including:
    • Name of function called
    • Effective Work Division
    • Time spent on Host during call
    • Time spent on each available Phi coprocessor during the call
  • Setting OFFLOAD_REPORT to 2 results in a report including everything from 1, and in addition:
    • Amount of data transferred to and from each Phi during call
Note: See TracWiki for help on using the wiki.