Skip to content

Commit

Permalink
misc: clean up user function code
Browse files Browse the repository at this point in the history
We no longer need special treat Fortran user functions.
  • Loading branch information
hzhou committed Apr 10, 2024
1 parent 6989848 commit f19a7ff
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 83 deletions.
14 changes: 0 additions & 14 deletions maint/local_python/binding_f77.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,20 +506,6 @@ def dump_attr_out(v, c_type, flag):
end_list_common.append(" *%s = (MPI_Aint) %s_i;" % (v, v))
end_list_common.append("}")

def dump_handle_create(v, c_type):
c_param_list.append("MPI_Fint *%s" % v)
# note: when fint is int, both the handle and the handler interface are compatible with C
c_arg_list_A.append("(%s *) %s" % (c_type, v))
c_arg_list_B.append("&%s_i" % v)
code_list_B.append("int %s_i;" % v)
end_list_B.append("if (!*ierr) {")
if c_type == "MPI_Errhandler":
end_list_B.append(" MPII_Errhandler_set_fc(%s_i);" % v)
elif c_type == "MPI_Op":
end_list_B.append(" MPII_Op_set_fc(%s_i);" % v)
end_list_B.append(" *%s = (MPI_Fint) %s_i;" % (v, v))
end_list_B.append("}")

def dump_sum(codelist, sum_v, sum_n, array):
codelist.append("int %s = 0;" % sum_v)
codelist.append("for (int i = 0; i < *%s; i++) {" % sum_n)
Expand Down
5 changes: 0 additions & 5 deletions src/include/mpii_f77interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
MPICH_API_PUBLIC void MPII_Keyval_set_fortran(int);
MPICH_API_PUBLIC void MPII_Keyval_set_fortran90(int);
MPICH_API_PUBLIC void MPII_Grequest_set_lang_f77(MPI_Request greq);
#if defined(HAVE_FORTRAN_BINDING) && !defined(HAVE_FINT_IS_INT)
MPICH_API_PUBLIC void MPII_Op_set_fc(MPI_Op);
typedef void (MPII_F77_User_function) (void *, void *, MPI_Fint *, MPI_Fint *);
MPICH_API_PUBLIC void MPII_Errhandler_set_fc(MPI_Errhandler);
#endif

#define MPII_ATTR_C_TO_FORTRAN(ATTR) ((ATTR)+1)

Expand Down
13 changes: 0 additions & 13 deletions src/mpi/coll/op/op_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ void MPII_Op_set_cxx(MPI_Op op, void (*opcall) (void))
MPI_Datatype, MPI_User_function *)) opcall;
}
#endif
#if defined(HAVE_FORTRAN_BINDING) && !defined(HAVE_FINT_IS_INT)
/* Normally, the C and Fortran versions are the same, by design in the
MPI Standard. However, if MPI_Fint and int are not the same size (e.g.,
MPI_Fint was made 8 bytes but int is 4 bytes), then the C and Fortran
versions must be distinguished. */
void MPII_Op_set_fc(MPI_Op op)
{
MPIR_Op *op_ptr;

MPIR_Op_get_ptr(op, op_ptr);
op_ptr->language = MPIR_LANG__FORTRAN;
}
#endif

int MPIR_Op_create_impl(MPI_User_function * user_fn, int commute, MPIR_Op ** p_op_ptr)
{
Expand Down
20 changes: 0 additions & 20 deletions src/mpi/coll/reduce_local/reduce_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,6 @@ static void call_user_op_cxx(const void *inbuf, void *inoutbuf, int count, MPI_D
}
#endif

#if defined(HAVE_FORTRAN_BINDING) && !defined(HAVE_FINT_IS_INT)
static void call_user_op_f77(const void *inbuf, void *inoutbuf, MPI_Fint count, MPI_Fint datatype,
MPIR_User_function uop)
{
/* Take off the global locks before calling user functions */
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
(uop.f77_function) ((void *) inbuf, inoutbuf, &count, &datatype);
MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
}
#endif

int MPIR_Reduce_local(const void *inbuf, void *inoutbuf, MPI_Aint count, MPI_Datatype datatype,
MPI_Op op)
{
Expand Down Expand Up @@ -109,15 +98,6 @@ int MPIR_Reduce_local(const void *inbuf, void *inoutbuf, MPI_Aint count, MPI_Dat
(MPI_User_function *) op_ptr->function.c_function);
goto fn_exit;
}
#endif
#if defined(HAVE_FORTRAN_BINDING) && !defined(HAVE_FINT_IS_INT)
if (op_ptr->language == MPIR_LANG__FORTRAN) {
/* large count not supported */
MPIR_Assert(op_ptr->kind == MPIR_OP_KIND__USER);
call_user_op_f77(inbuf, inoutbuf, (MPI_Fint) count, (MPI_Fint) datatype,
op_ptr->function);
goto fn_exit;
}
#endif
if (op_ptr->kind == MPIR_OP_KIND__USER_X) {
call_user_op_x(inbuf, inoutbuf, count, datatype, op_ptr->function, op_ptr->extra_state);
Expand Down
31 changes: 0 additions & 31 deletions src/mpi/errhan/errutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,6 @@ void MPII_Errhandler_set_cxx(MPI_Errhandler errhand, void (*errcall) (void))
}
#endif /* HAVE_CXX_BINDING */

#if defined(HAVE_FORTRAN_BINDING) && !defined(HAVE_FINT_IS_INT)
void MPII_Errhandler_set_fc(MPI_Errhandler errhand)
{
MPIR_Errhandler *errhand_ptr;

MPIR_Errhandler_get_ptr(errhand, errhand_ptr);
errhand_ptr->language = MPIR_LANG__FORTRAN;
}

#endif

/* ------------------------------------------------------------------------- */
/* Group 2: These routines are called on error exit from most
Expand Down Expand Up @@ -291,27 +281,6 @@ int MPIR_call_errhandler(MPIR_Errhandler * errhandler, int errorcode, MPIR_handl
#endif
break;
}
#endif
#ifdef HAVE_FORTRAN_BINDING
case MPIR_LANG__FORTRAN90:
case MPIR_LANG__FORTRAN:
{
/* If int and MPI_Fint aren't the same size, we need to
* convert. As this is not performance critical, we
* do this even if MPI_Fint and int are the same size. */
MPI_Fint ferr = errorcode;
MPI_Fint commhandle;
#ifdef HAVE_ROMIO
if (h.kind == MPI_FILE) {
commhandle = MPI_File_c2f(h.u.fh);
} else
#endif
{
commhandle = h.u.handle;
}
(*errhandler->errfn.F77_Handler_function) (&commhandle, &ferr);
}
break;
#endif
}

Expand Down

0 comments on commit f19a7ff

Please sign in to comment.