max_real_segsize = true_extent + (max_segcount - 1) * extent;
/* Allocate and initialize temporary buffers */
- inbuf[0] = (char*)malloc(max_real_segsize);
+ inbuf[0] = (char*)smpi_get_tmp_sendbuffer(max_real_segsize);
if (NULL == inbuf[0]) { ret = -1; line = __LINE__; goto error_hndl; }
if (size > 2) {
- inbuf[1] = (char*)malloc(max_real_segsize);
+ inbuf[1] = (char*)smpi_get_tmp_recvbuffer(max_real_segsize);
if (NULL == inbuf[1]) { ret = -1; line = __LINE__; goto error_hndl; }
}
}
- if (NULL != inbuf[0]) free(inbuf[0]);
- if (NULL != inbuf[1]) free(inbuf[1]);
+ if (NULL != inbuf[0]) smpi_free_tmp_buffer(inbuf[0]);
+ if (NULL != inbuf[1]) smpi_free_tmp_buffer(inbuf[1]);
return MPI_SUCCESS;
error_hndl:
XBT_DEBUG("%s:%4d\tRank %d Error occurred %d\n",
__FILE__, line, rank, ret);
- if (NULL != inbuf[0]) free(inbuf[0]);
- if (NULL != inbuf[1]) free(inbuf[1]);
+ if (NULL != inbuf[0]) smpi_free_tmp_buffer(inbuf[0]);
+ if (NULL != inbuf[1]) smpi_free_tmp_buffer(inbuf[1]);
return ret;
}
} 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;
}
/* 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;
}
(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 */
messages. */
if (size > 1)
- origin = (char *) xbt_malloc(count * extent);
+ origin = (char *) smpi_get_tmp_recvbuffer(count * extent);
/* Initialize the receive buffer. */
}
if (origin)
- free(origin);
+ smpi_free_tmp_buffer(origin);
/* All done */
return 0;
}
} 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;
}
} else if (!(vrank % 2)) {
/* 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;
}
}
if (NULL != tempbuf)
- free(tempbuf);
+ smpi_free_tmp_buffer(tempbuf);
//!FIXME : store the tree, as done in ompi, instead of calculating it each time ?
xbt_free(bmtree);