Skip to content

Convert some Perl build scripts to Python #13231

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 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions autogen.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# Copyright (c) 2015-2022 IBM Corporation. All rights reserved.
# Copyright (c) 2020 Amazon.com, Inc. or its affiliates.
# All Rights reserved.
#
# Copyright (c) 2025 Nanook Consulting All rights reserved.
# Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
Expand Down Expand Up @@ -1609,7 +1609,7 @@ sub replace_config_sub_guess {
# sync).

my @scripts;
push(@scripts, "ompi/include/mpif-values.pl");
push(@scripts, "ompi/include/mpif-values.py");

foreach my $s (@scripts) {
verbose "=== $s\n";
Expand Down
40 changes: 40 additions & 0 deletions config/ompi_fortran_get_alignment.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
5 changes: 4 additions & 1 deletion config/ompi_setup_mpi_fortran.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -138,6 +138,9 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
AC_DEFINE([ompi_fortran_bogus_type_t], [int],
[A bogus type that allows us to have sentinel type values that are still valid])

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.
OMPI_FORTRAN_CHECK([CHARACTER], [yes],
Expand Down
3 changes: 2 additions & 1 deletion ompi/communicator/comm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* reserved.
* Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2023 NVIDIA Corporation. All rights reserved.
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -453,7 +454,7 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
comm->c_index_vec = NULL;

/*
* magic numerology - see TOPDIR/ompi/include/mpif-values.pl
* magic numerology - see TOPDIR/ompi/include/mpif-values.py
*/
idx = (comm == (ompi_communicator_t*)ompi_mpi_comm_world_addr) ? 0 :
(comm == (ompi_communicator_t*)ompi_mpi_comm_self_addr) ? 1 :
Expand Down
3 changes: 2 additions & 1 deletion ompi/datatype/ompi_datatype_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Copyright (c) 2016-2018 FUJITSU LIMITED. All rights reserved.
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -566,7 +567,7 @@ int32_t ompi_datatype_init( void )
} while(0)

/*
* This MUST match the order of ompi/include/mpif-values.pl
* This MUST match the order of ompi/include/mpif-values.py
* Any change will break binary compatibility of Fortran programs.
*/
MOOG(datatype_null, 0);
Expand Down
24 changes: 14 additions & 10 deletions ompi/include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
# 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.
# Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
Expand Down Expand Up @@ -66,7 +67,7 @@ endif

include ompi/Makefile.am

# This is complicated, but mpif-values.pl generates several
# This is complicated, but mpif-values.py generates several
# mpif-*.h files in this directory (during autogen.pl).
# Hence, if any of those files change, it's safer to just force the
# user to re-autogen.
Expand All @@ -75,17 +76,17 @@ include ompi/Makefile.am
# @ echo "ERROR: you must re-run autogen.pl (sorry!)"
# @ exit 1

EXTRA_DIST = $(headers) mpif-values.pl
EXTRA_DIST = $(headers) mpif-values.py

#
# mpif-sizeof.h is generated based on some results from configure tests.
#

sizeof_pl=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-sizeof.pl
sizeof_py=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-sizeof.py
mpif-sizeof.h: $(top_builddir)/config.status
mpif-sizeof.h: $(sizeof_pl)
mpif-sizeof.h: $(sizeof_py)
mpif-sizeof.h:
$(OMPI_V_GEN) $(sizeof_pl) \
$(OMPI_V_GEN) $(python) $(sizeof_py) \
--header=$@ --ierror=mandatory \
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
Expand All @@ -102,15 +103,18 @@ mpif-sizeof.h:
# results from configure tests.
#

mpif_mangling_pl=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-mangling.pl
mpif_mangling_py=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-mangling.py
mpif-c-constants-decl.h: $(top_builddir)/config.status
mpif-c-constants-decl.h: $(mpif_mangling_pl)
mpif-c-constants-decl.h: $(mpif_mangling_py)
mpif-c-constants-decl.h:
$(OMPI_V_GEN) $(mpif_mangling_pl) \
$(OMPI_V_GEN) $(python) $(mpif_mangling_py) \
--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)
Expand Down
15 changes: 8 additions & 7 deletions ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -538,9 +539,9 @@ typedef MPI_Win_errhandler_function MPI_Win_errhandler_fn
* Miscellaneous constants
*
* NOTE: Many of the integer constants below *also* appear in
* ompi/include/mpif-values.pl. If you change any of these integer
* ompi/include/mpif-values.py. If you change any of these integer
* values below, make sure to also change the corresponding values in
* mpif-values.pl.
* mpif-values.py.
*/
#define MPI_ANY_SOURCE -1 /* match any source rank */
#define MPI_PROC_NULL -2 /* rank of null process */
Expand Down Expand Up @@ -583,7 +584,7 @@ typedef MPI_Win_errhandler_function MPI_Win_errhandler_fn
* Constants for C code to access elements in Fortran MPI status array.
*
* NOTE: The MPI_F_SOURCE, MPI_F_TAG, MPI_F_ERROR are intentionally 1
* smaller than their Fortran equivalents in mpif-values.pl (because C
* smaller than their Fortran equivalents in mpif-values.py (because C
* is 0-indexed and Fortran is 1-indexed).
*/
#define MPI_F_STATUS_SIZE OMPI_FORTRAN_STATUS_SIZE /* Size of Fortran MPI status array */
Expand Down Expand Up @@ -761,7 +762,7 @@ enum {
* Comparison results. Don't change the order of these, the group
* comparison functions rely on it.
* Do not change the order of these without also modifying
* mpif-values.pl.
* mpif-values.py.
*/
enum {
MPI_IDENT,
Expand All @@ -773,7 +774,7 @@ enum {
/*
* MPI_Init_thread constants
* Do not change the order of these without also modifying
* mpif-values.pl.
* mpif-values.py.
*/
enum {
MPI_THREAD_SINGLE,
Expand All @@ -785,7 +786,7 @@ enum {
/*
* Datatype combiners.
* Do not change the order of these without also modifying
* mpif-values.pl.
* mpif-values.py.
*/
enum {
MPI_COMBINER_NAMED,
Expand Down Expand Up @@ -837,7 +838,7 @@ enum {
/*
* Communicator split type constants.
* Do not change the order of these without also modifying
* mpif-values.pl.
* mpif-values.py.
*/
enum {
MPI_COMM_TYPE_SHARED,
Expand Down
3 changes: 2 additions & 1 deletion ompi/include/mpif-sentinels.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
! All rights reserved.
! Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
! Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
! Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
! $COPYRIGHT$
!
! Additional copyrights may follow
Expand All @@ -26,7 +27,7 @@
!
! - the "mpi" module bindings
! - the "mpi_f08" module bindings
! - ompi/mpi/fortran/base/gen-mpi-mangling.pl
! - ompi/mpi/fortran/base/gen-mpi-mangling.py
!

! MPI_BOTTOM is only used where choice buffers can be used (meaning
Expand Down
Loading