Skip to content
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

binding/io: misc issues related to io binding generation #7276

Merged
merged 10 commits into from
Feb 3, 2025
Merged
22 changes: 8 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,6 @@ if test "$with_cross" != "no" ; then
fi

# This goes here because we need the top_srcdir
HAVE_CXX_IO=0
if test "$enable_romio" = "yes" ; then
if test -d $use_top_srcdir/src/mpi/romio ; then
AC_DEFINE(HAVE_ROMIO,1,[Define if ROMIO is enabled])
Expand All @@ -1403,10 +1402,9 @@ if test "$enable_romio" = "yes" ; then
# This test used -e under Linux, but not all test programs understand
# -e
if test ! -d lib ; then mkdir lib ; fi
# tell mpi.h to include mpio.h
HAVE_ROMIO='#include "mpio.h"'
# tell mpicxx.h that we have IO
HAVE_CXX_IO=1
# define ROMIO_VERSION in mpi.h so application can check whether ROMIO is included
ROMIO_VERSION='#define ROMIO_VERSION 126'

romio_subdir_args=""
if test "$enable_mpi_abi" = "yes" ; then
romio_subdir_args="--enable-mpi-abi"
Expand All @@ -1416,8 +1414,7 @@ if test "$enable_romio" = "yes" ; then
AC_MSG_WARN([ROMIO src directory is not available])
fi
fi
AC_SUBST(HAVE_ROMIO)
AC_SUBST(HAVE_CXX_IO)
AC_SUBST(ROMIO_VERSION)

