X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d20f024dba9ff1e9c8822237caaf963b9e913889..271068c7d949ed959313b055466e13539485bc2c:/src/smpi/colls/scatter/scatter-ompi.cpp?ds=sidebyside diff --git a/src/smpi/colls/scatter/scatter-ompi.cpp b/src/smpi/colls/scatter/scatter-ompi.cpp index 89737b61c5..50d24eb7f9 100644 --- a/src/smpi/colls/scatter/scatter-ompi.cpp +++ b/src/smpi/colls/scatter/scatter-ompi.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. +/* Copyright (c) 2013-2019. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -25,8 +25,8 @@ namespace simgrid{ namespace smpi{ -int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, - MPI_Datatype rdtype, int root, MPI_Comm comm) +int scatter__ompi_binomial(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, + MPI_Datatype rdtype, int root, MPI_Comm comm) { int line = -1; int i; @@ -34,8 +34,9 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt int vrank; int size; int total_send = 0; - char *ptmp = NULL; - char *tempbuf = NULL; + unsigned char* ptmp = nullptr; + unsigned char* tempbuf = nullptr; + const unsigned char* cptmp; // const ptmp int err; ompi_coll_tree_t* bmtree; MPI_Status status; @@ -63,7 +64,8 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt if (rank == root) { if (0 == root) { /* root on 0, just use the send buffer */ - ptmp = (char*)sbuf; + ptmp = nullptr; // unused + cptmp = static_cast(sbuf); if (rbuf != MPI_IN_PLACE) { /* local copy to rbuf */ err = Datatype::copy(sbuf, scount, sdtype, rbuf, rcount, rdtype); @@ -74,14 +76,15 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt } } else { /* root is not on 0, allocate temp buffer for send */ - tempbuf = (char*)smpi_get_tmp_sendbuffer(strue_extent + (scount * size - 1) * sextent); - if (NULL == tempbuf) { + tempbuf = smpi_get_tmp_sendbuffer(strue_extent + (scount * size - 1) * sextent); + if (nullptr == tempbuf) { err = MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } - ptmp = tempbuf - slb; + ptmp = tempbuf - slb; + cptmp = ptmp; /* and rotate data so they will eventually in the right place */ err = Datatype::copy((char*)sbuf + sextent * root * scount, scount * (size - root), sdtype, ptmp, @@ -111,14 +114,15 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt } else if (not(vrank % 2)) { /* non-root, non-leaf nodes, allocate temp buffer for recv * the most we need is rcount*size/2 */ - tempbuf = (char*)smpi_get_tmp_recvbuffer(rtrue_extent + (rcount * size - 1) * rextent); - if (NULL == tempbuf) { + tempbuf = smpi_get_tmp_recvbuffer(rtrue_extent + (rcount * size - 1) * rextent); + if (nullptr == tempbuf) { err = MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } - ptmp = tempbuf - rlb; + ptmp = tempbuf - rlb; + cptmp = ptmp; sdtype = rdtype; scount = rcount; @@ -126,7 +130,8 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt total_send = scount; } else { /* leaf nodes, just use rbuf */ - ptmp = (char*)rbuf; + ptmp = static_cast(rbuf); + cptmp = ptmp; } if (not(vrank % 2)) { @@ -146,7 +151,7 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt mycount = size - vkid; mycount *= scount; - Request::send(ptmp + total_send * sextent, mycount, sdtype, bmtree->tree_next[i], COLL_TAG_SCATTER, comm); + Request::send(cptmp + total_send * sextent, mycount, sdtype, bmtree->tree_next[i], COLL_TAG_SCATTER, comm); total_send += mycount; } @@ -156,16 +161,14 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt Request::recv(ptmp, rcount, rdtype, bmtree->tree_prev, COLL_TAG_SCATTER, comm, &status); } - if (NULL != tempbuf) - smpi_free_tmp_buffer(tempbuf); + smpi_free_tmp_buffer(tempbuf); // not FIXME : store the tree, as done in ompi, instead of calculating it each time ? - xbt_free(bmtree); + ompi_coll_tuned_topo_destroy_tree(&bmtree); return MPI_SUCCESS; err_hndl: - if (NULL != tempbuf) - free(tempbuf); + smpi_free_tmp_buffer(tempbuf); XBT_DEBUG("%s:%4d\tError occurred %d, rank %2d", __FILE__, line, err, rank); return err; @@ -191,8 +194,8 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt * Accepts: - same arguments as MPI_Scatter() * Returns: - MPI_SUCCESS or error code */ -int Coll_scatter_ompi_basic_linear::scatter(void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, - MPI_Datatype rdtype, int root, MPI_Comm comm) +int scatter__ompi_basic_linear(const void* sbuf, int scount, MPI_Datatype sdtype, void* rbuf, int rcount, + MPI_Datatype rdtype, int root, MPI_Comm comm) { int i, rank, size, err; char *ptmp;