X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/15badc71ce964f6dae6428c9a4c0198fad5d4936..5f20336848afac691c04b1d5989b31589400883d:/src/smpi/colls/gather-ompi.c diff --git a/src/smpi/colls/gather-ompi.c b/src/smpi/colls/gather-ompi.c index 22e6e63dd9..46dc36e259 100644 --- a/src/smpi/colls/gather-ompi.c +++ b/src/smpi/colls/gather-ompi.c @@ -1,3 +1,9 @@ +/* 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. */ + /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,17 +15,13 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * $COPYRIGHT$ * * Additional copyrights may follow - * - * $HEADER$ */ #include "colls_private.h" #include "coll_tuned_topo.h" -#define MCA_COLL_BASE_TAG_GATHER 333 /* Todo: gather_intra_generic, gather_intra_binary, gather_intra_chain, * gather_intra_pipeline, segmentation? */ int @@ -75,7 +77,7 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, } else { /* root is not on 0, allocate temp buffer for recv, * rotate data at the end */ - tempbuf = (char *) malloc(rtrue_extent + (rcount*size - 1) * rextent); + tempbuf = (char *) smpi_get_tmp_recvbuffer(rtrue_extent + (rcount*size - 1) * rextent); if (NULL == tempbuf) { err= MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } @@ -97,7 +99,7 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, /* other non-leaf nodes, allocate temp buffer for data received from * children, the most we need is half of the total data elements due * to the property of binimoal tree */ - tempbuf = (char *) malloc(strue_extent + (scount*size - 1) * sextent); + tempbuf = (char *) smpi_get_tmp_sendbuffer(strue_extent + (scount*size - 1) * sextent); if (NULL == tempbuf) { err= MPI_ERR_OTHER; line = __LINE__; goto err_hndl; } @@ -136,8 +138,8 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, "smpi_coll_tuned_gather_ompi_binomial rank %d recv %d mycount = %d", rank, bmtree->tree_next[i], mycount); - smpi_mpi_recv(ptmp + total_recv*rextent, rcount*size-total_recv, rdtype, - bmtree->tree_next[i], MCA_COLL_BASE_TAG_GATHER, + smpi_mpi_recv(ptmp + total_recv*rextent, mycount, rdtype, + bmtree->tree_next[i], COLL_TAG_GATHER, comm, &status); total_recv += mycount; @@ -152,7 +154,7 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, smpi_mpi_send(ptmp, total_recv, sdtype, bmtree->tree_prev, - MCA_COLL_BASE_TAG_GATHER, + COLL_TAG_GATHER, comm); } if (rank == root) { @@ -167,17 +169,18 @@ smpi_coll_tuned_gather_ompi_binomial(void *sbuf, int scount, (char *) rbuf,rcount*root,rdtype); if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; } - free(tempbuf); + smpi_free_tmp_buffer(tempbuf); } } else if (!(vrank % 2)) { /* other non-leaf nodes */ - free(tempbuf); + smpi_free_tmp_buffer(tempbuf); } + xbt_free(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); @@ -243,16 +246,16 @@ smpi_coll_tuned_gather_ompi_linear_sync(void *sbuf, int scount, first_segment_count ); smpi_mpi_recv(sbuf, 0, MPI_BYTE, root, - MCA_COLL_BASE_TAG_GATHER, + COLL_TAG_GATHER, comm, MPI_STATUS_IGNORE); smpi_mpi_send(sbuf, first_segment_count, sdtype, root, - MCA_COLL_BASE_TAG_GATHER, + COLL_TAG_GATHER, comm); smpi_mpi_send((char*)sbuf + extent * first_segment_count, (scount - first_segment_count), sdtype, - root, MCA_COLL_BASE_TAG_GATHER, + root, COLL_TAG_GATHER, comm); } @@ -277,7 +280,6 @@ smpi_coll_tuned_gather_ompi_linear_sync(void *sbuf, int scount, COLL_TUNED_COMPUTED_SEGCOUNT( (size_t)first_segment_size, typelng, first_segment_count ); - ptmp = (char *) rbuf; for (i = 0; i < size; ++i) { if (i == rank) { /* skip myself */ @@ -288,18 +290,18 @@ smpi_coll_tuned_gather_ompi_linear_sync(void *sbuf, int scount, /* irecv for the first segment from i */ ptmp = (char*)rbuf + i * rcount * extent; first_segment_req = smpi_mpi_irecv(ptmp, first_segment_count, rdtype, i, - MCA_COLL_BASE_TAG_GATHER, comm + COLL_TAG_GATHER, comm ); /* send sync message */ smpi_mpi_send(rbuf, 0, MPI_BYTE, i, - MCA_COLL_BASE_TAG_GATHER, + COLL_TAG_GATHER, comm); /* irecv for the second segment */ ptmp = (char*)rbuf + (i * rcount + first_segment_count) * extent; reqs[i]=smpi_mpi_irecv(ptmp, (rcount - first_segment_count), - rdtype, i, MCA_COLL_BASE_TAG_GATHER, comm + rdtype, i, COLL_TAG_GATHER, comm ); /* wait on the first segment to complete */ @@ -316,6 +318,7 @@ smpi_coll_tuned_gather_ompi_linear_sync(void *sbuf, int scount, /* wait all second segments to complete */ ret = smpi_mpi_waitall(size, reqs, MPI_STATUSES_IGNORE); + if (ret != MPI_SUCCESS) { line = __LINE__; goto error_hndl; } free(reqs); } @@ -376,7 +379,7 @@ smpi_coll_tuned_gather_ompi_basic_linear(void *sbuf, int scount, if (rank != root) { smpi_mpi_send(sbuf, scount, sdtype, root, - MCA_COLL_BASE_TAG_GATHER, + COLL_TAG_GATHER, comm); return MPI_SUCCESS; } @@ -395,7 +398,7 @@ smpi_coll_tuned_gather_ompi_basic_linear(void *sbuf, int scount, } } else { smpi_mpi_recv(ptmp, rcount, rdtype, i, - MCA_COLL_BASE_TAG_GATHER, + COLL_TAG_GATHER, comm, MPI_STATUS_IGNORE); err = MPI_SUCCESS; }