Skip to content

Commit d9e4b07

Browse files
ggouaillardethppritcha
authored andcommitted
fortran/use-mpi-f08: fix mpi_f08 bindings build condition.
Fortran 2008 bindings can now be built if the Fortran compiler supports IGNORE_TKR *or* Fortran ISO bindings. Some other fixes were included in this commit. Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent c42e77a commit d9e4b07

File tree

15 files changed

+207
-25
lines changed

15 files changed

+207
-25
lines changed

config/ompi_config_files.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ AC_DEFUN([OMPI_CONFIG_FILES],[
4545
ompi/mpi/fortran/use-mpi-f08/bindings/Makefile
4646
ompi/mpi/fortran/use-mpi-f08/ts/Makefile
4747
ompi/mpi/fortran/use-mpi-f08/mod/Makefile
48+
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-subarrays-config.h
4849
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h
4950
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h
5051
ompi/mpi/fortran/mpiext-use-mpi/Makefile

config/ompi_setup_mpi_fortran.m4

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +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])
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.])])
457473

458474
# The overall "_BIND_C" variable will be set to 1 if we have all
459475
# the necessary forms of BIND(C)

ompi/include/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ include_HEADERS += \
4242
mpif-handles.h \
4343
mpif-io-constants.h \
4444
mpif-io-handles.h \
45-
mpif-sentinels.h
45+
mpif-sentinels.h \
46+
mpif-subarrays-config.h
4647

4748
endif
4849

ompi/include/mpif-config.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
! reserved.
1616
! Copyright (c) 2019 Triad National Security, LLC. All rights
1717
! reserved.
18+
! Copyright (c) 2019 Research Organization for Information Science
19+
! and Technology (RIST). All rights reserved.
1820
! $COPYRIGHT$
1921
!
2022
! Additional copyrights may follow
@@ -84,4 +86,3 @@
8486
parameter (MPI_SUBARRAYS_SUPPORTED= .false.)
8587
! Hard-coded for .false. for now
8688
parameter (MPI_ASYNC_PROTECTS_NONBLOCKING = .false.)
87-
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! -*- fortran -*-
2+
!
3+
! Copyright (c) 2019 Research Organization for Information Science
4+
! and Technology (RIST). All rights reserved.
5+
! $COPYRIGHT$
6+
!
7+
! Additional copyrights may follow
8+
!
9+
! $HEADER$
10+
!
11+
12+
!
13+
! MPI F08 conformance
14+
!
15+
logical MPI_SUBARRAYS_SUPPORTED
16+
logical MPI_ASYNC_PROTECTS_NONBLOCKING
17+
parameter (MPI_SUBARRAYS_SUPPORTED= .FALSE.)
18+
parameter (MPI_ASYNC_PROTECTS_NONBLOCKING = .FALSE.)
19+

ompi/include/mpif.h.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
! Copyright (c) 2004-2005 The Regents of the University of California.
1212
! All rights reserved.
1313
! Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
14-
! Copyright (c) 2017 Research Organization for Information Science
15-
! and Technology (RIST). All rights reserved.
14+
! Copyright (c) 2017-2019 Research Organization for Information Science
15+
! and Technology (RIST). All rights reserved.
1616
! $COPYRIGHT$
1717
!
1818
! Additional copyrights may follow
@@ -54,6 +54,7 @@
5454
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5555
5656
include 'mpif-config.h'
57+
include 'mpif-subarrays-config.h'
5758
include 'mpif-constants.h'
5859
include 'mpif-handles.h'
5960
include 'mpif-io-constants.h'

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ libforce_usempif08_internal_modules_to_be_built_la_SOURCES = \
6464

6565
nodist_noinst_HEADERS = mpi-f08-interfaces.h
6666

67-
noinst_HEADERS = mpi-f08-rename.h
67+
noinst_HEADERS = \
68+
mpi-f08-subarrays-config.h \
69+
mpi-f08-rename.h \
70+
mpi-f08-interfaces.h
6871

6972
libforce_usempi_internal_modules_to_be_built.la: libusempif08_internal_modules.la
7073

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! -*- fortran -*-
2+
!
3+
! Copyright (c) 2019 Research Organization for Information Science
4+
! and Technology (RIST). All rights reserved.
5+
! $COPYRIGHT$
6+
!
7+
! Additional copyrights may follow
8+
!
9+
! $HEADER$
10+
!
11+
12+
!
13+
! MPI F08 conformance
14+
!
15+
logical MPI_SUBARRAYS_SUPPORTED
16+
logical MPI_ASYNC_PROTECTS_NONBLOCKING
17+
parameter (MPI_SUBARRAYS_SUPPORTED= @OMPI_MPI_SUBARRAYS_SUPPORTED@)
18+
parameter (MPI_ASYNC_PROTECTS_NONBLOCKING = @OMPI_MPI_ASYNC_PROTECTS_NONBLOCKING@)
19+

ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module mpi_f08_types
2525
use mpi_types
2626

2727
include "mpif-config.h"
28+
include "mpi-f08-subarrays-config.h"
2829
include "mpif-constants.h"
2930
include "mpif-io-constants.h"
3031

ompi/mpi/fortran/use-mpi-f08/ts/bcast_ts.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ void ompi_bcast_ts(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
3535
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
3636
MPI_Datatype c_datatype = NULL, c_type = NULL;
3737
int c_root = OMPI_FINT_2_INT(*root);
38-
void *buffer = x->base_addr;
38+
void *buffer = NULL;
3939
int c_count = 0;
4040

4141
if (OMPI_COMM_IS_INTRA(c_comm) || MPI_PROC_NULL != c_root) {
4242
c_type = PMPI_Type_f2c(*datatype);
4343
c_count = OMPI_FINT_2_INT(*count);
44-
OMPI_CFI_2_C(x, c_count, c_type, c_datatype, c_ierr);
44+
if ((OMPI_COMM_IS_INTER(c_comm) && MPI_PROC_NULL == c_root) || (ompi_comm_rank(c_comm) == c_root)) {
45+
OMPI_CFI_2_C_COPY(x, buffer, c_count, c_type, c_datatype, c_ierr);
46+
} else {
47+
OMPI_CFI_2_C_ALLOC(x, buffer, c_count, c_type, c_datatype, c_ierr);
48+
}
4549
if (MPI_SUCCESS != c_ierr) {
4650
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
4751
OMPI_ERRHANDLER_INVOKE(c_comm, c_ierr, FUNC_NAME)
@@ -54,8 +58,12 @@ void ompi_bcast_ts(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
5458
c_datatype,
5559
c_root,
5660
c_comm);
57-
if (c_datatype != c_type) {
58-
ompi_datatype_destroy(&c_datatype);
59-
}
6061
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
62+
if (OMPI_COMM_IS_INTRA(c_comm) || MPI_PROC_NULL != c_root) {
63+
if ((OMPI_COMM_IS_INTER(c_comm) && MPI_ROOT == c_root) || (ompi_comm_rank(c_comm) == c_root)) {
64+
OMPI_C_2_CFI_FREE(x, buffer, c_count, c_type, c_datatype, c_ierr);
65+
} else {
66+
OMPI_C_2_CFI_COPY(x, buffer, c_count, c_type, c_datatype, c_ierr);
67+
}
68+
}
6169
}

0 commit comments

Comments
 (0)