Skip to content

Commit 8a912b0

Browse files
jtrongemphinney1100hppritcha
committed
Generate interfaces for C with bigcount
This adds scripts for generating the Fortran and C API bindings from template files, while also generating bigcount interfaces for those that require them. The Fortran binding code (for mpi_f08) is designed to generate both the Fortran subroutines and wrapping C code which calls into the MPI C api. Python >=3.6 is required for running these scripts, which is only necessary when the binding files have not already been generated. Users of the distribution tarball should not need to generate these files and thus should not require Python. Co-authored-by: mphinney1100 <mphinney@lanl.gov> Co-authored-by: Howard Pritchard <hppritcha@gmail.com> Signed-off-by: Jake Tronge <jtronge@lanl.gov>
1 parent b4390af commit 8a912b0

File tree

880 files changed

+40006
-39433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

880 files changed

+40006
-39433
lines changed

.gitignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-constants.h
230230
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h
231231
ompi/mpi/fortran/use-mpi-f08/sizeof_f08.f90
232232
ompi/mpi/fortran/use-mpi-f08/sizeof_f08.h
233-
ompi/mpi/fortran/use-mpi-f08/profile/psizeof_f08.f90
234-
ompi/mpi/fortran/use-mpi-f08/profile/*.F90
235233

236234
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-interfaces.h
237235
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-file-interfaces.h
@@ -534,9 +532,10 @@ docs/_static
534532
docs/_static/css/custom.css
535533
docs/_templates
536534

537-
# Common Python virtual environment directory names
535+
# Common Python virtual environment and cache directory names
538536
venv
539537
py??
538+
__pycache__/
540539

541540
# Copies of PRRTE RST files (i.e., not source controlled in this tree)
542541
docs/prrte-rst-content
@@ -546,3 +545,14 @@ docs/schizo-ompi-rst-content
546545
# tarballs)
547546
docs/html
548547
docs/man
548+
549+
# Generated binding scripts
550+
ompi/mpi/bindings/ompi_bindings/compiler.py
551+
552+
# Generated C Bindings
553+
ompi/mpi/c/generated_*.c
554+
555+
# Generated Fortran Bindings
556+
ompi/mpi/fortran/use-mpi-f08/*_generated.F90
557+
ompi/mpi/fortran/use-mpi-f08/base/*_generated.c
558+
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces-generated.h

config/ompi_config_files.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ AC_DEFUN([OMPI_CONFIG_FILES],[
4141
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-removed-interfaces.h
4242
ompi/mpi/fortran/use-mpi-f08/Makefile
4343
ompi/mpi/fortran/use-mpi-f08/base/Makefile
44-
ompi/mpi/fortran/use-mpi-f08/profile/Makefile
4544
ompi/mpi/fortran/use-mpi-f08/bindings/Makefile
4645
ompi/mpi/fortran/use-mpi-f08/mod/Makefile
4746
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h
4847
ompi/mpi/fortran/mpiext-use-mpi/Makefile
4948
ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile
49+
ompi/mpi/bindings/ompi_bindings/compiler.py
5050
ompi/mpi/tool/Makefile
5151

5252
ompi/tools/ompi_info/Makefile

config/ompi_configure_options.m4

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,26 @@ else
253253
fi
254254
AM_CONDITIONAL(OMPI_OMPIO_SUPPORT, test "$ompi_want_ompio" = "1")
255255

256+
AC_MSG_CHECKING([if want bigcount support])
257+
AC_ARG_ENABLE([bigcount],
258+
[AS_HELP_STRING([--enable-bigcount],
259+
[Enable the bigcount API])])
260+
if test "$enable_bigcount" = "yes" ; then
261+
AC_MSG_RESULT([yes])
262+
ompi_enable_bigcount=1
263+
else
264+
AC_MSG_RESULT([no])
265+
ompi_enable_bigcount=0
266+
fi
267+
AC_DEFINE_UNQUOTED([OMPI_BIGCOUNT],[$ompi_enable_bigcount],
268+
[Whether we want to compile bigcount API support])
269+
270+
# If the binding source files don't exist, then we need Python to generate them
271+
AM_PATH_PYTHON([3.6],,[:])
272+
binding_file="${srcdir}/ompi/mpi/c/ompi_send.c"
273+
AS_IF([! test -e "$binding_file" && test "$PYTHON" = ":"],
274+
[AC_MSG_ERROR([Open MPI requires Python >=3.6 for generating the bindings. Aborting])])
275+
AM_CONDITIONAL(OMPI_GENERATE_BINDINGS,[test "$PYTHON" != ":"])
276+
256277
])dnl
257278

config/ompi_fortran_check_ts.m4

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
dnl -*- shell-script -*-
2+
dnl
3+
dnl Copyright (c) 2019 Research Organization for Information Science
4+
dnl and Technology (RIST). All rights reserved.
5+
dnl $COPYRIGHT$
6+
dnl
7+
dnl Additional copyrights may follow
8+
dnl
9+
dnl $HEADER$
10+
dnl
11+
12+
# Check whether or not the C compiler supports ISO_Fortran_binding.h
13+
# Also check whether C and Fortran compiler interoperate.
14+
#
15+
# OMPI_FORTRAN_CHECK_TS([action if found], [action if not found])
16+
# ----------------------------------------------------
17+
AC_DEFUN([OMPI_FORTRAN_CHECK_TS],[
18+
AS_VAR_PUSHDEF([fortran_ts], [ompi_cv_fortran_have_ts])
19+
20+
AC_CHECK_HEADERS([ISO_Fortran_binding.h],
21+
[AC_CACHE_CHECK([if Fortran and C compilers support ISO_Fortran_binding.h], fortran_ts,
22+
[mkdir conftest.$$
23+
cd conftest.$$
24+
25+
# Try to compile the C bindings
26+
cat > conftest_c.c << EOF
27+
#include <ISO_Fortran_binding.h>
28+
29+
int is_contiguous_c(CFI_cdesc_t* x) {
30+
return CFI_is_contiguous(x);
31+
}
32+
EOF
33+
OPAL_LOG_COMMAND([$CC $CCFLAGS -c conftest_c.c],
34+
[cat > conftest.f90 << EOF
35+
module MOD_IS_CONTIGUOUS
36+
37+
interface
38+
39+
function is_contiguous(buf) BIND(C, name="is_contiguous_c")
40+
implicit none
41+
type(*), dimension(..) :: buf
42+
integer :: is_contiguous
43+
end function is_contiguous
44+
45+
end interface
46+
47+
end module
48+
49+
program test_is_contiguous
50+
use MOD_IS_CONTIGUOUS
51+
implicit none
52+
integer :: a0, a1(2), a2(2,2), a3(2,2,2)
53+
write (*,*) is_contiguous(a0)
54+
write (*,*) is_contiguous(a1)
55+
write (*,*) is_contiguous(a2)
56+
write (*,*) is_contiguous(a3)
57+
end program
58+
EOF
59+
OPAL_LOG_COMMAND([$FC $FCFLAGS $FCFLAGS_f90 -o conftest conftest.f90 conftest_c.o $LDFLAGS $LIBS],
60+
[AS_VAR_SET(fortran_ts, yes)],
61+
[AS_VAR_SET(fortran_ts, no)])],
62+
[AS_VAR_SET(fortran_ts, no)])
63+
cd ..
64+
rm -rf conftest.$$])],
65+
[AS_VAR_SET(fortran_ts, no)])
66+
67+
AS_VAR_IF(fortran_ts, [yes], [$1], [$2])
68+
AS_VAR_POPDEF([fortran_ts])dnl
69+
])

config/ompi_setup_mpi_fortran.m4

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,27 @@ end program]])],
449449
# If we got all the stuff from above, then also look for the new
450450
# F08 syntax that we can use for the use_mpif08 module.
451451

452-
# We need to have ignore TKR functionality to build the mpi_f08
452+
OMPI_FORTRAN_HAVE_TS=0
453+
OMPI_MPI_SUBARRAYS_SUPPORTED=.false.
454+
OMPI_MPI_ASYNC_PROTECTS_NONBLOCKING=.false.
455+
AS_IF([test $OMPI_TRY_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS],
456+
[OMPI_FORTRAN_CHECK_TS([OMPI_FORTRAN_HAVE_TS=1])])
457+
458+
AC_SUBST(OMPI_MPI_SUBARRAYS_SUPPORTED)
459+
AC_SUBST(OMPI_MPI_ASYNC_PROTECTS_NONBLOCKING)
460+
461+
# We need to have ignore TKR or the ISO Fortran bindings functionality to build the mpi_f08
453462
# module
454-
AS_IF([test $OMPI_TRY_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS && \
455-
test $OMPI_FORTRAN_HAVE_IGNORE_TKR -eq 1],
456-
[OMPI_BUILD_FORTRAN_BINDINGS=$OMPI_FORTRAN_USEMPIF08_BINDINGS
457-
OMPI_FORTRAN_F08_PREDECL=$OMPI_FORTRAN_IGNORE_TKR_PREDECL
458-
OMPI_FORTRAN_F08_TYPE=$OMPI_FORTRAN_IGNORE_TKR_TYPE
459-
])
463+
AS_IF([test $OMPI_TRY_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS],
464+
[AS_IF([test $OMPI_FORTRAN_HAVE_IGNORE_TKR -eq 1],
465+
[OMPI_BUILD_FORTRAN_BINDINGS=$OMPI_FORTRAN_USEMPIF08_BINDINGS
466+
OMPI_FORTRAN_F08_PREDECL=$OMPI_FORTRAN_IGNORE_TKR_PREDECL
467+
OMPI_FORTRAN_F08_TYPE=$OMPI_FORTRAN_IGNORE_TKR_TYPE
468+
])
469+
AS_IF([test $OMPI_FORTRAN_HAVE_TS -eq 1],
470+
[OMPI_BUILD_FORTRAN_BINDINGS=$OMPI_FORTRAN_USEMPIF08_BINDINGS
471+
OMPI_MPI_SUBARRAYS_SUPPORTED=.true.
472+
OMPI_MPI_ASYNC_PROTECTS_NONBLOCKING=.true.])])
460473

461474
# The overall "_BIND_C" variable will be set to 1 if we have all
462475
# the necessary forms of BIND(C)
@@ -590,17 +603,13 @@ end type test_mpi_handle],
590603
])
591604

592605
OMPI_FORTRAN_NEED_WRAPPER_ROUTINES=1
593-
OMPI_FORTRAN_F08_PREDECL='!'
594-
OMPI_FORTRAN_F08_TYPE=real
595606
OMPI_FORTRAN_HAVE_F08_ASSUMED_RANK=0
596607
AS_IF([test $OMPI_TRY_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS && \
597608
test $OMPI_BUILD_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS],
598609
[ # Look for Fortran 2008 assumed rank syntax
599610
OMPI_FORTRAN_CHECK_F08_ASSUMED_RANK(
600611
[ # If we have assumed rank, we can build the use
601612
# mpi_f08 module "better"
602-
OMPI_FORTRAN_F08_PREDECL='!'
603-
OMPI_FORTRAN_F08_TYPE='type(*), dimension(..)'
604613
OMPI_FORTRAN_HAVE_F08_ASSUMED_RANK=1])
605614

606615
# Which mpi_f08 implementation are we using?
@@ -630,6 +639,12 @@ end type test_mpi_handle],
630639
[OMPI_FORTRAN_ELEMENTAL_TYPE=])])
631640
AC_SUBST(OMPI_FORTRAN_ELEMENTAL_TYPE)
632641

642+
OMPI_FORTRAN_HAVE_C_ISO_FORTRAN=0
643+
AS_IF([test $OMPI_TRY_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS && \
644+
test $OMPI_BUILD_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS],
645+
[OMPI_FORTRAN_CHECK_TS([OMPI_FORTRAN_HAVE_TS=1],
646+
[OMPI_FORTRAN_HAVE_TS=0])])
647+
633648
# Note: the current implementation *only* has wrappers;
634649
# there is no optimized implementation for a "good"
635650
# compiler. I'm leaving the above logic in place for
@@ -652,6 +667,8 @@ end type test_mpi_handle],
652667
AS_IF([test $OMPI_MIN_REQUIRED_FORTRAN_BINDINGS -gt $OMPI_BUILD_FORTRAN_BINDINGS],
653668
[AC_MSG_ERROR([Cannot build requested Fortran bindings, aborting])])
654669

670+
dnl AC_CONFIG_FILES([ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h])
671+
655672
# -------------------
656673
# mpif.h final setup
657674
# -------------------
@@ -792,10 +809,9 @@ end type test_mpi_handle],
792809
# This goes into mpifort-wrapper-data.txt
793810
AC_SUBST(OMPI_FORTRAN_USEMPIF08_LIB)
794811

795-
# These go into interfaces/mpi-f08-interfaces-[no]bind.h (and
796-
# mpi-f*-interfaces*.h files)
797-
AC_SUBST(OMPI_FORTRAN_F08_PREDECL)
798-
AC_SUBST(OMPI_FORTRAN_F08_TYPE)
812+
# These go into mod/mpi-f08-interfaces.h
813+
AC_SUBST(OMPI_F08_IGNORE_TKR_PREDECL)
814+
AC_SUBST(OMPI_F08_IGNORE_TKR_TYPE)
799815

800816
AC_SUBST(OMPI_MPI_PREFIX)
801817
AC_SUBST(OMPI_MPI_BIND_PREFIX)
@@ -877,6 +893,22 @@ end type test_mpi_handle],
877893
# For configure-fortran-output.h
878894
AC_SUBST(OMPI_FORTRAN_HAVE_BIND_C)
879895

896+
AM_CONDITIONAL(OMPI_FORTRAN_HAVE_TS,
897+
[test $OMPI_FORTRAN_HAVE_TS -eq 1])
898+
AC_SUBST(OMPI_FORTRAN_HAVE_TS)
899+
900+
AS_IF([test $OMPI_FORTRAN_HAVE_TS -eq 1],
901+
[OMPI_F08_IGNORE_TKR_TYPE="type(*), dimension(..)"
902+
OMPI_F08_IGNORE_TKR_PREDECL="no attribute required for"
903+
OMPI_F08_BINDINGS_EXTENSION="ts"
904+
OMPI_F08_BINDINGS_TS_SUFFIX="ts"],
905+
[OMPI_F08_IGNORE_TKR_TYPE=$OMPI_FORTRAN_IGNORE_TKR_TYPE
906+
OMPI_F08_IGNORE_TKR_PREDECL=${OMPI_FORTRAN_IGNORE_TKR_PREDECL:1}
907+
OMPI_F08_BINDINGS_EXTENSION="f"
908+
OMPI_F08_BINDINGS_TS_SUFFIX=""])
909+
AC_SUBST(OMPI_F08_BINDINGS_EXTENSION)
910+
AC_SUBST(OMPI_F08_BINDINGS_TS_SUFFIX)
911+
880912
# Somewhat redundant because ompi/Makefile.am won't traverse into
881913
# ompi/mpi/fortran/use-mpi-f08 if it's not to be built, but we
882914
# might as well have ompi/mpi/fortran/use-mpi-f08/Makefile.am be

0 commit comments

Comments
 (0)