Why Is MPI_COMM_RANK Not Working Correctly on Mac OSX?

  • Fortran
  • Thread starter natski
  • Start date
  • Tags
    Fortran Mac
In summary, the speaker is having trouble running a Fortran code with mpi on a Mac. They followed a guide for installation and are trying to run a simple "hello world" code. However, when executed, the code is not parallelizing correctly and the speaker is seeking advice on how to fix this issue. They have noticed that the code is running four parallel versions, but the rank being returned by MPI_COMM_RANK seems to be the problem. They are wondering if this is a common issue for Macs.
  • #1
natski
267
2
Hi all,

I have been running mpi fortran code on Linux based systems without any trouble for some time but making the same code run on a Mac is causing me some headaches. I installed mpi using the guide at: http://www.macresearch.org/compiling-mpi-f90-support-snow-leopard

I am trying to run some simple "hello world" code:

! Fortran example
program hello
include 'mpif.h'
integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)

call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
print*, 'node', rank, ': Hello world'
call MPI_FINALIZE(ierror)
end

Compiling with mpif90 -o mpihello mpihello.f90 and then executing with mpirun -np 4 mpihello I get...

node 0 : Hello world
node 0 : Hello world
node 0 : Hello world
node 0 : Hello world

So essentially I am calling node 0 four times rather than actually parallelizing anything. Has anyone else encountered this problem? The same code runs fine on Linux FYI. Any tips/suggestions would be extremely appreciated!

Natski
 
Technology news on Phys.org
  • #2
By looping the inner code and re-running I notice in Activity Monitor that four parallel versions of the code are in fact running. So this seems simply something wrong with the rank being returned by MPI_COMM_RANK - is this a normal issue for Macs?
 

FAQ: Why Is MPI_COMM_RANK Not Working Correctly on Mac OSX?

1. Can I run MPI Fortran on Mac OSX?

Yes, it is possible to run MPI Fortran on Mac OSX. However, it requires the installation of a third-party MPI implementation, such as Open MPI or MPICH.

2. How do I install MPI Fortran on Mac OSX?

To install MPI Fortran on Mac OSX, you will need to first install a third-party MPI implementation. This can be done through a package manager, such as Homebrew or MacPorts, or by downloading and compiling the source code. Once the MPI implementation is installed, you can then compile and run your Fortran code with the appropriate MPI compiler commands.

3. Can I use any MPI implementation on Mac OSX?

While there are several MPI implementations available for Mac OSX, not all of them may be compatible with your specific system and compiler. It is important to research and choose an MPI implementation that is compatible with your system and meets your specific needs.

4. Are there any limitations to running MPI Fortran on Mac OSX?

There are a few limitations to be aware of when running MPI Fortran on Mac OSX. One limitation is that Mac OSX does not support shared memory communication, so all communication between processes must be done through the network. Additionally, some MPI implementations may have limited support for certain features or optimizations on Mac OSX.

5. Can I use multiple MPI implementations on Mac OSX?

Yes, it is possible to use multiple MPI implementations on Mac OSX. This can be useful for comparing performance or using different features from different implementations. However, it is important to carefully manage and configure your system so that the different implementations do not conflict with each other.

Similar threads

Replies
5
Views
1K
Replies
12
Views
6K
Replies
1
Views
2K
Replies
12
Views
3K
Replies
1
Views
2K
Replies
54
Views
4K
Replies
2
Views
3K
Back
Top