1
1

Add support for F77/F90 in the Open MPI extensions interface system.

Per RFC from OMPI Devel list:
 * http://www.open-mpi.org/community/lists/devel/2011/06/9324.php

This commit was SVN r24772.
Этот коммит содержится в:
Josh Hursey 2011-06-10 20:03:06 +00:00
родитель 033cbbed31
Коммит 0833734fcf
8 изменённых файлов: 418 добавлений и 32 удалений

Просмотреть файл

@ -4,6 +4,7 @@ dnl Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
@ -101,6 +102,10 @@ AC_DEFUN([EXT_CONFIGURE],[
# first create the output include directory
mkdir -p $outdir
###############
# C Bindings
###############
# remove any previously generated #include files
mpi_ext_h=$outdir/mpi-ext.h
rm -f $mpi_ext_h
@ -120,10 +125,74 @@ extern "C" {
#define OMPI_HAVE_MPI_EXT 1
EOF
###############
# C++ Bindings
###############
# remove any previously generated #include files
mpicxx_ext_h=$outdir/mpicxx-ext.h
rm -f $mpicxx_ext_h
# Create the final mpi-ext.h file.
cat > $mpicxx_ext_h <<EOF
/*
* \$HEADER\$
*/
#ifndef OMPI_MPI_EXT_H
#define OMPI_MPI_EXT_H 1
#define OMPI_HAVE_MPI_EXT 1
EOF
###############
# F77 Bindings
###############
# remove any previously generated #include files
mpif_ext_h=$outdir/mpif-ext.h
rm -f $mpif_ext_h
# Create the final mpif-ext.h file.
cat > $mpif_ext_h <<EOF
! -*- fortran -*-
! \$HEADER\$
!
integer OMPI_HAVE_MPI_EXT
parameter (OMPI_HAVE_MPI_EXT=1)
!
EOF
###############
# F90 Bindings
###############
# remove any previously generated #include files
mpif90_ext_h=$outdir/mpif90-ext.f90
rm -f $mpif90_ext_h
# Create the final mpif90-ext.h file.
cat > $mpif90_ext_h <<EOF
! -*- fortran -*-
! \$HEADER\$
!
module mpi_ext
! Eventhough this is not a useful parameter (cannot be used as a
! preprocessor catch) define it to keep the linker from complaining
! during the build.
integer OMPI_HAVE_MPI_EXT
parameter (OMPI_HAVE_MPI_EXT=1)
!
EOF
#
# XXX: Left todo: Add header files for other languages
# Process each component
#
# remove any previously generated #include files
@ -140,6 +209,9 @@ EOF
[static_components],
[static_ltlibs])])])
###############
# C Bindings
###############
# Create the final mpi-ext.h file.
cat >> $mpi_ext_h <<EOF
@ -151,9 +223,32 @@ EOF
EOF
#
# XXX: Left todo: Close header files for other languages
#
###############
# C++ Bindings
###############
# Create the final mpicxx-ext.h file.
cat >> $mpicxx_ext_h <<EOF
#endif /* OMPI_MPI_EXT_H */
EOF
###############
# F77 Bindings
###############
# Create the final mpif-ext.h file.
cat >> $mpif_ext_h <<EOF
!
EOF
###############
# F90 Bindings
###############
# Create the final mpif90-ext.h file.
cat >> $mpif90_ext_h <<EOF
!
end module mpi_ext
EOF
# Create the final .h file that will be included in the type's
@ -270,43 +365,183 @@ AC_DEFUN([EXT_PROCESS_COMPONENT],[
component=$1
# Output pretty results
AC_MSG_CHECKING([if MPI extension $component can compile])
AC_MSG_CHECKING([if MPI Extension $component can compile])
AC_MSG_RESULT([yes])
# Save the list of headers and convenience libraries that this component will output
# There *must* be C bindings
EXT_C_HEADERS="$EXT_C_HEADERS mpiext/$component/mpiext_${component}_c.h"
EXT_C_LIBS="$EXT_C_LIBS mpiext/$component/libext_mpiext_${component}.la"
component_header="mpiext_${component}_c.h"
tmp[=]m4_translit([$1],[a-z],[A-Z])
component_define="OMPI_HAVE_MPI_EXT_${tmp}"
cat >> $mpi_ext_h <<EOF
###############
# C Bindings
###############
test_header="${srcdir}/ompi/mpiext/$component/mpiext_${component}_c.h"
AC_MSG_CHECKING([if MPI Extension $component has C bindings])
if test -e "$test_header" ; then
AC_MSG_RESULT([yes])
# Save the list of headers and convenience libraries that this component will output
EXT_C_HEADERS="$EXT_C_HEADERS mpiext/$component/mpiext_${component}_c.h"
EXT_C_LIBS="$EXT_C_LIBS mpiext/$component/libext_mpiext_${component}.la"
$3="mpiext/${component}/libext_mpiext_${component}.la $$3"
component_header="mpiext_${component}_c.h"
cat >> $mpi_ext_h <<EOF
/* Enabled Extension: $component */
#define $component_define 1
#include "openmpi/ompi/mpiext/$component/$component_header"
EOF
else
# There *must* be C bindings
AC_MSG_RESULT([no])
AC_MSG_WARN([C Bindings are required])
AC_MSG_ERROR([Cannot continue])
fi
###############
# C++ Bindings
###############
#
# XXX: Need to add conditional logic for components that do not supply
# XXX: some or all of the other 3 interfaces [C++, F77, F90]. If they
# XXX: did provide those bindings, then add the header file to the relevant
# XXX: language binding's header file.
# Test if this extension has cxx bindings
# If not, skip this step.
#
EXT_CXX_HEADERS="$EXT_CXX_HEADERS mpiext/$component/mpiext_${component}_cxx.h"
EXT_CXX_LIBS="$EXT_CXX_LIBS mpiext/$component/libext_mpiext_${component}_cxx.la"
test_header="${srcdir}/ompi/mpiext/$component/mpiext_${component}_cxx.h"
EXT_F77_HEADERS="$EXT_F77_HEADERS mpiext/$component/mpiext_${component}_f77.h"
EXT_F77_LIBS="$EXT_F77_LIBS mpiext/$component/libext_mpiext_${component}_f77.la"
AC_MSG_CHECKING([if MPI Extension $component has CXX bindings])
if test -e "$test_header" ; then
AC_MSG_RESULT([yes])
EXT_CXX_HEADERS="$EXT_CXX_HEADERS mpiext/$component/mpiext_${component}_cxx.h"
EXT_CXX_LIBS="$EXT_CXX_LIBS mpiext/$component/libext_mpiext_${component}_cxx.la"
$3="$$3 mpiext/${component}/libext_mpiext_${component}_cxx.la"
component_header="mpiext_${component}_cxx.h"
cat >> $mpicxx_ext_h <<EOF
/* Enabled Extension: $component */
#define $component_define 1
#include "openmpi/ompi/mpiext/$component/$component_header"
EOF
else
AC_MSG_RESULT([no])
cat >> $mpicxx_ext_h <<EOF
/* Enabled Extension: $component
* No CXX Bindings available
*/
#define $component_define 0
EOF
fi
###############
# F77 Bindings
###############
#
# Test if this extension has f77 bindings
# If not, skip this step.
#
test_header="${srcdir}/ompi/mpiext/$component/mpiext_${component}_f77.h"
enabled_f77=0
AC_MSG_CHECKING([if MPI Extension $component has F77 bindings])
if test -e "$test_header" ; then
AC_MSG_RESULT([yes])
enabled_f77=1
EXT_F77_HEADERS="$EXT_F77_HEADERS mpiext/$component/mpiext_${component}_f77.h"
EXT_F77_LIBS="$EXT_F77_LIBS mpiext/$component/libext_mpiext_${component}_f77.la"
$3="$$3 mpiext/${component}/libext_mpiext_${component}_f77.la"
component_header="mpiext_${component}_f77.h"
cat >> $mpif_ext_h <<EOF
!
! Enabled Extension: $component
!
integer $component_define
parameter ($component_define=1)
include 'openmpi/ompi/mpiext/$component/$component_header'
EOF
else
AC_MSG_RESULT([no])
cat >> $mpif_ext_h <<EOF
!
! Enabled Extension: $component
! No F77 Bindings available
!
integer $component_define
parameter ($component_define=0)
EOF
fi
###############
# F90 Bindings
###############
#
# Test if this extension has f90 bindings
# If not, skip this step.
#
test_header="${srcdir}/ompi/mpiext/$component/mpiext_${component}_f90.h"
AC_MSG_CHECKING([if MPI Extension $component has F90 bindings])
if test -e "$test_header" ; then
AC_MSG_RESULT([yes])
EXT_F90_HEADERS="$EXT_F90_HEADERS mpiext/$component/mpiext_${component}_f90.h"
#EXT_F90_LIBS="$EXT_F90_LIBS mpiext/$component/libext_mpiext_${component}_f90.la"
#$3="$$3 mpiext/${component}/libext_mpiext_${component}_f90.la"
component_header="mpiext_${component}_f90.h"
cat >> $mpif90_ext_h <<EOF
!
! Enabled Extension: $component
!
EOF
#
# Include the f77 header if it is available
# Cannot do this from inside the f90.h since, for VPATH builds,
# the top_ompi_srcdir is needed to find the header.
#
if test "$enabled_f77" = 1; then
f77_component_header="mpiext_${component}_f77.h"
cat >> $mpif90_ext_h <<EOF
include '$top_ompi_srcdir/ompi/mpiext/$component/$f77_component_header'
EOF
fi
cat >> $mpif90_ext_h <<EOF
include '$top_ompi_srcdir/ompi/mpiext/$component/$component_header'
EOF
else
AC_MSG_RESULT([no])
cat >> $mpif90_ext_h <<EOF
!
! Enabled Extension: $component
! No F90 Bindings available
!
EOF
fi
EXT_F90_HEADERS="$EXT_F90_HEADERS mpiext/$component/mpiext_${component}_f90.h"
EXT_F90_LIBS="$EXT_F90_LIBS mpiext/$component/libext_mpiext_${component}_f90.la"
# Add this subdir to the mast list of all EXT component subdirs
$2="$$2 ${component}"
$3="mpiext/${component}/libext_mpiext_${component}.la $$3"
m4_ifdef([OMPI_MPIEXT_]$1[_NEED_INIT],
[echo "extern const ompi_mpiext_component_t ompi_mpiext_${component};" >> $outfile.extern

Просмотреть файл

@ -10,7 +10,7 @@
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
# Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -43,7 +43,9 @@ endif
# counterparts (which AM automatically ships).
nodist_include_HEADERS = \
mpi.h \
mpi-ext.h
mpi-ext.h \
mpicxx-ext.h \
mpif-ext.h
if OMPI_WANT_F77_BINDINGS
nodist_include_HEADERS += \
@ -51,6 +53,37 @@ nodist_include_HEADERS += \
mpif-config.h
endif
# If we have any F90 MPI extensions, compile and generate the
# mpi_ext F90 module file. Do this by compiling a fake library;
# the modulefile will be created as a side-effect of compiling
# mpif90-ext.f90.
noinst_LTLIBRARIES = libforce_f90_module_to_be_built.la
libforce_f90_module_to_be_built_la_SOURCES = mpif90-ext.f90
mpi_ext.$(OBJEXT): mpif90-ext.f90
$(FCCOMPILE) -c -I. -o $@ $(FCFLAGS_f90) $<
MOSTLYCLEANFILES = *.mod
#
# Install the generated .mod files. Unfortunately, each F90 compiler
# may generate different filenames, so we have to use a glob. :-(
#
install-exec-hook:
@ for file in `ls *.mod`; do \
echo $(INSTALL) $$file $(DESTDIR)$(libdir); \
$(INSTALL) $$file $(DESTDIR)$(libdir); \
done
uninstall-local:
@ for file in `ls *.mod`; do \
echo rm -f $(DESTDIR)$(libdir)/$$file; \
rm -f $(DESTDIR)$(libdir)/$$file; \
done
#endif
include ompi/Makefile.am
EXTRA_DIST = $(headers)
@ -64,5 +97,5 @@ endif
# Remove the auto-generated mpi-ext.h file
# Since there is no mpi-ext.h.in, autogen does not know to cleanup this file.
distclean-local:
rm -f mpi-ext.h
rm -f mpi-ext.h mpicxx-ext.h mpif-ext.h mpif90-ext.h

Просмотреть файл

@ -2,6 +2,7 @@
# Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -9,21 +10,62 @@
# $HEADER$
#
#
# C bindings
#
headers = \
mpiext_example_c.h
sources = \
c/progress.c
lib = libext_mpiext_example.la
lib_sources = $(sources)
#
# F77 bindings
#
f77_sources =
if OMPI_WANT_F77_BINDINGS
headers += \
mpiext_example_f77.h
f77_sources += \
f77/progress_f.c
endif
#
# F90 bindings
#
if OMPI_WANT_F77_BINDINGS
headers += \
mpiext_example_f90.h
endif
extcomponentdir = $(pkglibdir)
noinst_LTLIBRARIES = $(lib)
# For C Bindings
lib = libext_mpiext_example.la
lib_sources = $(sources)
libext_mpiext_example_la_SOURCES = $(lib_sources)
libext_mpiext_example_la_LDFLAGS = -module -avoid-version
# For F77 Bindings
AM_CPPFLAGS = -DOMPI_PROFILE_LAYER=0 -DOMPI_COMPILING_F77_WRAPPERS=1
f77_lib = libext_mpiext_example_f77.la
f77_lib_sources = $(f77_sources)
libext_mpiext_example_f77_la_SOURCES = $(f77_lib_sources)
libext_mpiext_example_f77_la_LIBADD = $(lib_sources)
libext_mpiext_example_f77_la_LDFLAGS = -module -avoid-version
# For F90 Bindings
#f90_lib = libext_mpiext_example_f90.la
#f90_lib_sources =
#libext_mpiext_example_f90_la_SOURCES = $(f90_lib_sources)
noinst_LTLIBRARIES = $(lib) $(f77_lib)
ompidir = $(includedir)/openmpi/ompi/mpiext/example
ompi_HEADERS = \
$(headers)

Просмотреть файл

@ -2,6 +2,7 @@
* Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -44,9 +45,9 @@ ompi_mpiext_component_t ompi_mpiext_example = {
};
int OMPI_Progress(char * stmt)
int OMPI_Progress(int count)
{
printf("%s!!!\n", stmt);
printf("Count = %d!\n", count);
return MPI_SUCCESS;
}

40
ompi/mpiext/example/f77/progress_f.c Обычный файл
Просмотреть файл

@ -0,0 +1,40 @@
/*
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdio.h>
#include "ompi/mpi/f77/bindings.h"
#include "ompi/mpi/f77/constants.h"
#include "mpiext_example_c.h"
static void OMPI_Progress_f(MPI_Fint *count, MPI_Fint *ierr);
OMPI_DECLSPEC void OMPI_PROGRESS(MPI_Fint *count, MPI_Fint *ierr);
OMPI_DECLSPEC void ompi_progress(MPI_Fint *count, MPI_Fint *ierr);
OMPI_DECLSPEC void ompi_progress_(MPI_Fint *count, MPI_Fint *ierr);
OMPI_DECLSPEC void ompi_progress__(MPI_Fint *count, MPI_Fint *ierr);
void OMPI_PROGRESS(MPI_Fint *count, MPI_Fint *ierr) {
OMPI_Progress_f(count, ierr);
}
void ompi_progress(MPI_Fint *count, MPI_Fint *ierr) {
OMPI_Progress_f(count, ierr);
}
void ompi_progress_(MPI_Fint *count, MPI_Fint *ierr) {
OMPI_Progress_f(count, ierr);
}
void ompi_progress__(MPI_Fint *count, MPI_Fint *ierr) {
OMPI_Progress_f(count, ierr);
}
static void OMPI_Progress_f(MPI_Fint *count, MPI_Fint *ierr)
{
*ierr = OMPI_INT_2_FINT(OMPI_Progress(OMPI_FINT_2_INT(*count)));
}

Просмотреть файл

@ -1,6 +1,7 @@
/*
* Copyright (c) 2004-2009 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -9,4 +10,4 @@
*
*/
OMPI_DECLSPEC int OMPI_Progress(char * stmt);
OMPI_DECLSPEC int OMPI_Progress(int count);

11
ompi/mpiext/example/mpiext_example_f77.h Обычный файл
Просмотреть файл

@ -0,0 +1,11 @@
! -*- fortran -*-
!
! Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
! $COPYRIGHT$
!
! Additional copyrights may follow
!
! $HEADER$
!
! Since we have only functions, there is nothing to declare

23
ompi/mpiext/example/mpiext_example_f90.h Обычный файл
Просмотреть файл

@ -0,0 +1,23 @@
! -*- fortran -*-
!
! Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
! $COPYRIGHT$
!
! Additional copyrights may follow
!
! $HEADER$
!
! This whole file will be included in the mpif90_ext module interface section, so
! there's no need to declare that again here.
! Include the parameters for this extension
! Included from config/ompi_ext.m4 into mpif90-ext.f90
! include '../mpiext/example/mpiext_example_f77.h'
interface OMPI_Progress
subroutine ompi_progress(count)
integer, intent(IN) :: count
end subroutine ompi_progress
end interface OMPI_Progress