Skip to content

Commit 4b6390e

Browse files
authored
Merge pull request #10704 from drwootton/deprecate_mpi_sizeof
Implement warning for use of MPI_Sizeof in MPI 4.0 compliant OpenMPI
2 parents 2306f09 + 2505f9f commit 4b6390e

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

config/ompi_setup_mpi_fortran.m4

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dnl reserved.
1717
dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
1818
dnl Copyright (c) 2014-2021 Research Organization for Information Science
1919
dnl and Technology (RIST). All rights reserved.
20-
dnl Copyright (c) 2016 IBM Corporation. All rights reserved.
20+
dnl Copyright (c) 2016-2022 IBM Corporation. All rights reserved.
2121
dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2222
dnl Copyright (c) 2022 Triad National Security, LLC. All rights
2323
dnl reserved.
@@ -307,6 +307,38 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
307307
OMPI_FORTRAN_GET_KIND_VALUE([C_INT32_T], 9, [OMPI_FORTRAN_C_INT32_T_KIND])
308308
OMPI_FORTRAN_GET_KIND_VALUE([C_INT64_T], 18, [OMPI_FORTRAN_C_INT64_T_KIND])
309309

310+
#
311+
# See if "attributes deprecated" is supported
312+
# - False positives were seen with compilers like XL which will ignore
313+
# this option by default, but if the user specifies some options to
314+
# the wrapper compiler later it will fail to recognize the option.
315+
# - For now just limit this check to compilers that we know will work
316+
# This directive is only recognized, and works, for gfortran 11.0 and
317+
# later. As a result, this directive is generated only if the
318+
# Fortran compiler building Open MPI is gfortran 11.0 or later.
319+
OMPI_FORTRAN_HAVE_ATTR_DEPRECATED=0
320+
AS_IF([test $ompi_fortran_happy -eq 1],
321+
[AC_MSG_CHECKING([if Fortran compiler supports the deprecated attribute])
322+
AS_IF([test "$opal_cv_c_compiler_vendor" = "gnu"],
323+
[AC_LANG_PUSH([Fortran])
324+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program check_for_attr_deprecated
325+
!GCC$ ATTRIBUTES DEPRECATED :: x
326+
real*4 x
327+
x = 123.4
328+
print *,x
329+
end program]])],
330+
[OMPI_FORTRAN_HAVE_ATTR_DEPRECATED=1
331+
AC_MSG_RESULT([Yes])],
332+
[AC_MSG_RESULT([No])])
333+
AC_LANG_POP([Fortran])],
334+
[AC_MSG_RESULT([Unknown])])
335+
])
336+
AC_SUBST(OMPI_FORTRAN_HAVE_ATTR_DEPRECATED)
337+
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_ATTR_DEPRECATED,
338+
$OMPI_FORTRAN_HAVE_ATTR_DEPRECATED,
339+
[Whether the compiler supports Fortran ATTRIBUTES DEPRECATED or not])
340+
341+
310342
#--------------------------------------------------------
311343
# Fortran mpif.h MPI bindings
312344
#--------------------------------------------------------

ompi/include/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Copyright (c) 2014-2021 Research Organization for Information Science
1515
# and Technology (RIST). All rights reserved.
1616
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
17+
# Copyright (c) 2022 IBM Corporation. All rights reserved.
1718
# $COPYRIGHT$
1819
#
1920
# Additional copyrights may follow
@@ -91,7 +92,9 @@ mpif-sizeof.h:
9192
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
9293
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
9394
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
94-
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
95+
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32) \
96+
--mpi_version=$(MPI_VERSION) \
97+
--request_deprecate=$(OMPI_FORTRAN_HAVE_ATTR_DEPRECATED)
9598

9699
#
97100
# mpif-c-constants-decl.h, among other files, is generated based on some

ompi/mpi/fortran/base/gen-mpi-sizeof.pl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved.
44
# Copyright (c) 2015-2021 Research Organization for Information Science
55
# and Technology (RIST). All rights reserved.
6+
# Copyright (c) 2022 IBM Corporation. All rights reserved.
67
# $COPYRIGHT$
78
#
89
# Script to generate the overloaded MPI_SIZEOF interfaces and
@@ -39,6 +40,8 @@
3940
my $mpi_complex32;
4041
my $pmpi_arg;
4142
my $help_arg = 0;
43+
my $request_deprecate = 0;
44+
my $mpi_version = 0;
4245

