Logo Cineca Logo SCAI
MARCONI status
GALILEO100 status
Marconi100 status

You are here

Matrix-Matrix Moltiplication - Native mode (MPI)

Here you'll find a program to perform a Matrix-Matrix multiplication using MPI : it works only using 2 Task.

 

First you have to load the correct compiler, the mpi library, fix the environment and enable MPI for MIC

module load intel (i.e. compiler suite)
module load intelmpi (i.e. mpi library)
source $INTEL_HOME/bin/compilervars.sh intel64 (to set up the environment variables)
export I_MPI_MIC=enable (to enable mpi on MIC)

 

Now you can cross-compile the code for running on the MIC coprocessor using mpicc for C programs and mpifc for fortran ones

Fortran: mpifc mm_mpi.F90  -mmic -o mm_mpi_F.x

 

Now you can run you job without entering the MIC coprocessor, but defining the MIC you are intended to run on, using the command mpirun.

 

mpirun.mic -host node021-mic0 -np 2 ./mm_mpi_F.x 2028
MPI version with task = 2
Matrix size is 2028
Check on a random element: 0.000000000000000E+000 511.852700478611
Elapsed time 20.0263540744781 s
Tot Gflops 0.832974961790926
All done...


If you want to split the two tasks onto two different MIC coprocessor you have to use the -perhost flag

mpirun.mic -host node021-mic0,host node021-mic1 -perhost 1 -np 2 ./mm_mpi_F.x 2028
MPI version with task = 2
Matrix size is 2028
Check on a random element: 0.000000000000000E+000 511.852700478611
Elapsed time 20.0265090465546 s
Tot Gflops 0.832968515941621
All done...