X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/40616078da72e823931c1fb884949054699ec39d..611d822b02f836d7abe031cced6adc4281ef4356:/src/smpi/colls/reduce/reduce-binomial.cpp diff --git a/src/smpi/colls/reduce/reduce-binomial.cpp b/src/smpi/colls/reduce/reduce-binomial.cpp index 05105b20f0..196e9faa1d 100644 --- a/src/smpi/colls/reduce/reduce-binomial.cpp +++ b/src/smpi/colls/reduce/reduce-binomial.cpp @@ -1,14 +1,16 @@ -/* Copyright (c) 2013-2014. The SimGrid Team. +/* Copyright (c) 2013-2018. 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 "../colls_private.hpp" +#include //#include - -int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, +namespace simgrid{ +namespace smpi{ +int Coll_reduce_binomial::reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) { @@ -30,9 +32,9 @@ int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent); int is_commutative = (op==MPI_OP_NULL || op->is_commutative()); mask = 1; - + int lroot; - if (is_commutative) + if (is_commutative) lroot = root; else lroot = 0; @@ -42,11 +44,11 @@ int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, /* adjust for potential negative lower bound in datatype */ tmp_buf = (void *)((char*)tmp_buf - true_lb); - + /* If I'm not the root, then my recvbuf may not be valid, therefore I have to allocate a temporary one */ if (rank != root) { - recvbuf = (void *) smpi_get_tmp_recvbuffer(count*(MAX(extent,true_extent))); + recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent)); recvbuf = (void *)((char*)recvbuf - true_lb); } if ((rank != root) || (sendbuf != MPI_IN_PLACE)) { @@ -60,7 +62,7 @@ int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, if (source < comm_size) { source = (source + lroot) % comm_size; Request::recv(tmp_buf, count, datatype, source, tag, comm, &status); - + if (is_commutative) { if(op!=MPI_OP_NULL) op->apply( tmp_buf, recvbuf, &count, datatype); } else { @@ -76,7 +78,7 @@ int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, mask <<= 1; } - if (!is_commutative && (root != 0)){ + if (not is_commutative && (root != 0)) { if (rank == 0){ Request::send(recvbuf, count, datatype, root,tag, comm); }else if (rank == root){ @@ -85,9 +87,11 @@ int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count, } if (rank != root) { - smpi_free_tmp_buffer(recvbuf); + smpi_free_tmp_buffer(recvbuf); } smpi_free_tmp_buffer(tmp_buf); return 0; } +} +}