4346
&Getopt::Long::Configure("bundling");
4447
my $ok = Getopt::Long::GetOptions("complex32=i" => \$mpi_complex32,
@@ -53,6 +56,8 @@
5356
"real16=i" => \$mpi_real16,
5457
"real2=i" => \$mpi_real2,
5558
"iso_real16=i" => \$mpi_iso_real16,
59+
"request_deprecate=i" => \$request_deprecate,
60+
"mpi_version=i" => \$mpi_version,
5661
"help|h" => \$help_arg);
5762

5863
die "Must specify header and/or impl filenames to output"
@@ -106,7 +111,13 @@ sub queue_sub {
106111
$subr->{start} = $start;
107112
$subr->{middle} = "${indent} size = storage_size(x) / 8
108113
${indent} ${optional_ierror_statement}ierror = 0";
109-
$subr->{end} = "${indent}END SUBROUTINE ^PREFIX^$sub_name^RANK^";
114+
if (($mpi_version >= 4) && ($request_deprecate == 1)) {
115+
$subr->{end} = "!GCC\$ ATTRIBUTES DEPRECATED :: ^PREFIX^$sub_name^RANK^\n";
116+
}
117+
else {
118+
$subr->{end} = "";
119+
}
120+
$subr->{end} .= "${indent}END SUBROUTINE ^PREFIX^$sub_name^RANK^";
110121

111122
# Save it in the overall hash
112123
$subs->{$sub_name} = $subr;

ompi/mpi/fortran/use-mpi-f08/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Copyright (c) 2019 Triad National Security, LLC. All rights
1515
# reserved.
1616
# Copyright (c) 2020 Sandia National Laboratories. All rights reserved.
17+
# Copyright (c) 2022 IBM Corporation. All rights reserved.
1718
#
1819
# $COPYRIGHT$
1920
#
@@ -79,7 +80,9 @@ sizeof_f08.h:
7980
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
8081
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
8182
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
82-
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
83+
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32) \
84+
--mpi_version=$(MPI_VERSION) \
85+
--request_deprecate=$(OMPI_FORTRAN_HAVE_ATTR_DEPRECATED)
8386

8487
sizeof_f08.f90: $(top_builddir)/config.status
8588
sizeof_f08.f90: $(sizeof_pl)

ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Copyright (c) 2016 IBM Corporation. All rights reserved.
77
#
88
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
9+
# Copyright (c) 2022 IBM Corporation. All rights reserved.
910
# $COPYRIGHT$
1011
#
1112
# Additional copyrights may follow
@@ -105,7 +106,9 @@ mpi-ignore-tkr-sizeof.h:
105106
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
106107
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
107108
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
108-
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
109+
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32) \
110+
--mpi_version=$(MPI_VERSION) \
111+
--request_deprecate=$(OMPI_FORTRAN_HAVE_ATTR_DEPRECATED)
109112

110113
mpi-ignore-tkr-sizeof.f90: $(top_builddir)/config.status
111114
mpi-ignore-tkr-sizeof.f90: $(sizeof_pl)

ompi/mpi/fortran/use-mpi-tkr/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# reserved.
1616
# Copyright (c) 2014-2021 Research Organization for Information Science
1717
# and Technology (RIST). All rights reserved.
18-
# Copyright (c) 2016 IBM Corporation. All rights reserved.
18+
# Copyright (c) 2016-2022 IBM Corporation. All rights reserved.
1919
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2020
# $COPYRIGHT$
2121
#
@@ -136,7 +136,9 @@ mpi-tkr-sizeof.h:
136136
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
137137
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
138138
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
139-
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
139+
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32) \
140+
--mpi_version=$(MPI_VERSION) \
141+
--request_deprecate=$(OMPI_FORTRAN_HAVE_ATTR_DEPRECATED)
140142

141143
mpi-tkr-sizeof.f90: $(top_builddir)/config.status
142144
mpi-tkr-sizeof.f90: $(sizeof_pl)

0 commit comments

Comments
 (0)