AM_CONDITIONAL([BUILD_ROMIO], [test x$enable_romio = xyes])
#
Expand Down Expand Up @@ -3383,17 +3380,14 @@ AC_DEFINE_UNQUOTED([MPIR_OFFSET_MAX],[$MPIR_OFFSET_MAX],[limits.h _MAX constant
MPI_OFFSET_TYPEDEF="typedef $MPI_OFFSET MPI_Offset;"
AC_SUBST(MPI_OFFSET_TYPEDEF)
#
# Fortran type for an Offset type (needed to define MPI_DISPLACEMENT_CURRENT
# The value for this comes from ROMIO, and is needed in mpif.h.in
# Fortran type for an Offset type (needed to define MPI_DISPLACEMENT_CURRENT)
# and is needed in mpif.h.in.
# First, we check that this works with both Fortran compilers (if
# they are defined)
#
# If there is no FORTRAN_MPI_OFFSET type (because ROMIO is disabled),
# just use INTEGER
if test -z "$FORTRAN_MPI_OFFSET" ; then
FORTRAN_MPI_OFFSET=INTEGER
fi
if test "$enable_f77" = yes -a "$enable_f90" = yes ; then
FORTRAN_MPI_OFFSET="INTEGER(KIND=$OFFSET_KIND)"

AC_LANG_PUSH([Fortran 77])
AC_MSG_CHECKING([whether the Fortran Offset type works with Fortran 77])
AC_COMPILE_IFELSE([
Expand Down
2 changes: 1 addition & 1 deletion maint/gen_binding_f08.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os

def main():
# currently support -no-real128, -no-mpiio, -fint-size, -aint-size, -count-size, -cint-size
# currently support -no-real128, -fint-size, -aint-size, -count-size, -cint-size
G.parse_cmdline()

binding_dir = G.get_srcdir_path("src/binding")
Expand Down
2 changes: 1 addition & 1 deletion maint/gen_binding_f77.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os

def main():
# currently support -no-real128, -no-mpiio, -aint-is-int
# currently support -no-real128, -aint-is-int
G.parse_cmdline()

binding_dir = G.get_srcdir_path("src/binding")
Expand Down
31 changes: 7 additions & 24 deletions maint/local_python/binding_f08.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,42 +1182,26 @@ def dump_handle_routines():
else:
G.out.append(" res = (f08%MPI_VAL /= f)")
G.out.append("END FUNCTION %s" % func_name)
# e.g. MPI_Comm_f2c

def dump_handle_f2c():
# e.g. MPI_Comm_f2c/c2f
G.out.append("INTERFACE")
G.out.append("INDENT")
for a in G.handle_list:
if a == "MPI_File":
continue
if RE.match(r'MPIX?_(\w+)', a):
c_name = "c_" + RE.m.group(1)
for p in [("f", "c"), ("c", "f")]:
func_name = "%s_%s2%s" % (a, p[0], p[1])
G.out.append("")
G.out.append("FUNCTION %s(x) result(res)" % func_name)
G.out.append("FUNCTION %s(x) bind(C, name=\"P%s\") result(res)" % (func_name, func_name))
G.out.append(" USE mpi_c_interface_types, ONLY: %s" % c_name)
if p[0] == "f":
G.out.append(" INTEGER, VALUE :: x")
G.out.append(" INTEGER(%s) :: res" % c_name)
else:
G.out.append(" INTEGER(%s), VALUE :: x" % c_name)
G.out.append(" INTEGER :: res")
G.out.append(" res = x")
G.out.append("END FUNCTION %s" % func_name)

def dump_file_interface():
G.out.append("")
G.out.append("INTERFACE")
G.out.append("INDENT")
for p in [("f", "c"), ("c", "f")]:
func_name = "MPI_File_%s2%s" % (p[0], p[1])
G.out.append("")
G.out.append("FUNCTION %s(x) bind(C, name=\"%s\") result(res)" % (func_name, func_name))
G.out.append(" USE mpi_c_interface_types, ONLY: c_File")
if p[0] == "f":
G.out.append(" INTEGER, VALUE :: x")
G.out.append(" INTEGER(c_File) :: res")
else:
G.out.append(" INTEGER(c_File), VALUE :: x")
G.out.append(" INTEGER :: res")
G.out.append("END FUNCTION MPI_File_%s2%s" % (p[0], p[1]))
G.out.append("DEDENT")
G.out.append("END INTERFACE")

Expand Down Expand Up @@ -1270,8 +1254,7 @@ def dump_sizeof_routines():
G.out.append("")
G.out.append("private :: c_int, c_Count, c_Status")
dump_handle_types()
if "no-mpiio" not in G.opts:
dump_file_interface()
dump_handle_f2c()
dump_status_type()
dump_status_interface()
dump_handle_interface()
Expand Down
65 changes: 0 additions & 65 deletions maint/local_python/mpi_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,71 +245,6 @@ def parse_param_attributes(p):
else:
p['asynchronous'] = False

# FIXME: until ROMIO interface are generated
def get_mpiio_func_list():
io_func_name_list = [
"MPI_File_c2f",
"MPI_File_close",
"MPI_File_delete",
"MPI_File_errhandler_function",
"MPI_File_f2c",
"MPI_File_get_amode",
"MPI_File_get_atomicity",
"MPI_File_get_byte_offset",
"MPI_File_get_group",
"MPI_File_get_info",
"MPI_File_get_position",
"MPI_File_get_position_shared",
"MPI_File_get_size",
"MPI_File_get_type_extent",
"MPI_File_get_view",
"MPI_File_iread",
"MPI_File_iread_all",
"MPI_File_iread_at",
"MPI_File_iread_at_all",
"MPI_File_iread_shared",
"MPI_File_iwrite",
"MPI_File_iwrite_all",
"MPI_File_iwrite_at",
"MPI_File_iwrite_at_all",
"MPI_File_iwrite_shared",
"MPI_File_open",
"MPI_File_preallocate",
"MPI_File_read",
"MPI_File_read_all",
"MPI_File_read_all_begin",
"MPI_File_read_all_end",
"MPI_File_read_at",
"MPI_File_read_at_all",
"MPI_File_read_at_all_begin",
"MPI_File_read_at_all_end",
"MPI_File_read_ordered",
"MPI_File_read_ordered_begin",
"MPI_File_read_ordered_end",
"MPI_File_read_shared",
"MPI_File_seek",
"MPI_File_seek_shared",
"MPI_File_set_atomicity",
"MPI_File_set_info",
"MPI_File_set_size",
"MPI_File_set_view",
"MPI_File_sync",
"MPI_File_write",
"MPI_File_write_all",
"MPI_File_write_all_begin",
"MPI_File_write_all_end",
"MPI_File_write_at",
"MPI_File_write_at_all",
"MPI_File_write_at_all_begin",
"MPI_File_write_at_all_end",
"MPI_File_write_ordered",
"MPI_File_write_ordered_begin",
"MPI_File_write_ordered_end",
"MPI_File_write_shared",
"MPI_Register_datarep"
]
return [G.FUNCS[a.lower()] for a in io_func_name_list]

def get_f77_dummy_func_list():
dummy_func_name_list = [
"MPI_DUP_FN",
Expand Down
6 changes: 6 additions & 0 deletions src/binding/c/io_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ MPI_File_read_at_all_begin:

MPI_File_read_at_all_end:
.desc: Complete a split collective read using
.skip: validate-buf

MPI_File_read_all_begin:
.desc: Begin a split collective read using individual file pointer
Expand All @@ -120,6 +121,7 @@ MPI_File_read_all:

MPI_File_read_all_end:
.desc: Complete a split collective read using
.skip: validate-buf

MPI_File_read_at_all:
.desc: Collective read using explicit offset
Expand All @@ -138,6 +140,7 @@ MPI_File_read_ordered:

MPI_File_read_ordered_end:
.desc: Complete a split collective read using shared file pointer
.skip: validate-buf

MPI_File_read_shared:
.desc: Read using shared file pointer
Expand Down Expand Up @@ -172,6 +175,7 @@ MPI_File_write_at_all_begin:

MPI_File_write_at_all_end:
.desc: Complete a split collective write using explicit offset
.skip: validate-buf

MPI_File_write_all_begin:
.desc: Begin a split collective write using
Expand All @@ -181,6 +185,7 @@ MPI_File_write_all:

MPI_File_write_all_end:
.desc: Complete a split collective write using individual file pointer
.skip: validate-buf

MPI_File_write_at_all:
.desc: Collective write using explicit offset
Expand All @@ -199,6 +204,7 @@ MPI_File_write_ordered:

MPI_File_write_ordered_end:
.desc: Complete a split collective write using shared file pointer
.skip: validate-buf

MPI_File_write_shared:
.desc: Write using shared file pointer
Expand Down
25 changes: 0 additions & 25 deletions src/binding/cxx/buildiface
Original file line number Diff line number Diff line change
Expand Up @@ -1254,12 +1254,6 @@ typedef int MPI_File;\
# Begin the class, writing the common operations (destructors etc.)
&BeginClass( $class );

# Hack to ifdef out the file routines
if ($class eq "file") {
# Define the file type only if supported.
print $OUTFD "#if \@HAVE_CXX_IO\@\n";
}

foreach $mpilevel (@mpilevels) {
if ($mpilevel eq "post") {
$printed_extra_fnc = 1;
Expand Down Expand Up @@ -1307,11 +1301,6 @@ typedef int MPI_File;\
&$extrafnc( $OUTFD );
}

# Hack to ifdef out the file routines
if ($class eq "file") {
# Define the file type only if supported.
print $OUTFD "#endif\n";
}
&EndClass;

# Special case. Once we define a Datatype, add this typedef
Expand Down Expand Up @@ -1347,11 +1336,9 @@ typedef int MPI_File;\
# Only define these typedefs when MPI-IO is available (this is the same
# test as used for the rest of the I/O routines );
print $OUTFD "\
#if \@HAVE_CXX_IO\@
typedef int Datarep_extent_function( const Datatype&, Aint&, void *);
typedef int Datarep_conversion_function( void *, Datatype &, int, void *,
Offset, void * );
#endif
\n";

print $OUTFD "\n";
Expand Down Expand Up @@ -1995,13 +1982,6 @@ extern Datatype TWOINTEGER;
else { print $OUTFD ";\n"; }
}

print $OUTFD "// Include these only if MPI-IO is available\n";
if ($giveValue) {
print $OUTFD "#ifdef HAVE_ROMIO\n";
} else {
print $OUTFD "#if \@HAVE_CXX_IO\@\n";
}

# Other file constants
foreach $int (MAX_DATAREP_STRING) {
print $OUTFD "${extern}const int $int";
Expand All @@ -2021,7 +2001,6 @@ extern Datatype TWOINTEGER;
if ($giveValue) { print $OUTFD " = MPI_MODE_$int;\n"; }
else { print $OUTFD ";\n"; }
}
print $OUTFD "#endif // IO\n";

# Some modes are for RMA, not I/O
foreach $int (NOCHECK,NOPRECEDE, NOPUT, NOSTORE, NOSUCCEED) {
Expand Down Expand Up @@ -2654,7 +2633,6 @@ void Win::Call_errhandler( int errorcode ) const
MPI_Win_call_errhandler( (MPI_Win) the_real_win, errorcode );
}

#ifdef HAVE_ROMIO
void File::Call_errhandler( int errorcode ) const
{
// we must free the Errhandler object returned from Get_errhandler because
Expand All @@ -2671,7 +2649,6 @@ void File::Call_errhandler( int errorcode ) const
}
MPI_File_call_errhandler( (MPI_File) the_real_file, errorcode );
}
#endif // IO

// Helper function to invoke the comm_world C++ error handler.
void MPIR_Call_world_errhand( int err )
Expand All @@ -2685,7 +2662,6 @@ EOT
# The data rep conversion functions need to be wrapped in C code
# Only define this routine when MPI-IO is available (this is the same
# test as used for the rest of the I/O routines );
print $OUTFD "#ifdef HAVE_ROMIO\n";
print $OUTFD "
extern \"C\" {
//
Expand Down Expand Up @@ -2747,7 +2723,6 @@ void Register_datarep( const char *datarep,
routine for ldata will never be freed */
}
";
print $OUTFD "#endif\n";


print $OUTFD "\
Expand Down
6 changes: 0 additions & 6 deletions src/binding/cxx/user_proxy.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ struct CXX_errhan_state {
union {
MPI::Comm::Errhandler_function * comm_err_fn;
MPI::Win::Errhandler_function * win_err_fn;
#ifdef HAVE_ROMIO
MPI::File::Errhandler_function * file_err_fn;
#endif
// MPI::Session::Errhandler_function * session_err_fn;
} u;
};
Expand All @@ -60,14 +58,12 @@ static void CXX_win_errhan_proxy(MPI_Win win, int error_code, void *extra_state)
p->u.win_err_fn(h, &error_code);
}

#ifdef HAVE_ROMIO
static void CXX_file_errhan_proxy(MPI_File file, int error_code, void *extra_state)
{
CXX_errhan_state *p = (CXX_errhan_state *) extra_state;
MPI::File h = file;
p->u.file_err_fn(h, &error_code);
}
#endif

static void CXX_errhan_free(void *extra_state)
{
Expand Down Expand Up @@ -100,7 +96,6 @@ Errhandler Win::Create_errhandler(MPI::Win::Errhandler_function *f)
return e1;
}

#ifdef HAVE_ROMIO
Errhandler File::Create_errhandler(MPI::File::Errhandler_function *f)
{
CXX_errhan_state *p = new(CXX_errhan_state);
Expand All @@ -113,4 +108,3 @@ Errhandler File::Create_errhandler(MPI::File::Errhandler_function *f)
e1.the_real_errhandler = eh;
return e1;
}
#endif
2 changes: 2 additions & 0 deletions src/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#define MPICH 1
#define MPICH_HAS_C2F 1

@ROMIO_VERSION@

/* MPICH_VERSION is the version string. MPICH_NUMVERSION is the
* numeric version that can be used in numeric comparisons.
*
Expand Down
2 changes: 2 additions & 0 deletions src/mpi/romio/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ AM_CPPFLAGS += $(MPI_H_INCLUDE)
# handle the "include" directory here
AM_CPPFLAGS += -I$(top_builddir)/include -I$(top_srcdir)/include $(external_includes)
# nodist_ b/c these are created by config.status and should not be distributed
if INSTALL_HEADERS
nodist_include_HEADERS += include/mpio.h include/mpiof.h
endif

# ------------------------------------------------------------------------

Expand Down
Loading