Logo Cineca Logo SCAI
MARCONI status
GALILEO100 status
Marconi100 status

You are here

Matrix-Matrix Moltiplication - Native mode (OpenMP)

Here you'll find two simple program to perform a matrix-matrix multilication using OpenMP directives.

 

First you have to load the correct compiler and fix the environment

module load intel (i.e. compiler suite)
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:

C: icc mm.c -openmp -mmic -o mm_C.x
Fortran: ifort mm.F90 -openmp -mmic -o mm_F.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

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

 

Finally you can run the programs, setting, the number of threads to use

export OMP_NUM_THREADS=240
./pi_C.x 1200
Open-MP version with threads = 240
Matrix size is 1200
Check on a random element: 5.684341886E-14
Elapsed time (s) = 0.063931

export OMP_NUM_THREADS=40
./pi_C.x 1200
Open-MP version with threads = 40
Matrix size is 1200
Check on a random element: 5.684341886E-14
Elapsed time (s) = 0.230866

 

 
export OMP_NUM_THREADS=120
./mm_F.x 2400
Open-MP version with threads = 120
Matrix size is 2400
Check on a random element: 5.684341886080801E-013 591.605984657262
Elapsed time 0.960820198059082 s
Gflops 28.7754150629334

export OMP_NUM_THREADS=30
/mm_F.x 2400
Open-MP version with threads = 30
Matrix size is 2400
Check on a random element: 5.684341886080801E-013 591.605984657262
Elapsed time 2.54440808296204 s
Gflops 10.8661814844630