here's a simple mpi program (I'm a beginner with it):
#include <stdio.h>
#include <mpi.h>
int main(int argc, char ** argv) {
int rank, size;
char name[80];
int length;
MPI_Init(&argc, &argv); // note that argc and argv are passed
// by address
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);
printf("size is: %d\n", size);
MPI_Get_processor_name(name,&length);
printf("Hello MPI: processor %d of %d on %s\n", rank,size,name);
MPI_Finalize();
}
I've compiled it with mpicc -o ex1 file.c but when I run it with mpirun -np 10 ./ex1 it doesn't create 10 process as expected. Infact, for ten times, it writes:
Hello MPI: processor 0 of 1 on lory-SVE1513Q1ESI
I don't know why the size variable is set with 1. I've tried to run it on a computer in my campus laboratory (ubuntu as mine) and it works correctly with:
Hello MPI: processor 0 of 10 on lory-SVE1513Q1ESI Hello MPI: processor 1 of 10 on lory-SVE1513Q1ESI Hello MPI: processor 2 of 10 on lory-SVE1513Q1ESI ...
what's the difference with my computer? :(