I was trying to write a program for matrix vektor multiplication using MPI and C. Somehow it always gave me this error message when I was using the MPI_Barrier command:
======================================================================= = BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 4547 RUNNING AT localhost
= EXIT CODE: 11
= CLEANING UP REMAINING PROCESSES =========================================================================
I then deleted the MPI_Barrier command and to synchronize my processes I used the sleep() function, and it worked. I then figured my code is correct. Has anyone of you ever had a similar problem? I am very confused.
The whole code looks like this:
#include <stdio.h>
#include <stdlib.h>
#include "mpi.h"
#include <unistd.h>
int main (int argc, char **argv)
{
/* MPI Parameter */
int err;
int size, rank;
/* loop-parameters */
int i, j, p, m, l, k, t, v, w, d, z;
int r, q;
double **A_r;
double *x_q;
double *mybuf;
double *b_r;
/* Initialize MPI-Umgebung */
err = MPI_Init (&argc, &argv);
err = MPI_Comm_rank (MPI_COMM_WORLD, &rank);
err = MPI_Comm_size (MPI_COMM_WORLD, &size);
I skipped the irrelevant part here.
/* Output of each process */
for (p = 0; p < size; p++)
{
if (rank == p)
{
printf ("Prozess %d: A_r\n", p);
for (i = 0; i < r; i++)
{
for (j = 0; j < m; j++)
printf ("%4.2f ", A_r[i][j]);
printf ("\n");
}
printf ("\nProzess %d: x_q\n", p);
for (j = 0; j < q; j++)
printf ("%4.2f ", x_q[j]);
printf ("\n");
printf ("\nProzess %d: b_r\n", p);
for (i = 0; i < r; i++)
printf ("%4.2f ", b_r[i]);
printf ("\n\n\n");
}
MPI_Barrier(MPI_COMM_WORLD);
}
for (i = 0; i < r; i++)
free (A_r[i]);
free (A_r);
free (x_q);
free (mybuf);
free (b_r);
err = MPI_Finalize ();
return 0;
}
EDIT: Sorry I hope this is better now. The Thing is just before the last for loop if I put "//" before the MPI_Barrier, the programm works, but if I have it actually in my code it gives me the above mentioned error.