[mpich-discuss] [EXTERNAL] Re: MPI_alloc_mem call code compiles with Open MPI, not MPICH

Zhou, Hui zhouh at anl.gov
Fri Sep 22 11:11:08 CDT 2023


I created issue https://github.com/pmodels/mpich/issues/6691 to track this issue.

Hui
________________________________
From: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] <matthew.thompson at nasa.gov>
Sent: Friday, September 22, 2023 11:02 AM
To: Zhou, Hui <zhouh at anl.gov>; discuss at mpich.org <discuss at mpich.org>
Subject: Re: [EXTERNAL] Re: MPI_alloc_mem call code compiles with Open MPI, not MPICH


Hui,



The option flag doesn't seem to help:



$ mpifort -fallow-argument-mismatch support_for_mpi_alloc_mem_cptr.F90

support_for_mpi_alloc_mem_cptr.F90:9:53:



    9 |    call MPI_Alloc_mem(sz, MPI_INFO_NULL, ptr, ierror)

      |                                                     1

Error: Type mismatch in argument 'baseptr' at (1); passed TYPE(c_ptr) to INTEGER(8)



I did test and, yes, mpi_f08 does let it work. I think the issue is I'm not sure the library this is in can assume mpi_f08 support for all supported compilers.



For example, I know NAG + Open MPI does not build mpi_f08. I haven't tried NAG + MPICH...if that does support it, maybe we could move there?



I did look around online, and the MPI Forum does sort of say my code should be supported:



https://www.mpi-forum.org/docs/mpi-3.1/mpi31-report/node216.htm



"If the Fortran compiler provides TYPE(C_PTR), then the following generic interface must be provided in the mpi module and should be provided in mpif.h through overloading, i.e., with the same routine name as the routine with INTEGER(KIND=MPI_ADDRESS_KIND) BASEPTR, but with a different specific procedure name

...

The base procedure name of this overloaded function is MPI_ALLOC_MEM_CPTR"



If I look at the Open MPI source code, I do see "MPI_alloc_mem_cptr" there:



https://github.com/open-mpi/ompi/blob/main/ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-interfaces.h.in#L207



but not in MPICH's.



Now, I tried changing it to use MPI_ADDRESS_KIND like on the page above (thinking maybe that was it) but:



$ cat support_for_mpi_alloc_mem_cptr.address_kind.F90

program main

   use mpi

   use iso_c_binding, only: C_PTR



   integer(kind=MPI_ADDRESS_KIND) :: sz

   type (c_ptr) :: ptr



   call MPI_Alloc_mem(sz, MPI_INFO_NULL, ptr, ierror)



end program main



$ mpifort support_for_mpi_alloc_mem_cptr.address_kind.F90

support_for_mpi_alloc_mem_cptr.address_kind.F90:8:53:



    8 |    call MPI_Alloc_mem(sz, MPI_INFO_NULL, ptr, ierror)

      |                                                     1

Error: Type mismatch in argument 'baseptr' at (1); passed TYPE(c_ptr) to INTEGER(8)



Matt

--

Matt Thompson, SSAI, Sr Scientific Programmer/Analyst

NASA GSFC,    Global Modeling and Assimilation Office

Code 610.1,  8800 Greenbelt Rd,  Greenbelt,  MD 20771

Phone: 301-614-6712                 Fax: 301-614-6246

http://science.gsfc.nasa.gov/sed/bio/matthew.thompson



From: "Zhou, Hui" <zhouh at anl.gov>
Date: Friday, September 22, 2023 at 11:29 AM
To: "discuss at mpich.org" <discuss at mpich.org>
Cc: "Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC]" <matthew.thompson at nasa.gov>
Subject: [EXTERNAL] Re: MPI_alloc_mem call code compiles with Open MPI, not MPICH



Hi Matt,



Are you able to test `use mpi_f08` instead? We'll open an issue to track this for "use mpi". In the meantime, you may be able to bypass this issue by adding the `-fallow-argument-mismatch flag to mpifort​.



Hui

________________________________

From: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] via discuss <discuss at mpich.org>
Sent: Friday, September 22, 2023 9:11 AM
To: discuss at mpich.org <discuss at mpich.org>
Cc: Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] <matthew.thompson at nasa.gov>
Subject: [mpich-discuss] MPI_alloc_mem call code compiles with Open MPI, not MPICH



All,



I'm sort of new to MPICH and I'm encountering one call that works with Open MPI but not MPICH. As such, I'm wondering if I built MPICH incorrectly or incompletely (always easy to miss a configure flag!).



To wit, I have a code like:



program main

   use mpi

   use iso_fortran_env, only: INT64

   use iso_c_binding, only: C_PTR



   integer(kind=INT64) :: sz

   type (c_ptr) :: ptr



   call MPI_Alloc_mem(sz, MPI_INFO_NULL, ptr, ierror)



end program main



If I compile with GCC 12.1 + Open MPI 4.1.3, all is well:



$ mpifort --showme:version

mpifort: Open MPI 4.1.3 (Language: Fortran)

mathomp4 at discover23 ~/MPITests/CPtr master ?25

$ mpifort support_for_mpi_alloc_mem_cptr.F90

mathomp4 at discover23 ~/MPITests/CPtr master ?25

$ echo $?

0



I'll also say Intel MPI builds this code as well.



But with MPICH 4.1.2 I just built:



$ mpifort support_for_mpi_alloc_mem_cptr.F90

support_for_mpi_alloc_mem_cptr.F90:9:53:



    9 |    call MPI_Alloc_mem(sz, MPI_INFO_NULL, ptr, ierror)

      |                                                     1

Error: Type mismatch in argument 'baseptr' at (1); passed TYPE(c_ptr) to INTEGER(8)



Now, my configure lines to Open MPI and MPICH are pretty boring, so the resulting mpiforts are as well:



$ mpifort -show

gfortran -I/discover/swdev/gmao_SIteam/MPI/openmpi/4.1.3/gcc-12.1.0/include -pthread -I/discover/swdev/gmao_SIteam/MPI/openmpi/4.1.3/gcc-12.1.0/lib -L/discover/swdev/gmao_SIteam/MPI/openmpi/4.1.3/gcc-12.1.0/lib -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi



$ mpifort -show

gfortran -I/discover/swdev/gmao_SIteam/MPI/mpich/4.1.2/gcc-12.1.0/include -I/discover/swdev/gmao_SIteam/MPI/mpich/4.1.2/gcc-12.1.0/include -L/discover/swdev/gmao_SIteam/MPI/mpich/4.1.2/gcc-12.1.0/lib -lmpifort -Wl,-rpath -Wl,/discover/swdev/gmao_SIteam/MPI/mpich/4.1.2/gcc-12.1.0/lib -Wl,--enable-new-dtags -lmpi



But I see Open MPI has that "mpi_usempi_ignore_tkr", is it possible that's what is doing it?



Perhaps we just need to recode the code (using transfer, etc?)



Thanks for any help,

Matt

--

Matt Thompson, SSAI, Sr Scientific Programmer/Analyst

NASA GSFC,    Global Modeling and Assimilation Office

Code 610.1,  8800 Greenbelt Rd,  Greenbelt,  MD 20771

Phone: 301-614-6712                 Fax: 301-614-6246

http://science.gsfc.nasa.gov/sed/bio/matthew.thompson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20230922/bea3a64d/attachment-0001.html>


More information about the discuss mailing list