I remember 2-3 months that this code and other variations would give me different results for rank and size, but now I'm lost, I don't understand what the issue could be.
Could be the upgrading to ubuntu 24.04 from 22.04? If yes, is there a way to resolve? I need to fix it as soon as possible because I need it for one of my course.
I was trying this simple program using MPI on my laptop (ubuntu 24.04LTS):
#include <mpi.h>
#include <stdio.h>
int 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);
printf("I'm processor %d of %d!\n", rank, size);
MPI_Finalize();
return 0;
}
In the terminal I wrote this:
mpicc nameOfMyFile.c
mpirun -n 4 ./a.out (I've also tried mpirun -np)
The output is the following:
I'm processor 0 of 1! I'm processor 0 of 1! I'm processor 0 of 1! I'm processor 0 of 1!
I've already tried to re-install MPICH and I checked the version in the terminal with: mpirun --version
HYDRA build details: Version: 4.2.0 Release Date: Fri Feb 9 12:29:21 CST 2024
This bug is tracked here: https://bugs.launchpad.net/ubuntu/+source/mpich/+bug/2072338
Unfortunately the fix is not propagated through package sources