Skip to content

Problem with MPI_Status conversion when C has 4-byte ints and Fortran has 8-byte INTEGERs #7918

@ahaichen

Description

@ahaichen

Open MPI version: 4.0.1

  • installed from source
  • build with: ./configure F77=gfortran FC=gfortran FFLAGS=-fdefault-integer-8 FCFLAGS=-fdefault-integer-8
  • Operating system: Linux version 4.9.0-12-amd64 ([email protected])
  • CPU: Intel(R) Xeon(R)

Hi all,

I get an issue when running in 64-bit MPI with the rank initialized 0, the code is

Program test
USE MPI_F08
IMPLICIT NONE

TYPE(MPI_Status)                            :: MPI_stat
Integer(kind=MPI_INTEGER_KIND) :: MPI_err
Integer(kind=MPI_INTEGER_KIND) :: MPI_id=0
Integer(kind=MPI_INTEGER_KIND) :: MPI_np
Integer                                              :: tempint,i_MPI

CALL MPI_Init(MPI_err)
CALL MPI_Comm_rank(MPI_COMM_WORLD,MPI_id,MPI_err)
CALL MPI_Comm_size(MPI_COMM_WORLD,MPI_np,MPI_err)

if(MPI_id==0) tempint=1
if(MPI_id/=0)  tempint=-1

write(*,*) 'MPI_np check1: MPI_id=',MPI_id,'MPI_np=',MPI_np,'tempint',tempint
if(MPI_id/=0) call MPI_Send(tempint,1,MPI_integer8,0,MPI_id,MPI_COMM_WORLD,MPI_err)
DO i_MPI=1,MPI_np-1
  if(MPI_id==0) call MPI_Recv(tempint,1,MPI_integer8,i_MPI,i_MPI,MPI_COMM_WORLD,MPI_stat,MPI_err)
ENDDO
write(*,*) 'MPI_np check2: MPI_id=',MPI_id,'MPI_np=',MPI_np,'tempint',tempint

CALL MPI_Finalize(MPI_err)
End program test

It is compiled with

mpifort -fdefault-integer-8 test.f90

run with

mpirun -np 3 ./a.out

the output for 3 threads will be

 MPI_np check1: MPI_id=                    0 MPI_np=                    3 tempint                    1
 MPI_np check1: MPI_id=                    2 MPI_np=                    3 tempint                   -1
 MPI_np check1: MPI_id=                    1 MPI_np=                    3 tempint                   -1
 MPI_np check2: MPI_id=                    1 MPI_np=                    3 tempint                   -1
 MPI_np check2: MPI_id=                    0 MPI_np=                    0 tempint                   -1
 MPI_np check2: MPI_id=                    2 MPI_np=                    3 tempint                   -1

It seems by giving "MPI_id=0", the "MPI_np" will turn to 0 (should be 3) on the rank 0 after a MPI_recv call.

MPI_np check2: MPI_id=                    0 MPI_np=                    0 tempint                   -1

I do not understand how does this happen. Does anyone have an idea on this issue? thanks a lot ~

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions