From: Augustin Degomme Date: Tue, 9 Apr 2013 16:19:00 +0000 (+0200) Subject: replace star_reduction by our own reduction X-Git-Tag: v3_9_90~412^2~25 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/89e44dce958ad9625570b126f11d299b829d4932 replace star_reduction by our own reduction --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 1bc2ee7c6e..2d6ba837b4 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -175,7 +175,6 @@ set(SMPI_SRC src/smpi/colls/reduce-flat-tree.c src/smpi/colls/reduce-NTSL.c src/smpi/colls/reduce-scatter-gather.c - src/smpi/colls/star-reduction.c ) if(SMPI_F2C) diff --git a/src/smpi/colls/allreduce-NTS.c b/src/smpi/colls/allreduce-NTS.c index c7e145de61..32ca68b7f6 100644 --- a/src/smpi/colls/allreduce-NTS.c +++ b/src/smpi/colls/allreduce-NTS.c @@ -69,7 +69,7 @@ smpi_coll_tuned_allreduce_NTS(void *sbuf, void *rbuf, int rcount, ((rank + size - 1) % size), tag + i, comm, &status); // compute result to rbuf+recv_offset - star_reduction(op, (char *)sbuf + recv_offset, (char *)rbuf + recv_offset, &count, &dtype); + smpi_op_apply(op, (char *)sbuf + recv_offset, (char *)rbuf + recv_offset, &count, &dtype); } // all-gather diff --git a/src/smpi/colls/allreduce-lr.c b/src/smpi/colls/allreduce-lr.c index a7f733690c..d5266292d0 100644 --- a/src/smpi/colls/allreduce-lr.c +++ b/src/smpi/colls/allreduce-lr.c @@ -75,7 +75,7 @@ smpi_coll_tuned_allreduce_lr(void *sbuf, void *rbuf, int rcount, ((rank + size - 1) % size), tag + i, comm, &status); // compute result to rbuf+recv_offset - star_reduction(op, (char *) sbuf + recv_offset, (char *) rbuf + recv_offset, + smpi_op_apply(op, (char *) sbuf + recv_offset, (char *) rbuf + recv_offset, &count, &dtype); } diff --git a/src/smpi/colls/allreduce-rab-rsag.c b/src/smpi/colls/allreduce-rab-rsag.c index 268ac8b80d..f13602060e 100644 --- a/src/smpi/colls/allreduce-rab-rsag.c +++ b/src/smpi/colls/allreduce-rab-rsag.c @@ -52,7 +52,7 @@ int smpi_coll_tuned_allreduce_rab_rsag(void *sbuff, void *rbuff, int count, // do the reduction on received data. since the // ordering is right, it doesn't matter whether // the operation is commutative or not. - star_reduction(op, tmp_buf, rbuff, &count, &dtype); + smpi_op_apply(op, tmp_buf, rbuff, &count, &dtype); // change the rank newrank = rank / 2; @@ -121,7 +121,7 @@ int smpi_coll_tuned_allreduce_rab_rsag(void *sbuff, void *rbuff, int count, // This algorithm is used only for predefined ops // and predefined ops are always commutative. - star_reduction(op, (char *) tmp_buf + disps[recv_idx] * extent, + smpi_op_apply(op, (char *) tmp_buf + disps[recv_idx] * extent, (char *) rbuff + disps[recv_idx] * extent, &recv_cnt, &dtype); diff --git a/src/smpi/colls/allreduce-rab1.c b/src/smpi/colls/allreduce-rab1.c index e57ac2fcd0..ae72f7491a 100644 --- a/src/smpi/colls/allreduce-rab1.c +++ b/src/smpi/colls/allreduce-rab1.c @@ -50,7 +50,7 @@ int smpi_coll_tuned_allreduce_rab1(void *sbuff, void *rbuff, smpi_mpi_sendrecv((char *) recv + send_idx * extent, send_cnt, dtype, dst, tag, tmp_buf, recv_cnt, dtype, dst, tag, comm, &status); - star_reduction(op, tmp_buf, (char *) recv + recv_idx * extent, &recv_cnt, + smpi_op_apply(op, tmp_buf, (char *) recv + recv_idx * extent, &recv_cnt, &dtype); // update send_idx for next iteration @@ -84,7 +84,7 @@ int smpi_coll_tuned_allreduce_rab1(void *sbuff, void *rbuff, smpi_mpi_sendrecv((char *) rbuff + send_idx * extent, send_cnt, dtype, dst, tag, tmp_buf, recv_cnt, dtype, dst, tag, comm, &status); - star_reduction(op, tmp_buf, (char *) rbuff + recv_idx * extent, &recv_cnt, + smpi_op_apply(op, tmp_buf, (char *) rbuff + recv_idx * extent, &recv_cnt, &dtype); // update send_idx for next iteration diff --git a/src/smpi/colls/allreduce-rab2.c b/src/smpi/colls/allreduce-rab2.c index ca1dee9147..982933c90e 100644 --- a/src/smpi/colls/allreduce-rab2.c +++ b/src/smpi/colls/allreduce-rab2.c @@ -45,7 +45,7 @@ int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff, memcpy(tmp, recv, nbytes); for (i = 1, s_offset = nbytes; i < nprocs; i++, s_offset = i * nbytes) - star_reduction(op, (char *) recv + s_offset, tmp, &send_size, &dtype); + smpi_op_apply(op, (char *) recv + s_offset, tmp, &send_size, &dtype); mpi_coll_allgather_fun(tmp, send_size, dtype, recv, send_size, dtype, comm); memcpy(rbuff, recv, count * s_extent); @@ -66,7 +66,7 @@ int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff, memcpy((char *) rbuff + r_offset, recv, nbytes); for (i = 1, s_offset = nbytes; i < nprocs; i++, s_offset = i * nbytes) - star_reduction(op, (char *) recv + s_offset, (char *) rbuff + r_offset, + smpi_op_apply(op, (char *) recv + s_offset, (char *) rbuff + r_offset, &send_size, &dtype); mpi_coll_allgather_fun((char *) rbuff + r_offset, send_size, dtype, rbuff, send_size, diff --git a/src/smpi/colls/allreduce-rdb.c b/src/smpi/colls/allreduce-rdb.c index bb9c82e3d1..f1fe9f6a5d 100644 --- a/src/smpi/colls/allreduce-rdb.c +++ b/src/smpi/colls/allreduce-rdb.c @@ -60,7 +60,7 @@ int smpi_coll_tuned_allreduce_rdb(void *sbuff, void *rbuff, int count, // do the reduction on received data. since the // ordering is right, it doesn't matter whether // the operation is commutative or not. - star_reduction(op, tmp_buf, rbuff, &count, &dtype); + smpi_op_apply(op, tmp_buf, rbuff, &count, &dtype); // change the rank newrank = rank / 2; @@ -98,10 +98,10 @@ int smpi_coll_tuned_allreduce_rdb(void *sbuff, void *rbuff, int count, // we assume it is commuttive op // if (op -> op_commute || (dst < rank)) if ((dst < rank)) { - star_reduction(op, tmp_buf, rbuff, &count, &dtype); + smpi_op_apply(op, tmp_buf, rbuff, &count, &dtype); } else // op is noncommutative and the order is not right { - star_reduction(op, rbuff, tmp_buf, &count, &dtype); + smpi_op_apply(op, rbuff, tmp_buf, &count, &dtype); // copy result back into recvbuf smpi_mpi_sendrecv(tmp_buf, count, dtype, rank, tag, rbuff, count, diff --git a/src/smpi/colls/allreduce-smp-binomial.c b/src/smpi/colls/allreduce-smp-binomial.c index 49bf0ab49c..cf68dfb647 100644 --- a/src/smpi/colls/allreduce-smp-binomial.c +++ b/src/smpi/colls/allreduce-smp-binomial.c @@ -73,7 +73,7 @@ int smpi_coll_tuned_allreduce_smp_binomial(void *send_buf, void *recv_buf, src = (inter_rank * num_core) + (intra_rank | mask); if (src < comm_size) { smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status); - star_reduction(op, tmp_buf, recv_buf, &count, &dtype); + smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype); } } else { dst = (inter_rank * num_core) + (intra_rank & (~mask)); @@ -92,7 +92,7 @@ int smpi_coll_tuned_allreduce_smp_binomial(void *send_buf, void *recv_buf, src = (inter_rank | mask) * num_core; if (src < comm_size) { smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status); - star_reduction(op, tmp_buf, recv_buf, &count, &dtype); + smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype); } } else { dst = (inter_rank & (~mask)) * num_core; diff --git a/src/smpi/colls/allreduce-smp-rdb.c b/src/smpi/colls/allreduce-smp-rdb.c index ee6037917e..d208584c01 100644 --- a/src/smpi/colls/allreduce-smp-rdb.c +++ b/src/smpi/colls/allreduce-smp-rdb.c @@ -71,7 +71,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count, src = (inter_rank * num_core) + (intra_rank | mask); if (src < comm_size) { smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status); - star_reduction(op, tmp_buf, recv_buf, &count, &dtype); + smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype); } } else { dst = (inter_rank * num_core) + (intra_rank & (~mask)); @@ -108,7 +108,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count, } else { src = rank - num_core; smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status); - star_reduction(op, tmp_buf, recv_buf, &count, &dtype); + smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype); newrank = inter_rank / 2; } } else { @@ -134,7 +134,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count, /* exchange data in rdb manner */ smpi_mpi_sendrecv(recv_buf, count, dtype, dst, tag, tmp_buf, count, dtype, dst, tag, comm, &status); - star_reduction(op, tmp_buf, recv_buf, &count, &dtype); + smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype); mask <<= 1; } } diff --git a/src/smpi/colls/allreduce-smp-rsag-lr.c b/src/smpi/colls/allreduce-smp-rsag-lr.c index dba0a065ff..fd49327c0d 100644 --- a/src/smpi/colls/allreduce-smp-rsag-lr.c +++ b/src/smpi/colls/allreduce-smp-rsag-lr.c @@ -66,7 +66,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_lr(void *send_buf, void *recv_buf, // if (src < ((inter_rank + 1) * num_core)) { if (src < comm_size) { smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status); - star_reduction(op, tmp_buf, recv_buf, &count, &dtype); + smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype); //printf("Node %d recv from node %d when mask is %d\n", rank, src, mask); } } else { @@ -124,7 +124,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_lr(void *send_buf, void *recv_buf, &status); // result is in rbuf - star_reduction(op, tmp_buf, (char *) recv_buf + recv_offset, &recv_count, + smpi_op_apply(op, tmp_buf, (char *) recv_buf + recv_offset, &recv_count, &dtype); } diff --git a/src/smpi/colls/allreduce-smp-rsag-rab.c b/src/smpi/colls/allreduce-smp-rsag-rab.c index af6871acaf..c98b78d84e 100644 --- a/src/smpi/colls/allreduce-smp-rsag-rab.c +++ b/src/smpi/colls/allreduce-smp-rsag-rab.c @@ -53,7 +53,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_rab(void *sbuf, void *rbuf, int count, // if (src < ((inter_rank + 1) * num_core)) { if (src < comm_size) { smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status); - star_reduction(op, tmp_buf, rbuf, &count, &dtype); + smpi_op_apply(op, tmp_buf, rbuf, &count, &dtype); //printf("Node %d recv from node %d when mask is %d\n", rank, src, mask); } } else { @@ -112,7 +112,7 @@ int smpi_coll_tuned_allreduce_smp_rsag_rab(void *sbuf, void *rbuf, int count, tmp_buf, curr_count, dtype, (dst * num_core), tag, comm, &status); - star_reduction(op, tmp_buf, (char *)rbuf + recv_offset, &curr_count, &dtype); + smpi_op_apply(op, tmp_buf, (char *)rbuf + recv_offset, &curr_count, &dtype); mask *= 2; curr_count /= 2; diff --git a/src/smpi/colls/allreduce-smp-rsag.c b/src/smpi/colls/allreduce-smp-rsag.c index 53d1a7f410..24ccaa0041 100644 --- a/src/smpi/colls/allreduce-smp-rsag.c +++ b/src/smpi/colls/allreduce-smp-rsag.c @@ -65,7 +65,7 @@ int smpi_coll_tuned_allreduce_smp_rsag(void *send_buf, void *recv_buf, // if (src < ((inter_rank + 1) * num_core)) { if (src < comm_size) { smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status); - star_reduction(op, tmp_buf, recv_buf, &count, &dtype); + smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype); //printf("Node %d recv from node %d when mask is %d\n", rank, src, mask); } } else { @@ -105,7 +105,7 @@ int smpi_coll_tuned_allreduce_smp_rsag(void *send_buf, void *recv_buf, &status); // result is in rbuf - star_reduction(op, tmp_buf, (char *) recv_buf + recv_offset, &seg_count, + smpi_op_apply(op, tmp_buf, (char *) recv_buf + recv_offset, &seg_count, &dtype); } diff --git a/src/smpi/colls/colls_private.h b/src/smpi/colls/colls_private.h index 5686a71282..66a2114be3 100644 --- a/src/smpi/colls/colls_private.h +++ b/src/smpi/colls/colls_private.h @@ -4,6 +4,5 @@ #include "colls.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_colls); -void star_reduction(MPI_Op op, void *src, void *target, int *count, MPI_Datatype *dtype); #endif diff --git a/src/smpi/colls/reduce-NTSL.c b/src/smpi/colls/reduce-NTSL.c index a4625335b2..5a3b8875c6 100644 --- a/src/smpi/colls/reduce-NTSL.c +++ b/src/smpi/colls/reduce-NTSL.c @@ -66,12 +66,12 @@ int smpi_coll_tuned_reduce_NTSL(void *buf, void *rbuf, int count, if (count <= segment) { if (rank == root) { smpi_mpi_recv(tmp_buf, count, datatype, from, tag, comm, &status); - star_reduction(op, tmp_buf, rbuf, &count, &datatype); + smpi_op_apply(op, tmp_buf, rbuf, &count, &datatype); } else if (rank == ((root - 1 + size) % size)) { smpi_mpi_send(rbuf, count, datatype, to, tag, comm); } else { smpi_mpi_recv(tmp_buf, count, datatype, from, tag, comm, &status); - star_reduction(op, tmp_buf, rbuf, &count, &datatype); + smpi_op_apply(op, tmp_buf, rbuf, &count, &datatype); smpi_mpi_send(rbuf, count, datatype, to, tag, comm); } free(tmp_buf); @@ -97,7 +97,7 @@ int smpi_coll_tuned_reduce_NTSL(void *buf, void *rbuf, int count, } for (i = 0; i < pipe_length; i++) { smpi_mpi_wait(&recv_request_array[i], &status); - star_reduction(op, tmp_buf + (i * increment), (char *)rbuf + (i * increment), + smpi_op_apply(op, tmp_buf + (i * increment), (char *)rbuf + (i * increment), &segment, &datatype); } } @@ -119,7 +119,7 @@ int smpi_coll_tuned_reduce_NTSL(void *buf, void *rbuf, int count, } for (i = 0; i < pipe_length; i++) { smpi_mpi_wait(&recv_request_array[i], &status); - star_reduction(op, tmp_buf + (i * increment), (char *)rbuf + (i * increment), + smpi_op_apply(op, tmp_buf + (i * increment), (char *)rbuf + (i * increment), &segment, &datatype); send_request_array[i] = smpi_mpi_isend((char *) rbuf + (i * increment), segment, datatype, to, (tag + i), comm); diff --git a/src/smpi/colls/reduce-arrival-pattern-aware.c b/src/smpi/colls/reduce-arrival-pattern-aware.c index 7c921af7a3..1e252504c9 100644 --- a/src/smpi/colls/reduce-arrival-pattern-aware.c +++ b/src/smpi/colls/reduce-arrival-pattern-aware.c @@ -129,7 +129,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, smpi_mpi_send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm); smpi_mpi_recv(tmp_buf, count, datatype, from, tag, comm, &status); - star_reduction(op, tmp_buf, rbuf, &count, &datatype); + smpi_op_apply(op, tmp_buf, rbuf, &count, &datatype); } } /* while loop */ } @@ -181,7 +181,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, from = header_buf[myordering - 1]; smpi_mpi_recv(tmp_buf, count, datatype, header_buf[myordering - 1], tag, comm, &status); - star_reduction(op, tmp_buf, rbuf, &count, &datatype); + smpi_op_apply(op, tmp_buf, rbuf, &count, &datatype); smpi_mpi_send(rbuf, count, datatype, to, tag, comm); } } /* non-root */ @@ -257,7 +257,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, for (i = 0; i < pipe_length; i++) { smpi_mpi_recv(tmp_buf + (i * increment), segment, datatype, from, tag, comm, &status); - star_reduction(op, tmp_buf + (i * increment), + smpi_op_apply(op, tmp_buf + (i * increment), (char *)rbuf + (i * increment), &segment, &datatype); } } @@ -311,7 +311,7 @@ int smpi_coll_tuned_reduce_arrival_pattern_aware(void *buf, void *rbuf, } for (i = 0; i < pipe_length; i++) { smpi_mpi_wait(&recv_request_array[i], MPI_STATUS_IGNORE); - star_reduction(op, tmp_buf + (i * increment), (char *)rbuf + (i * increment), + smpi_op_apply(op, tmp_buf + (i * increment), (char *)rbuf + (i * increment), &segment, &datatype); send_request_array[i]=smpi_mpi_isend((char *)rbuf + (i * increment), segment, datatype, to, tag, comm); } diff --git a/src/smpi/colls/reduce-binomial.c b/src/smpi/colls/reduce-binomial.c index 76fef91981..63de8fe932 100644 --- a/src/smpi/colls/reduce-binomial.c +++ b/src/smpi/colls/reduce-binomial.c @@ -35,7 +35,7 @@ int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, if (source < comm_size) { source = (source + root) % comm_size; smpi_mpi_recv(tmp_buf, count, datatype, source, tag, comm, &status); - star_reduction(op, tmp_buf, recvbuf, &count, &datatype); + smpi_op_apply(op, tmp_buf, recvbuf, &count, &datatype); } } else { dst = ((relrank & (~mask)) + root) % comm_size; diff --git a/src/smpi/colls/reduce-flat-tree.c b/src/smpi/colls/reduce-flat-tree.c index 7d178e1451..f304e78224 100644 --- a/src/smpi/colls/reduce-flat-tree.c +++ b/src/smpi/colls/reduce-flat-tree.c @@ -50,7 +50,7 @@ smpi_coll_tuned_reduce_flat_tree(void *sbuf, void *rbuf, int count, } /* Call reduction function. */ - star_reduction(op, inbuf, rbuf, &count, &dtype); + smpi_op_apply(op, inbuf, rbuf, &count, &dtype); } diff --git a/src/smpi/colls/reduce-scatter-gather.c b/src/smpi/colls/reduce-scatter-gather.c index 4dbcbf1327..fd1c5dccc9 100644 --- a/src/smpi/colls/reduce-scatter-gather.c +++ b/src/smpi/colls/reduce-scatter-gather.c @@ -56,7 +56,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, newrank = -1; } else { smpi_mpi_recv(tmp_buf, count, datatype, rank + 1, tag, comm, &status); - star_reduction(op, tmp_buf, recv_ptr, &new_count, &datatype); + smpi_op_apply(op, tmp_buf, recv_ptr, &new_count, &datatype); newrank = rank / 2; } } else /* rank >= 2*rem */ @@ -109,7 +109,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, /* tmp_buf contains data received in this step. recvbuf contains data accumulated so far */ - star_reduction(op, (char *) tmp_buf + disps[recv_idx] * extent, + smpi_op_apply(op, (char *) tmp_buf + disps[recv_idx] * extent, (char *) recv_ptr + disps[recv_idx] * extent, &recv_cnt, &datatype); @@ -233,7 +233,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, else { smpi_mpi_recv(tmp_buf, count, datatype, rank + 1, tag, comm, &status); - star_reduction(op, tmp_buf, recvbuf, &count, &datatype); + smpi_op_apply(op, tmp_buf, recvbuf, &count, &datatype); newrank = rank / 2; } } else /* rank >= 2*rem */ @@ -286,7 +286,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf, /* tmp_buf contains data received in this step. recvbuf contains data accumulated so far */ - star_reduction(op, (char *) tmp_buf + disps[recv_idx] * extent, + smpi_op_apply(op, (char *) tmp_buf + disps[recv_idx] * extent, (char *) recvbuf + disps[recv_idx] * extent, &recv_cnt, &datatype); diff --git a/src/smpi/colls/star-reduction.c b/src/smpi/colls/star-reduction.c deleted file mode 100644 index 2ca8149813..0000000000 --- a/src/smpi/colls/star-reduction.c +++ /dev/null @@ -1,334 +0,0 @@ -#include "colls_private.h" - -/* - * created by Pitch Patarasuk - * Modified by Xin Yuan - * - * realize a subset of MPI predefine operators: - * MPI_LAND, MPI_BAND: C integer, Fortran integer, Byte - * MPI_LOR, MPI_BOR: C integer, Fortran integer, Byte - * MPI_LXOR, MPI_BXOR: C integer, Fortran integer, Byte - * MPI_SUM, MPI_PROD: C integer, Fortran integer, Floating point - * MPI_MIN, MPI_MAX: C integer, Fortran integer, Floating point, Byte - * - * Types not implemented: MPI_LONG_DOUBLE, MPI_LOGICAL, MPI_COMPLEX - */ - -#ifndef STAR_REDUCTION -#define STAR_REDUCTION - - -#ifdef MPICH2_REDUCTION -extern MPI_User_function * MPIR_Op_table[]; -#elif defined MVAPICH_REDUCETION -extern void *MPIR_ToPointer(); -struct MPIR_OP -{ - MPI_User_function *op; - int commute; - int permanent; -}; -#endif - -static void star_generic_reduction(MPI_Op op, void *src, void *target, int *count, MPI_Datatype *dtype){ - int i; - if ((op == MPI_BOR) || (op == MPI_LOR)) { - if ((*dtype == MPI_BYTE) || (*dtype == MPI_CHAR)) { - for (i=0;i<*count;i++) { - ((char *)target)[i] |= ((char *)src)[i]; - } - } - else if ((*dtype == MPI_INT) - || (*dtype == MPI_LONG) - || (*dtype == MPI_INT) - || (*dtype == MPI_UNSIGNED) - || (*dtype == MPI_UNSIGNED_LONG)) { - for (i=0;i<*count;i++) { - ((int *)target)[i] |= ((int *)src)[i]; - } - } - else if ((*dtype == MPI_SHORT) - || (*dtype == MPI_UNSIGNED_SHORT)) { - for (i=0;i<*count;i++) { - ((short *)target)[i] |= ((short *)src)[i]; - } - } - else { - printf("reduction operation not supported\n"); - } - } - - else if ((op == MPI_BAND) || (op == MPI_LAND)) { - if ((*dtype == MPI_BYTE) || (*dtype == MPI_CHAR)) { - for (i=0;i<*count;i++) { - ((char *)target)[i] &= ((char *)src)[i]; - } - } - else if ((*dtype == MPI_INT) - || (*dtype == MPI_LONG) - || (*dtype == MPI_UNSIGNED) - || (*dtype == MPI_UNSIGNED_LONG)) { - for (i=0;i<*count;i++) { - ((int *)target)[i] &= ((int *)src)[i]; - } - } - else if ((*dtype == MPI_SHORT) - || (*dtype == MPI_UNSIGNED_SHORT)) { - for (i=0;i<*count;i++) { - ((short *)target)[i] &= ((short *)src)[i]; - } - } - else { - printf("reduction operation not supported\n"); - } - } - - - else if ((op == MPI_BXOR) || (op == MPI_LXOR)) { - if ((*dtype == MPI_BYTE) || (*dtype == MPI_CHAR)) { - for (i=0;i<*count;i++) { - ((char *)target)[i] ^= ((char *)src)[i]; - } - } - else if ((*dtype == MPI_INT) - || (*dtype == MPI_LONG) - || (*dtype == MPI_UNSIGNED) - || (*dtype == MPI_UNSIGNED_LONG)) { - for (i=0;i<*count;i++) { - ((int *)target)[i] ^= ((int *)src)[i]; - } - } - else if ((*dtype == MPI_SHORT) - || (*dtype == MPI_UNSIGNED_SHORT)) { - for (i=0;i<*count;i++) { - ((short *)target)[i] ^= ((short *)src)[i]; - } - } - else { - printf("reduction operation not supported\n"); - } - } - - else if (op == MPI_MAX) { - if ((*dtype == MPI_INT) - || (*dtype == MPI_LONG)) { - for (i=0;i<*count;i++) { - if (((int *)src)[i] > ((int *)target)[i]) { - ((int *)target)[i] = ((int *)src)[i]; - } - } - } - else if ((*dtype == MPI_UNSIGNED) - || (*dtype == MPI_UNSIGNED_LONG)) { - for (i=0;i<*count;i++) { - if (((unsigned int *)src)[i] > ((unsigned int *)target)[i]) { - ((unsigned int *)target)[i] = ((unsigned int *)src)[i]; - } - } - } - else if (*dtype == MPI_SHORT) { - for (i=0;i<*count;i++) { - if (((short *)src)[i] > ((short *)target)[i]) { - ((short *)target)[i] = ((short *)src)[i]; - } - } - } - else if (*dtype == MPI_UNSIGNED_SHORT) { - for (i=0;i<*count;i++) { - if (((unsigned short *)src)[i] > ((unsigned short *)target)[i]) { - ((unsigned short *)target)[i] = ((unsigned short *)src)[i]; - } - } - } - - else if (*dtype == MPI_DOUBLE) { - for (i=0;i<*count;i++) { - if (((double *)src)[i] > ((double *)target)[i]) { - ((double *)target)[i] = ((double *)src)[i]; - } - } - } - else if (*dtype == MPI_FLOAT) { - for (i=0;i<*count;i++) { - if (((float *)src)[i] > ((float *)target)[i]) { - ((float *)target)[i] = ((float *)src)[i]; - } - } - } - else if ((*dtype == MPI_CHAR) || (*dtype == MPI_BYTE)) { - for (i=0;i<*count;i++) { - if (((char *)src)[i] > ((char *)target)[i]) { - ((char *)target)[i] = ((char *)src)[i]; - } - } - } - else { - printf("reduction operation not supported\n"); - } - } - - - - else if (op == MPI_MIN) { - if ((*dtype == MPI_INT) - || (*dtype == MPI_LONG)) { - for (i=0;i<*count;i++) { - if (((int *)src)[i] < ((int *)target)[i]) { - ((int *)target)[i] = ((int *)src)[i]; - } - } - } - else if ((*dtype == MPI_UNSIGNED) - || (*dtype == MPI_UNSIGNED_LONG)) { - for (i=0;i<*count;i++) { - if (((unsigned int *)src)[i] < ((unsigned int *)target)[i]) { - ((unsigned int *)target)[i] = ((unsigned int *)src)[i]; - } - } - } - else if (*dtype == MPI_SHORT) { - for (i=0;i<*count;i++) { - if (((short *)src)[i] < ((short *)target)[i]) { - ((short *)target)[i] = ((short *)src)[i]; - } - } - } - else if (*dtype == MPI_UNSIGNED_SHORT) { - for (i=0;i<*count;i++) { - if (((unsigned short *)src)[i] < ((unsigned short *)target)[i]) { - ((unsigned short *)target)[i] = ((unsigned short *)src)[i]; - } - } - } - - else if (*dtype == MPI_DOUBLE) { - for (i=0;i<*count;i++) { - if (((double *)src)[i] < ((double *)target)[i]) { - ((double *)target)[i] = ((double *)src)[i]; - } - } - } - else if (*dtype == MPI_FLOAT) { - for (i=0;i<*count;i++) { - if (((float *)src)[i] < ((float *)target)[i]) { - ((float *)target)[i] = ((float *)src)[i]; - } - } - } - else if ((*dtype == MPI_CHAR) || (*dtype == MPI_BYTE)) { - for (i=0;i<*count;i++) { - if (((char *)src)[i] < ((char *)target)[i]) { - ((char *)target)[i] = ((char *)src)[i]; - } - } - } - else { - printf("reduction operation not supported\n"); - } - } - - - else if (op == MPI_SUM) { - if ((*dtype == MPI_INT) - || (*dtype == MPI_LONG)) { - for (i=0;i<*count;i++) { - ((int *)target)[i] += ((int *)src)[i]; - } - } - else if ((*dtype == MPI_UNSIGNED) - || (*dtype == MPI_UNSIGNED_LONG)) { - for (i=0;i<*count;i++) { - ((unsigned int *)target)[i] += ((unsigned int *)src)[i]; - } - } - else if (*dtype == MPI_SHORT) { - for (i=0;i<*count;i++) { - ((short *)target)[i] += ((short *)src)[i]; - } - } - else if (*dtype == MPI_UNSIGNED_SHORT) { - for (i=0;i<*count;i++) { - ((unsigned short *)target)[i] += ((unsigned short *)src)[i]; - } - } - - else if (*dtype == MPI_DOUBLE) { - for (i=0;i<*count;i++) { - ((double *)target)[i] += ((double *)src)[i]; - } - } - else if (*dtype == MPI_FLOAT) { - for (i=0;i<*count;i++) { - ((float *)target)[i] += ((float *)src)[i]; - } - } - else { - printf("reduction operation not supported\n"); - } - } - - else if (op == MPI_PROD) { - if ((*dtype == MPI_INT) - || (*dtype == MPI_LONG)) { - for (i=0;i<*count;i++) { - ((int *)target)[i] *= ((int *)src)[i]; - } - } - else if ((*dtype == MPI_UNSIGNED) - || (*dtype == MPI_UNSIGNED_LONG)) { - for (i=0;i<*count;i++) { - ((unsigned int *)target)[i] *= ((unsigned int *)src)[i]; - } - } - else if (*dtype == MPI_SHORT) { - for (i=0;i<*count;i++) { - ((short *)target)[i] *= ((short *)src)[i]; - } - } - else if (*dtype == MPI_UNSIGNED_SHORT) { - for (i=0;i<*count;i++) { - ((unsigned short *)target)[i] *= ((unsigned short *)src)[i]; - } - } - - else if (*dtype == MPI_DOUBLE) { - for (i=0;i<*count;i++) { - ((double *)target)[i] *= ((double *)src)[i]; - } - } - else if (*dtype == MPI_FLOAT) { - for (i=0;i<*count;i++) { - ((float *)target)[i] *= ((float *)src)[i]; - } - } - else { - printf("reduction operation not supported\n"); - } - } - - else { - printf("reduction operation not supported\n"); - } -} - -void star_reduction(MPI_Op op, void *src, void *target, int *count, MPI_Datatype *dtype){ - -#ifdef MPICH2_REDUCTION -MPI_User_function * uop = MPIR_Op_table[op % 16 - 1]; - return (*uop) (src,target,count,dtype); -#elif defined MVAPICH_REDUCTION -MPI_User_function *uop; -struct MPIR_OP *op_ptr; -op_ptr = MPIR_ToPointer(op); -uop = op_ptr->op; - return (*uop) (src,target,count,dtype); -#else - return star_generic_reduction(op,src,target,count,dtype); -#endif - - - -} - - -#endif