Commit b18e3549 authored by James Dinan's avatar James Dinan
Browse files

[svn-r10145] Added macros for indexing Op tables.

Pulled bit manipulation arithmetic into macros for converting handles to
indices in MPIR_Op and MPIR_Op_check_dtype function pointer tables.

Reviewer: buntinas
parent 161d84ca
......@@ -3831,6 +3831,9 @@ extern MPI_User_function *MPIR_Op_table[];
typedef int (MPIR_Op_check_dtype_fn) ( MPI_Datatype );
extern MPIR_Op_check_dtype_fn *MPIR_Op_check_dtype_table[];
#define MPIR_OP_HDL_TO_FN(op) MPIR_Op_table[((op)&0xf) - 1]
#define MPIR_OP_HDL_TO_DTYPE_FN(op) MPIR_Op_check_dtype_table[((op)&0xf) - 1]
#if !defined MPIR_MIN
#define MPIR_MIN(a,b) (((a)>(b))?(b):(a))
#endif /* MPIR_MIN */
......
......@@ -829,7 +829,7 @@ int MPI_Allreduce(MPICH2_CONST void *sendbuf, void *recvbuf, int count,
}
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno =
( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
if (count != 0) {
MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
......
......@@ -364,7 +364,7 @@ int MPI_Exscan(MPICH2_CONST void *sendbuf, void *recvbuf, int count, MPI_Datatyp
}
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno =
( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
......
......@@ -746,7 +746,7 @@ int MPIX_Iallreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype
MPID_Op_valid_ptr(op_ptr, mpi_errno);
}
else if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno = ( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
mpi_errno = ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
if (comm_ptr->comm_kind == MPID_INTERCOMM)
......
......@@ -284,7 +284,7 @@ int MPIX_Iexscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype dat
MPID_Op_valid_ptr(op_ptr, mpi_errno);
}
else if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno = ( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
mpi_errno = ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
......
......@@ -1102,7 +1102,7 @@ int MPIX_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcoun
MPID_Op_valid_ptr(op_ptr, mpi_errno);
}
else if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno = ( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
mpi_errno = ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
......
......@@ -1011,7 +1011,7 @@ int MPIX_Ireduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount
MPID_Op_valid_ptr(op_ptr, mpi_errno);
}
else if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno = ( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
mpi_errno = ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
......
......@@ -862,7 +862,7 @@ int MPIX_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype dat
MPID_Op_valid_ptr(op_ptr, mpi_errno);
}
else if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno = ( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
mpi_errno = ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
......
......@@ -418,7 +418,7 @@ int MPIX_Iscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
MPID_Op_valid_ptr(op_ptr, mpi_errno);
}
else if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno = ( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
mpi_errno = ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
......
......@@ -1184,7 +1184,7 @@ int MPI_Reduce_scatter(MPICH2_CONST void *sendbuf, void *recvbuf, MPICH2_CONST i
}
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno =
( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
......
......@@ -1150,7 +1150,7 @@ int MPI_Reduce_scatter_block(MPICH2_CONST void *sendbuf, void *recvbuf,
}
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno =
( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
......
......@@ -1184,7 +1184,7 @@ int MPI_Reduce(MPICH2_CONST void *sendbuf, void *recvbuf, int count, MPI_Datatyp
}
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno =
( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
......
......@@ -49,7 +49,7 @@ int MPIR_Reduce_local_impl(const void *inbuf, void *inoutbuf, int count, MPI_Dat
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
/* get the function by indexing into the op table */
uop = MPIR_Op_table[op%16 - 1];
uop = MPIR_OP_HDL_TO_FN(op);
}
else {
MPID_Op_get_ptr(op, op_ptr);
......@@ -164,7 +164,7 @@ int MPI_Reduce_local(MPICH2_CONST void *inbuf, void *inoutbuf, int count, MPI_Da
MPID_Op_valid_ptr( op_ptr, mpi_errno );
}
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno = (*MPIR_Op_check_dtype_table[op%16 - 1])(datatype);
mpi_errno = (*MPIR_OP_HDL_TO_DTYPE_FN(op))(datatype);
}
if (count != 0) {
MPIR_ERRTEST_ALIAS_COLL(inbuf, inoutbuf, mpi_errno);
......
......@@ -546,7 +546,7 @@ int MPI_Scan(MPICH2_CONST void *sendbuf, void *recvbuf, int count, MPI_Datatype
}
if (HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) {
mpi_errno =
( * MPIR_Op_check_dtype_table[op%16 - 1] )(datatype);
( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype);
}
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
......
......@@ -627,7 +627,7 @@ static int do_accumulate_op(MPID_Request *rreq)
if (HANDLE_GET_KIND(rreq->dev.op) == HANDLE_KIND_BUILTIN)
{
/* get the function by indexing into the op table */
uop = MPIR_Op_table[((rreq->dev.op)&0xf) - 1];
uop = MPIR_OP_HDL_TO_FN(rreq->dev.op);
}
else
{
......@@ -952,7 +952,7 @@ static int do_simple_accumulate(MPIDI_PT_single_op *single_op)
if (HANDLE_GET_KIND(single_op->op) == HANDLE_KIND_BUILTIN)
{
/* get the function by indexing into the op table */
uop = MPIR_Op_table[((single_op->op)&0xf) - 1];
uop = MPIR_OP_HDL_TO_FN(single_op->op);
}
else
{
......
......@@ -70,7 +70,7 @@ int MPIDI_Get_accumulate(const void *origin_addr, int origin_count,
"**opnotpredefined %d", op );
/* get the function by indexing into the op table */
uop = MPIR_Op_table[((op)&0xf) - 1];
uop = MPIR_OP_HDL_TO_FN(op);
if (origin_predefined && target_predefined) {
/* Cast away const'ness for origin_address in order to
......
......@@ -355,7 +355,7 @@ int MPIDI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype
"**opnotpredefined %d", op );
/* get the function by indexing into the op table */
uop = MPIR_Op_table[((op)&0xf) - 1];
uop = MPIR_OP_HDL_TO_FN(op);
if (origin_predefined && target_predefined)
{
......
......@@ -2926,7 +2926,7 @@ int MPIDI_CH3_PktHandler_Accumulate_Immed( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
if (HANDLE_GET_KIND(accum_pkt->op) == HANDLE_KIND_BUILTIN) {
MPI_User_function *uop;
/* get the function by indexing into the op table */
uop = MPIR_Op_table[((accum_pkt->op)&0xf) - 1];
uop = MPIR_OP_HDL_TO_FN(accum_pkt->op);
(*uop)(accum_pkt->data, accum_pkt->addr,
&(accum_pkt->count), &(accum_pkt->datatype));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment