Skip to content

Commit

Permalink
misc: clean up user function code for cxx
Browse files Browse the repository at this point in the history
We no longer require special code for calling cxx op user funciton nor
cxx error handlers.
  • Loading branch information
hzhou committed Apr 10, 2024
1 parent f19a7ff commit ff1312d
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 103 deletions.
1 change: 0 additions & 1 deletion src/include/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ noinst_HEADERS += \
src/include/mpir_attr_generic.h \
src/include/mpir_attr.h \
src/include/mpii_f77interface.h \
src/include/mpii_cxxinterface.h \
src/include/mpii_fortlogical.h \
src/include/mpir_bsend.h \
src/include/mpir_cvars.h \
Expand Down
13 changes: 0 additions & 13 deletions src/include/mpii_cxxinterface.h

This file was deleted.

4 changes: 0 additions & 4 deletions src/include/mpiimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ typedef struct MPIR_Stream MPIR_Stream;
#include "mpir_pt2pt.h"
#include "mpir_gpu.h"

#ifdef HAVE_CXX_BINDING
#include "mpii_cxxinterface.h"
#endif

#ifdef HAVE_FORTRAN_BINDING
#include "mpii_f77interface.h"
#endif
Expand Down
1 change: 0 additions & 1 deletion src/include/mpir_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ typedef union MPIR_User_function {
typedef struct MPIR_Op {
MPIR_OBJECT_HEADER; /* adds handle and ref_count fields */
MPIR_Op_kind kind;
MPIR_Lang_t language;
int is_commute;
MPIR_User_function function;
MPIX_Destructor_function *destructor_fn;
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 @@ -16,18 +16,6 @@ MPIR_Object_alloc_t MPIR_Op_mem = { 0, 0, 0, 0, 0, 0, MPIR_OP,
NULL, {0}
};

#ifdef HAVE_CXX_BINDING
void MPII_Op_set_cxx(MPI_Op op, void (*opcall) (void))
{
MPIR_Op *op_ptr;

MPIR_Op_get_ptr(op, op_ptr);
op_ptr->language = MPIR_LANG__CXX;
MPIR_Process.cxx_call_op_fn = (void (*)(const void *, void *, int,
MPI_Datatype, MPI_User_function *)) opcall;
}
#endif

int MPIR_Op_create_impl(MPI_User_function * user_fn, int commute, MPIR_Op ** p_op_ptr)
{
MPIR_Op *op_ptr;
Expand All @@ -43,7 +31,6 @@ int MPIR_Op_create_impl(MPI_User_function * user_fn, int commute, MPIR_Op ** p_o
}
/* --END ERROR HANDLING-- */

op_ptr->language = MPIR_LANG__C;
op_ptr->is_commute = commute;
op_ptr->kind = MPIR_OP_KIND__USER;
#ifndef BUILD_MPI_ABI
Expand Down
21 changes: 0 additions & 21 deletions src/mpi/coll/reduce_local/reduce_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ static void call_user_op_x(const void *inbuf, void *inoutbuf, MPI_Count count,
MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
}

#ifdef HAVE_CXX_BINDING
static void call_user_op_cxx(const void *inbuf, void *inoutbuf, int count, MPI_Datatype datatype,
MPI_User_function * uop)
{
/* Take off the global locks before calling user functions */
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
(*MPIR_Process.cxx_call_op_fn) (inbuf, inoutbuf, count, datatype, uop);
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 @@ -89,16 +78,6 @@ int MPIR_Reduce_local(const void *inbuf, void *inoutbuf, MPI_Aint count, MPI_Dat
} else {
MPIR_Op_get_ptr(op, op_ptr);

#ifdef HAVE_CXX_BINDING
if (op_ptr->language == MPIR_LANG__CXX) {
/* large count not supported */
MPIR_Assert(count <= INT_MAX);
MPIR_Assert(op_ptr->kind == MPIR_OP_KIND__USER);
call_user_op_cxx(inbuf, inoutbuf, (int) count, datatype,
(MPI_User_function *) op_ptr->function.c_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);
} else if (op_ptr->kind == MPIR_OP_KIND__USER_LARGE) {
Expand Down
53 changes: 3 additions & 50 deletions src/mpi/errhan/errutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,6 @@ void MPIR_Err_init(void)
did_err_init = TRUE;
}

/* Language Callbacks */

#ifdef HAVE_CXX_BINDING
/* This routine is used to install a callback used by the C++ binding
to invoke the (C++) error handler. The callback routine is a C routine,
defined in the C++ binding. */
void MPII_Errhandler_set_cxx(MPI_Errhandler errhand, void (*errcall) (void))
{
MPIR_Errhandler *errhand_ptr;

MPIR_Errhandler_get_ptr(errhand, errhand_ptr);
errhand_ptr->language = MPIR_LANG__CXX;
#ifndef BUILD_MPI_ABI
MPIR_Process.cxx_call_errfn = (void (*)(int, int *, int *, void (*)(void))) errcall;
#else
MPIR_Process.cxx_call_errfn = (void (*)(int, ABI_Comm *, int *, void (*)(void))) errcall;
#endif
}
#endif /* HAVE_CXX_BINDING */


/* ------------------------------------------------------------------------- */
/* Group 2: These routines are called on error exit from most
Expand Down Expand Up @@ -252,36 +232,9 @@ int MPIR_call_errhandler(MPIR_Errhandler * errhandler, int errorcode, MPIR_handl
#endif
}
break;
#ifdef HAVE_CXX_BINDING
case MPIR_LANG__CXX:
{
int cxx_kind = 0;
if (h.kind == MPIR_COMM) {
cxx_kind = 0;
} else if (h.kind == MPIR_WIN) {
cxx_kind = 2;
} else {
MPIR_Assert_error("kind not supported");
}
#ifndef BUILD_MPI_ABI
if (h.kind == MPIR_FILE) {
MPIR_Process.cxx_call_errfn(cxx_kind, (void *) &h.u.fh, &errorcode,
(void (*)(void)) errhandler->
errfn.C_File_Handler_function);
} else {
MPIR_Process.cxx_call_errfn(cxx_kind, &h.u.handle, &errorcode,
(void (*)(void)) errhandler->
errfn.C_Comm_Handler_function);
}
#else

MPIR_Process.cxx_call_errfn(cxx_kind, (void *) &abi_handle, &errorcode,
(void (*)(void)) errhandler->
errfn.C_Comm_Handler_function);
#endif
break;
}
#endif
default:
MPIR_Assert(0);
break;
}

fn_exit:
Expand Down

0 comments on commit ff1312d

Please sign in to comment.