X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d155fd69fa99c97b3a9c86bb7f2e472c2e7332df..cd9affe6152d6bbec19a72ea6fe26ab9407b51b7:/src/smpi/colls/allreduce-rab2.c diff --git a/src/smpi/colls/allreduce-rab2.c b/src/smpi/colls/allreduce-rab2.c index d09cd1126a..3643321239 100644 --- a/src/smpi/colls/allreduce-rab2.c +++ b/src/smpi/colls/allreduce-rab2.c @@ -1,4 +1,10 @@ -#include "colls.h" +/* Copyright (c) 2013-2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#include "colls_private.h" //#include // this requires that count >= NP @@ -20,11 +26,11 @@ int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff, uop = op_ptr->op; #endif */ - MPI_Comm_rank(comm, &rank); - MPI_Comm_size(comm, &nprocs); + rank = smpi_comm_rank(comm); + nprocs = smpi_comm_size(comm); - MPI_Type_extent(dtype, &s_extent); + s_extent = smpi_datatype_get_extent(dtype); // uneven count if (count % nprocs) { @@ -34,20 +40,20 @@ int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff, send_size = (count + nprocs) / nprocs; nbytes = send_size * s_extent; - send = (void *) malloc(s_extent * send_size * nprocs); - recv = (void *) malloc(s_extent * send_size * nprocs); - tmp = (void *) malloc(nbytes); + send = (void *) xbt_malloc(s_extent * send_size * nprocs); + recv = (void *) xbt_malloc(s_extent * send_size * nprocs); + tmp = (void *) xbt_malloc(nbytes); memcpy(send, sbuff, s_extent * count); - MPI_Alltoall(send, send_size, dtype, recv, send_size, dtype, comm); + mpi_coll_alltoall_fun(send, send_size, dtype, recv, send_size, dtype, comm); 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_Allgather(tmp, send_size, dtype, recv, send_size, dtype, comm); + mpi_coll_allgather_fun(tmp, send_size, dtype, recv, send_size, dtype, comm); memcpy(rbuff, recv, count * s_extent); free(recv); @@ -59,20 +65,20 @@ int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff, nbytes = send_size * s_extent; r_offset = rank * nbytes; - recv = (void *) malloc(s_extent * send_size * nprocs); + recv = (void *) xbt_malloc(s_extent * send_size * nprocs); - MPI_Alltoall(send, send_size, dtype, recv, send_size, dtype, comm); + mpi_coll_alltoall_fun(send, send_size, dtype, recv, send_size, dtype, comm); 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_Allgather((char *) rbuff + r_offset, send_size, dtype, rbuff, send_size, + mpi_coll_allgather_fun((char *) rbuff + r_offset, send_size, dtype, rbuff, send_size, dtype, comm); free(recv); } - return 0; + return MPI_SUCCESS; }