This is the simple MPI program:
#include <stdio.h>
#include <mpi.h>
main(int argc, char ** argv)
{
int rank,size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if(rank==0)
{
printf("Hello world, I'm process %d of %d and I'm the boss\n",rank,size);}
else{
printf("Hello world, I'm process %d of %d\n",rank,size);
}
MPI_Finalize();
}
THIS IS THE SAME EXACT CODE THE TEACHER USED!
Here are the results I got compiling with:
mpicc hello.c -o hellompi
mpirun -np 8 ./hellompi
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Hello world, I'm process 0 of 1 and I'm the boss
Obviously the right code produces:
Hello world, I'm process 0 of 7 and I'm the boss
Hello world, I'm process 1 of 7
Hello world, I'm process 2 of 7
Hello world, I'm process 3 of 7
Hello world, I'm process 4 of 7
Hello world, I'm process 5 of 7
Hello world, I'm process 6 of 7
Hello world, I'm process 7 of 7
So obviously I need to uninstall OpenMPI, MPI then just install the right MPI... How do i do this?
Oh and yes this is what I get when I run:
cat /proc/cpuinfo | grep processor
processor :0
processor :1
processor :2
processor :3
processor :4
processor :5
processor :6
processor :7
plus i never get anything different even if when i mpirun -np 2
so i sudo apt-get remove mpi
then it looks like it uninstalls but then i run
mpichversion
and still get a version 3.0.1