Skip to content

configury: test Fortran complex(real16) #13198

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config/ompi_fortran_check_iso_fortran_env_real16.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ end program]])],
[AS_VAR_SET(iso_fortran_env_var_real16, no)])
AC_LANG_POP([Fortran])
])
AS_VAR_IF(iso_fortran_env_var_real16, [yes],
[AC_MSG_CHECKING([if Fortran compiler supports complex(ISO_FORTRAN_ENV:REAL16)])
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program check_for_iso_fortran_env_real16
use, intrinsic :: iso_fortran_env
complex(REAL16) :: var
var = 12.34
end program]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_WARN([*** Fortran compiler supports real(REAL16) but])
AC_MSG_WARN([*** does *not* support complex(REAL16)])
AC_MSG_WARN([*** Disabling support for ISO_FORTRAN_ENV:REAL16])
Copy link
Member

Choose a reason for hiding this comment

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

Should we just create another type / plumb through complex(real16) such that we can support real16 and not support complex(real16)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeffhammond explained former PGI based NVHPC compiler won't support complex(REAL16), but the future is with flang (LLVM) based compilers.
I don't think this is worth the hassle unless there is a real use-case for that.
#13190 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

I saw @jeffhammond's comment, but I thought that that was exactly why we would want to do this. I.e., other compilers support REAL16 and support COMPLEX(REAL16). But the NV compiler doesn't -- and won't -- support REAL16 and COMPLEX(REAL16) -- it'll only support REAL16.

So if we test for both, and have proper test results for both, then we can handle any compiler that supports one or both. In reality, it'll only be the NV compiler that only supports one, but that's fine -- it's a generalized test.

Copy link
Member

Choose a reason for hiding this comment

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

We can just turn OMPI_HAVE_FORTRAN_COMPLEX32 off and the datatype and op code should deal with having REAL16 but not COMPLEX32.

Copy link
Member

Choose a reason for hiding this comment

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

But I'm fine with the solution proposed here, either you have both or none.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a quick grep and unless I missed something, this is only used in MPI_Sizeof().
So though it would be ideal to handle compilers (e.g. NVHPC) that support real(REAL16) but not complex(REAL16), I do not think this is worth the hassle and fixing compilation by disabling ISO_FORTRAN_ENV:REAL16 altogether is good enough for the time being.
Of course anyone is free to improve this PR.

Copy link
Member

Choose a reason for hiding this comment

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

It is also used in the datatype and in the MPI Op via OMPI_HAVE_FORTRAN_COMPLEX32. But I would be surprised if it had any users. For the outcome, I'm with you this PR is good enough.

AS_VAR_SET(iso_fortran_env_var_real16, no)])
AC_LANG_POP([Fortran])],
[])

AS_VAR_IF(iso_fortran_env_var_real16, [yes], [$1], [$2])
AS_VAR_POPDEF([iso_fortran_env_var_real16])
Expand Down