So I'm trying to parallelize a Fortran 2003 program I have using MPI. I run it on node of 16 processor cores with 64Gb of shared memory. The 16 ranks within my MPI communicator have to apply some algorithm to part of a rather large array (about 6000 by 8000 elements, double precision).
Right now, I use MPI_BCAST to send copies of this array from the root rank to the other 15 ranks, which takes a lot of time. The big array is read-only so I figured it'd be faster to make it open to reading by all ranks using MPI_win_allocate_shared and just pass the win object. Since it is a shared-memory node, this should work fine. (All based on the explanation I found in an answer to this topic: MPI Fortran code: how to share data on node via openMP?)
However, when I try to compile the program, I get the following error message:
Undefined symbols for architecture x86_64:
"_mpi_win_allocate_shared_", referenced from:
___lakefinder_parallel_mpi_nam_module3_MOD_fill_sea_master in lakefinder_parallel_mpi_nam_module3.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
Not a clue why, since the program uses several other MPI commands (MPI_INIT, MPI_SEND, MPI_BCAST, etc.) and it works fine with those.
Any ideas?
Here's the basic code I have (only the relevant pieces, it's part of a large climate model which I won't bother you with):
PROGRAM Main_program
USE mpi
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_F_POINTER
USE configuration_main_module, only: dp ! 8-byte float
IMPLICIT NONE
REAL(dp), DIMENSION(6000,8000) :: data_array
INTEGER :: ierr, rank, size, win, disp_unit
INTEGER(KIND=MPI_ADDRESS_KIND) :: windowsize
TYPE(C_PTR) :: baseptr
! Split program into ranks
CALL MPI_INIT(ierr)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
CALL MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
! Open up a lot of space for the root rank and nothing for the others
IF (rank==0) THEN
windowsize = 6000*8000*8_MPI_ADDRESS_KIND
ELSE
windowsize = 0
END IF
disp_unit = 1
CALL MPI_Win_allocate_shared(windowsize, disp_unit, MPI_INFO_NULL, MPI_COMM_WORLD, baseptr, win, ierr)
CALL MPI_FINALIZE(ierr)
END PROGRAM Main_program
MPI_WIN_ALLOCATE_SHAREDis part of MPI-3.0. You need an implementation that covers that version of the standard or later. - Hristo Ilieviso_c_bindingwas defined much later in Fortran 2003. - jlokimlin