A simple MPI program to compute the matrix matrix multiplication. Splitting the matrix A rowwise, and distribute it to different processes. Comparing the runtime using 1, 2 and 4 processors.
int i, j, k;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
res[i][j] = 0;
for (k = 0; k < N; k++)
res[i][j] += mat1[i][k] * mat2[k][j];
}
}
Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
CPU(s): 8
Thread(s) per core: 2
$ mpic++ main.cpp -o exc
$ mpirun -np 4 exc