Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark mpif.h as deprecated #13123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

devreal
Copy link
Contributor

@devreal devreal commented Mar 5, 2025

MPI 4.1 deprecated mpif.h so we may want to start warning about it. Unfortunately, Fortran does not provide a standardized pre-processor so we're at the mercy of the compiler to print the warning. This patch enables the warning by default but allows it to be disabled through --disable-deprecate-mpif-h passed to configure.

flang-new prints the warning correctly:

flang-new -I$HOME/opt/openmpi-main/include deprecated.F -c
/Users/joseph/opt/openmpi-main/include/mpif.h:56:2: warning: #warning mpif.h is deprecated since MPI 4.1. Refer to MPI Sec. 19.1.4.
  #warning mpif.h is deprecated since MPI 4.1. Refer to MPI Sec. 19.1.4.
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./deprecated.F:4:1: warning: included here
          include 'mpif.h'
  ^^^^^^^^^^^^^^^^^^^^^^^^

gfortran doesn't:

gfortran -I$HOME/opt/openmpi-main/include deprecated.F -c
mpif.h:56:2:

Warning: Illegal preprocessor directive

Unless the include file that contains the warning in the same directory as the file being compiled so that it is not found through the include path:

cp ~/opt/openmpi-main/include/mpif* .
gfortran deprecated.F -c
mpif.h:56:2:

   56 | #warning mpif.h is deprecated since MPI 4.1. Refer to MPI Sec. 19.1.4.
      |  1
Warning: Illegal preprocessor directive

The file I used for testing:

cat deprecated.F

      program main
        implicit none
        include 'mpif.h'
        integer :: ierror
        call MPI_INIT(ierror)
        call MPI_FINALIZE(ierror)
      end program main

So in the end gfortran spoils the fun here. Maybe the compiler wrapper could copy a file that contains the warning and is included by mpif.h but that is more time than I have right now. Putting this out here in case someone has a smarter idea for how to do it.

Fixes #12190.

@jeffhammond
Copy link
Contributor

i guess you can enable this when flang-new is used.

@devreal
Copy link
Contributor Author

devreal commented Mar 11, 2025

I reworked this patch so that we capture the compiler output and check that it contains the warning we expect. I'm not sure that my m4 is correct so please check. Verified that the warning is enabled with flang-new and disabled with gfortran (which does not print the warning if the include file is in a separate directory).

@devreal
Copy link
Contributor Author

devreal commented Mar 11, 2025

@janjust Looks like the NVIDIA CI is out of disk space

@janjust
Copy link
Contributor

janjust commented Mar 11, 2025

@janjust Looks like the NVIDIA CI is out of disk space

we're checking

jsquyres
jsquyres previously approved these changes Mar 12, 2025
Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I made a suggestion on the exact deprecation message.

@devreal
Copy link
Contributor Author

devreal commented Mar 12, 2025

Thanks @jsquyres! Once approved, I will squash everything down to one commit.

jsquyres
jsquyres previously approved these changes Mar 13, 2025
MPI 4.1 has deprecated mpif.h. We add a `#warning` directive that
may be interpreted correctly if the Fortran compiler uses a C-style
preprocessor or generate a warning about a illegal directive, showing
the warning anyway:

```
    1 | #warning mpif.h is deprecated since MPI 4.1. Refer to MPI Sec. 19.1.4.
      |  1
Error: Illegal preprocessor directive [-Werror]
```

Also adds flang and flang-new to the list of known Fortran compilers.

Signed-off-by: Joseph Schuchart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MPI 4.1 - mpif.h is deprecated
4 participants