diff --git a/config/ompi_fortran_get_alignment.m4 b/config/ompi_fortran_get_alignment.m4 index 824b6756f16..9ccca2a22fb 100644 --- a/config/ompi_fortran_get_alignment.m4 +++ b/config/ompi_fortran_get_alignment.m4 @@ -10,6 +10,8 @@ dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, dnl University of Stuttgart. All rights reserved. dnl Copyright (c) 2004-2005 The Regents of the University of California. dnl All rights reserved. +dnl Copyright (c) 2025 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. dnl Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved. dnl $COPYRIGHT$ dnl @@ -178,3 +180,41 @@ end program]])], AS_VAR_COPY([$2], [type_var]) AS_VAR_POPDEF([type_var])dnl ])dnl + +# OMPI_FORTRAN_GET_COMMON_ALIGNMENT(variable to set) +# ------------------------------------------ +AC_DEFUN([OMPI_FORTRAN_GET_COMMON_ALIGNMENT],[ + AS_IF([test $OMPI_TRY_FORTRAN_BINDINGS -gt $OMPI_FORTRAN_NO_BINDINGS], + [AC_CACHE_CHECK([alignment of Fortran common], ompi_cv_fortran_common_alignment, + [AC_LANG_PUSH([Fortran]) + AC_LINK_IFELSE([AC_LANG_SOURCE([[ program falignment + CHARACTER A,B + COMMON /AA/A + COMMON /BB/B + OPEN(UNIT=10, FILE="conftestval") + if (LOC(A) > LOC(B)) then + write (10,'(I5)') LOC(A)-LOC(B) + else + write (10,'(I5)') LOC(B)-LOC(A) + endif + CLOSE(10) + +end program]])], + [AS_IF([test "$cross_compiling" = "yes"], + [AC_MSG_ERROR([Can not determine common alignment when cross-compiling])], + [OPAL_LOG_COMMAND([./conftest], + [AS_VAR_SET(ompi_cv_fortran_common_alignment, [`cat conftestval`])], + [AC_MSG_ERROR([Could not determine common alignment])])])], + + [AC_MSG_WARN([Could not determine common alignment]) + AC_MSG_WARN([See config.log for details]) + AC_MSG_ERROR([Cannot continue])]) + rm -rf conftest* *.mod 2> /dev/null + AC_LANG_POP([Fortran])]) + + AS_VAR_COPY([$1], [ompi_cv_fortran_common_alignment])], + [AC_MSG_CHECKING([Fortran common alignment]) + $1=0 + AC_MSG_RESULT([skipped])]) + +])dnl diff --git a/config/ompi_setup_mpi_fortran.m4 b/config/ompi_setup_mpi_fortran.m4 index 0fe0b333ebf..8e2da80bc99 100644 --- a/config/ompi_setup_mpi_fortran.m4 +++ b/config/ompi_setup_mpi_fortran.m4 @@ -15,7 +15,7 @@ dnl Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved. dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights dnl reserved. dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. -dnl Copyright (c) 2014-2021 Research Organization for Information Science +dnl Copyright (c) 2014-2025 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. dnl Copyright (c) 2016-2022 IBM Corporation. All rights reserved. dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. @@ -142,6 +142,8 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[ OMPI_FORTRAN_IKINDS= OMPI_FORTRAN_RKINDS= OMPI_FORTRAN_CKINDS= + OMPI_FORTRAN_GET_COMMON_ALIGNMENT([OMPI_FORTRAN_COMMON_ALIGNMENT]) + AC_SUBST([OMPI_FORTRAN_COMMON_ALIGNMENT]) # We want to set the #define's for all of these, so invoke the macros # regardless of whether we have F77 support or not. diff --git a/ompi/include/Makefile.am b/ompi/include/Makefile.am index 9b052b94920..5a27d1b68bd 100644 --- a/ompi/include/Makefile.am +++ b/ompi/include/Makefile.am @@ -11,7 +11,7 @@ # All rights reserved. # Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved. -# Copyright (c) 2014-2021 Research Organization for Information Science +# Copyright (c) 2014-2025 Research Organization for Information Science # and Technology (RIST). All rights reserved. # Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. # Copyright (c) 2022 IBM Corporation. All rights reserved. @@ -110,7 +110,10 @@ mpif-c-constants-decl.h: --caps $(OMPI_FORTRAN_CAPS) \ --plain $(OMPI_FORTRAN_PLAIN) \ --single $(OMPI_FORTRAN_SINGLE_UNDERSCORE) \ - --double $(OMPI_FORTRAN_DOUBLE_UNDERSCORE) + --double $(OMPI_FORTRAN_DOUBLE_UNDERSCORE) \ + --status-size $(OMPI_FORTRAN_STATUS_SIZE) \ + --align $(OMPI_FORTRAN_COMMON_ALIGNMENT) + if WANT_INSTALL_HEADERS ompidir = $(ompiincludedir) diff --git a/ompi/mpi/fortran/base/gen-mpi-mangling.pl b/ompi/mpi/fortran/base/gen-mpi-mangling.pl index a049c625228..5e4046178c3 100755 --- a/ompi/mpi/fortran/base/gen-mpi-mangling.pl +++ b/ompi/mpi/fortran/base/gen-mpi-mangling.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # -# Copyright (c) 2015 Research Organization for Information Science +# Copyright (c) 2015-2025 Research Organization for Information Science # and Technology (RIST). All rights reserved. # Copyright (c) 2015-2020 Cisco Systems, Inc. All rights reserved. # $COPYRIGHT$ @@ -16,6 +16,8 @@ my $plain_arg; my $single_underscore_arg; my $double_underscore_arg; +my $status_size_arg; +my $align_arg; my $help_arg = 0; &Getopt::Long::Configure("bundling"); @@ -23,10 +25,12 @@ "plain=i" => \$plain_arg, "single=i" => \$single_underscore_arg, "double=i" => \$double_underscore_arg, + "status-size=i" => \$status_size_arg, + "align=i" => \$align_arg, "help|h" => \$help_arg); if ($help_arg || !$ok) { - print "Usage: $0 [--caps|--plain|--single|--double] [--help]\n"; + print "Usage: $0 [--caps|--plain|--single|--double] --status-size= [--align=] [--help]\n"; exit(1 - $ok); } @@ -50,25 +54,25 @@ my $fortran; $fortran->{bottom} = { - c_type => "int", + c_type => "MPI_Fint", c_name => "mpi_fortran_bottom", f_type => "integer", f_name => "MPI_BOTTOM", }; $fortran->{in_place} = { - c_type => "int", + c_type => "MPI_Fint", c_name => "mpi_fortran_in_place", f_type => "integer", f_name => "MPI_IN_PLACE", }; $fortran->{unweighted} = { - c_type => "int", + c_type => "MPI_Fint", c_name => "mpi_fortran_unweighted", f_type => "integer, dimension(1)", f_name => "MPI_UNWEIGHTED", }; $fortran->{weights_empty} = { - c_type => "int", + c_type => "MPI_Fint", c_name => "mpi_fortran_weights_empty", f_type => "integer, dimension(1)", f_name => "MPI_WEIGHTS_EMPTY", @@ -88,19 +92,21 @@ }; $fortran->{errcodes_ignore} = { - c_type => "int", + c_type => "MPI_Fint", c_name => "mpi_fortran_errcodes_ignore", f_type => "integer, dimension(1)", f_name => "MPI_ERRCODES_IGNORE", }; $fortran->{status_ignore} = { - c_type => "int *", + c_type => "MPI_Fint", + c_dim => "[$status_size_arg]", c_name => "mpi_fortran_status_ignore", f_type => "type(MPI_STATUS)", f_name => "MPI_STATUS_IGNORE", }; $fortran->{statuses_ignore} = { - c_type => "int *", + c_type => "MPI_Fint", + c_dim => "[$status_size_arg]", c_name => "mpi_fortran_statuses_ignore", f_type => "type(MPI_STATUS)", f_name => "MPI_STATUSES_IGNORE(1)", @@ -130,7 +136,7 @@ sub gen_c_constants_decl { print OUT "/* WARNING: This is a generated file! Edits will be lost! */ /* - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2025 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * \$COPYRIGHT\$ @@ -146,7 +152,7 @@ sub gen_c_constants_decl { foreach my $key (sort(keys(%{$fortran}))) { my $f = $fortran->{$key}; my $m = mangle($f->{c_name}); - print OUT "extern $f->{c_type} $m; + print OUT "extern $f->{c_type} $m $f->{c_dim}; #define OMPI_IS_FORTRAN_" . uc($key) . "(addr) \\ (addr == (void*) &$m)\n\n"; } @@ -160,7 +166,7 @@ sub gen_c_constants { print OUT "/* WARNING: This is a generated file! Edits will be lost! */ /* - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2025 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * \$COPYRIGHT\$ @@ -171,7 +177,9 @@ sub gen_c_constants { foreach my $key (sort(keys(%{$fortran}))) { my $f = $fortran->{$key}; my $m = mangle($f->{c_name}); - print OUT "$f->{c_type} $m;\n"; + my $align = ""; + $align = "__opal_attribute_aligned__($align_arg)" if ($align_arg > 0); + print OUT "$f->{c_type} $align $m $f->{c_dim};\n"; } close (OUT);