Logo Cineca Logo SCAI

You are here

Matrix-Matrix Moltiplication - Native mode (MKL)

 

Here you'll find a simple program to perform a matrix-matrix multilication using Intel MKL libraries

 First you have to load the correct compiler, the MKL library and fix the environment

module load intel (i.e. compiler suite)
module load mkl (if necessary – i.e. math libraries)
source $INTEL_HOME/bin/compilervars.sh intel64 (to set up the environment variables)

 

Now you can cross-compile the code for running on the MIC coprocessor:

Fortran: ifort mm.F90 -mkl=parallel -mmic -o mm.x

 

Now you have to enter, via ssh (see here) directly to the MIC reserved for you, and there you have to setup environment variables, also for MKL library

export LD_LIBRARY_PATH=/cineca/prod/compilers/intel/cs-xe-2013/binary/lib/mic:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/cineca/prod/compilers/intel/cs-xe-2013/binary/mkl/lib/mic:${LD_LIBRARY_PATH}

 

Finally you can run the programs.

 mm.x 4800
MKL Version
Matrix size is 4800
Check on a random element: 0.000000000000000E+000 1208.00009495612
Elapsed time 1.18075895309448 s
Gflops 187.323584903024

./mm.x 7200
MKL Version
Matrix size is 7200
Check on a random element: 2.273736754432321E-013 1777.11981771769
Elapsed time 3.36846899986267 s
Gflops 221.612845488688

./mm.x 9600
MKL Version
Matrix size is 9600
Check on a random element: 9.094947017729282E-013 2408.90806086537
Elapsed time 7.27939701080322 s
Gflops 243.079474491357