Skip to content

Commit 81207f5

Browse files
committed
Convert more Perl build scripts to Python
Continue the slow trend of removing Perl from our build process, and move to a more sustainable (at least by number of developers who know the language) language: Python. Use generative AI to convert 3 Perl scripts to Python: mpif-values.pl, gen-mpi-mangling.pl, and gen-mpi-sizeof.pl. Validate the results by code review+inspection and diff'ing the results of the Python-generated files with the original Perl-generated files. Signed-off-by: Jeff Squyres <jeff@squyres.com>
1 parent e8f7f7b commit 81207f5

17 files changed

+1149
-1100
lines changed

autogen.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
# Copyright (c) 2015-2022 IBM Corporation. All rights reserved.
1111
# Copyright (c) 2020 Amazon.com, Inc. or its affiliates.
1212
# All Rights reserved.
13-
#
1413
# Copyright (c) 2025 Nanook Consulting All rights reserved.
14+
# Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
1515
# $COPYRIGHT$
1616
#
1717
# Additional copyrights may follow
@@ -1609,7 +1609,7 @@ sub replace_config_sub_guess {
16091609
# sync).
16101610

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

16141614
foreach my $s (@scripts) {
16151615
verbose "=== $s\n";

ompi/communicator/comm_init.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* reserved.
2828
* Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
2929
* Copyright (c) 2023 NVIDIA Corporation. All rights reserved.
30+
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
3031
* $COPYRIGHT$
3132
*
3233
* Additional copyrights may follow
@@ -453,7 +454,7 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
453454
comm->c_index_vec = NULL;
454455

455456
/*
456-
* magic numerology - see TOPDIR/ompi/include/mpif-values.pl
457+
* magic numerology - see TOPDIR/ompi/include/mpif-values.py
457458
*/
458459
idx = (comm == (ompi_communicator_t*)ompi_mpi_comm_world_addr) ? 0 :
459460
(comm == (ompi_communicator_t*)ompi_mpi_comm_self_addr) ? 1 :

ompi/datatype/ompi_datatype_module.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Copyright (c) 2016-2018 FUJITSU LIMITED. All rights reserved.
2121
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
2222
* reserved.
23+
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
2324
* $COPYRIGHT$
2425
*
2526
* Additional copyrights may follow
@@ -566,7 +567,7 @@ int32_t ompi_datatype_init( void )
566567
} while(0)
567568

568569
/*
569-
* This MUST match the order of ompi/include/mpif-values.pl
570+
* This MUST match the order of ompi/include/mpif-values.py
570571
* Any change will break binary compatibility of Fortran programs.
571572
*/
572573
MOOG(datatype_null, 0);

ompi/include/Makefile.am

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# and Technology (RIST). All rights reserved.
1616
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
1717
# Copyright (c) 2022 IBM Corporation. All rights reserved.
18+
# Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
1819
# $COPYRIGHT$
1920
#
2021
# Additional copyrights may follow
@@ -66,7 +67,7 @@ endif
6667

6768
include ompi/Makefile.am
6869

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

78-
EXTRA_DIST = $(headers) mpif-values.pl
79+
EXTRA_DIST = $(headers) mpif-values.py
7980

8081
#
8182
# mpif-sizeof.h is generated based on some results from configure tests.
8283
#
8384

84-
sizeof_pl=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-sizeof.pl
85+
sizeof_py=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-sizeof.py
8586
mpif-sizeof.h: $(top_builddir)/config.status
86-
mpif-sizeof.h: $(sizeof_pl)
87+
mpif-sizeof.h: $(sizeof_py)
8788
mpif-sizeof.h:
88-
$(OMPI_V_GEN) $(sizeof_pl) \
89+
$(OMPI_V_GEN) $(python) $(sizeof_py) \
8990
--header=$@ --ierror=mandatory \
9091
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
9192
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
@@ -102,11 +103,11 @@ mpif-sizeof.h:
102103
# results from configure tests.
103104
#
104105

105-
mpif_mangling_pl=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-mangling.pl
106+
mpif_mangling_py=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-mangling.py
106107
mpif-c-constants-decl.h: $(top_builddir)/config.status
107-
mpif-c-constants-decl.h: $(mpif_mangling_pl)
108+
mpif-c-constants-decl.h: $(mpif_mangling_py)
108109
mpif-c-constants-decl.h:
109-
$(OMPI_V_GEN) $(mpif_mangling_pl) \
110+
$(OMPI_V_GEN) $(python) $(mpif_mangling_py) \
110111
--caps $(OMPI_FORTRAN_CAPS) \
111112
--plain $(OMPI_FORTRAN_PLAIN) \
112113
--single $(OMPI_FORTRAN_SINGLE_UNDERSCORE) \

ompi/include/mpi.h.in

+8-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2929
* reserved.
3030
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved
31+
* Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
3132
* $COPYRIGHT$
3233
*
3334
* Additional copyrights may follow
@@ -538,9 +539,9 @@ typedef MPI_Win_errhandler_function MPI_Win_errhandler_fn
538539
* Miscellaneous constants
539540
*
540541
* NOTE: Many of the integer constants below *also* appear in
541-
* ompi/include/mpif-values.pl. If you change any of these integer
542+
* ompi/include/mpif-values.py. If you change any of these integer
542543
* values below, make sure to also change the corresponding values in
543-
* mpif-values.pl.
544+
* mpif-values.py.
544545
*/
545546
#define MPI_ANY_SOURCE -1 /* match any source rank */
546547
#define MPI_PROC_NULL -2 /* rank of null process */
@@ -583,7 +584,7 @@ typedef MPI_Win_errhandler_function MPI_Win_errhandler_fn
583584
* Constants for C code to access elements in Fortran MPI status array.
584585
*
585586
* NOTE: The MPI_F_SOURCE, MPI_F_TAG, MPI_F_ERROR are intentionally 1
586-
* smaller than their Fortran equivalents in mpif-values.pl (because C
587+
* smaller than their Fortran equivalents in mpif-values.py (because C
587588
* is 0-indexed and Fortran is 1-indexed).
588589
*/
589590
#define MPI_F_STATUS_SIZE OMPI_FORTRAN_STATUS_SIZE /* Size of Fortran MPI status array */
@@ -761,7 +762,7 @@ enum {
761762
* Comparison results. Don't change the order of these, the group
762763
* comparison functions rely on it.
763764
* Do not change the order of these without also modifying
764-
* mpif-values.pl.
765+
* mpif-values.py.
765766
*/
766767
enum {
767768
MPI_IDENT,
@@ -773,7 +774,7 @@ enum {
773774
/*
774775
* MPI_Init_thread constants
775776
* Do not change the order of these without also modifying
776-
* mpif-values.pl.
777+
* mpif-values.py.
777778
*/
778779
enum {
779780
MPI_THREAD_SINGLE,
@@ -785,7 +786,7 @@ enum {
785786
/*
786787
* Datatype combiners.
787788
* Do not change the order of these without also modifying
788-
* mpif-values.pl.
789+
* mpif-values.py.
789790
*/
790791
enum {
791792
MPI_COMBINER_NAMED,
@@ -837,7 +838,7 @@ enum {
837838
/*
838839
* Communicator split type constants.
839840
* Do not change the order of these without also modifying
840-
* mpif-values.pl.
841+
* mpif-values.py.
841842
*/
842843
enum {
843844
MPI_COMM_TYPE_SHARED,

ompi/include/mpif-sentinels.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
! All rights reserved.
1313
! Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
1414
! Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
15+
! Copyright (c) 2025 Jeffrey M. Squyres. All rights reserved.
1516
! $COPYRIGHT$
1617
!
1718
! Additional copyrights may follow
@@ -26,7 +27,7 @@
2627
!
2728
! - the "mpi" module bindings
2829
! - the "mpi_f08" module bindings
29-
! - ompi/mpi/fortran/base/gen-mpi-mangling.pl
30+
! - ompi/mpi/fortran/base/gen-mpi-mangling.py
3031
!
3132

3233
! MPI_BOTTOM is only used where choice buffers can be used (meaning

0 commit comments

Comments
 (0)