+/* 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
* 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$
*/
}
} else {
/* root is not on 0, allocate temp buffer for send */
- 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;
}
}
total_send = scount;
} else if (!(vrank % 2)) {
- /* non-root, non-leaf nodes, allocte temp buffer for recv
+ /* non-root, non-leaf nodes, allocate temp buffer for recv
* the most we need is rcount*size/2 */
- 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;
}
smpi_mpi_recv(ptmp, rcount*size, rdtype, bmtree->tree_prev,
COLL_TAG_SCATTER, comm, &status);
/* local copy to rbuf */
- err = smpi_datatype_copy(ptmp, scount, sdtype,
- rbuf, rcount, rdtype);
+ smpi_datatype_copy(ptmp, scount, sdtype, rbuf, rcount, rdtype);
}
/* send to children on all non-leaf */
for (i = 0; i < bmtree->tree_nextsize; i++) {
total_send += mycount;
}
- if (NULL != tempbuf)
- free(tempbuf);
+
} else {
/* recv from parent on leaf nodes */
smpi_mpi_recv(ptmp, rcount, rdtype, bmtree->tree_prev,
COLL_TAG_SCATTER, comm, &status);
}
+
+ if (NULL != tempbuf)
+ smpi_free_tmp_buffer(tempbuf);
//!FIXME : store the tree, as done in ompi, instead of calculating it each time ?
xbt_free(bmtree);