+/* 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$
*/
#include "colls_private.h"
accumbuf = (char*)recvbuf;
if( (NULL == accumbuf) || (root != rank) ) {
/* Allocate temporary accumulator buffer. */
- accumbuf_free = (char*)malloc(true_extent +
+ accumbuf_free = (char*)smpi_get_tmp_sendbuffer(true_extent +
(original_count - 1) * extent);
if (accumbuf_free == NULL) {
line = __LINE__; ret = -1; goto error_hndl;
}
/* Allocate two buffers for incoming segments */
real_segment_size = true_extent + (count_by_segment - 1) * extent;
- inbuf_free[0] = (char*) malloc(real_segment_size);
+ inbuf_free[0] = (char*) smpi_get_tmp_recvbuffer(real_segment_size);
if( inbuf_free[0] == NULL ) {
line = __LINE__; ret = -1; goto error_hndl;
}
/* if there is chance to overlap communication -
allocate second buffer */
if( (num_segments > 1) || (tree->tree_nextsize > 1) ) {
- inbuf_free[1] = (char*) malloc(real_segment_size);
+ inbuf_free[1] = (char*) smpi_get_tmp_recvbuffer(real_segment_size);
if( inbuf_free[1] == NULL ) {
line = __LINE__; ret = -1; goto error_hndl;
}
} /* end of for each segment */
/* clean up */
- if( inbuf_free[0] != NULL) free(inbuf_free[0]);
- if( inbuf_free[1] != NULL) free(inbuf_free[1]);
- if( accumbuf_free != NULL ) free(accumbuf_free);
+ smpi_free_tmp_buffer(inbuf_free[0]);
+ smpi_free_tmp_buffer(inbuf_free[1]);
+ smpi_free_tmp_buffer(accumbuf_free);
}
/* leaf nodes
text=smpi_datatype_get_extent(datatype);
if ((root == rank) && (MPI_IN_PLACE == sendbuf)) {
- tmpbuf = (char *) malloc(text + (count - 1) * ext);
+ tmpbuf = (char *) smpi_get_tmp_sendbuffer(text + (count - 1) * ext);
if (NULL == tmpbuf) {
return MPI_ERR_INTERN;
}
(char*)tmpbuf, count, datatype);
use_this_sendbuf = tmpbuf;
} else if (io_root == rank) {
- tmpbuf = (char *) malloc(text + (count - 1) * ext);
+ tmpbuf = (char *) smpi_get_tmp_recvbuffer(text + (count - 1) * ext);
if (NULL == tmpbuf) {
return MPI_ERR_INTERN;
}
COLL_TAG_REDUCE, comm,
MPI_STATUS_IGNORE);
if (MPI_IN_PLACE == sendbuf) {
- free(use_this_sendbuf);
+ smpi_free_tmp_buffer(use_this_sendbuf);
}
} else if (io_root == rank) {
smpi_mpi_send(use_this_recvbuf, count, datatype, root,
COLL_TAG_REDUCE,
comm);
- free(use_this_recvbuf);
+ smpi_free_tmp_buffer(use_this_recvbuf);
}
}
smpi_mpi_send(sbuf, count, dtype, root,
COLL_TAG_REDUCE,
comm);
- return -1;
+ return MPI_SUCCESS;
}
/* see discussion in ompi_coll_basic_reduce_lin_intra about
if (MPI_IN_PLACE == sbuf) {
sbuf = rbuf;
- inplace_temp = (char*)malloc(true_extent + (count - 1) * extent);
+ inplace_temp = (char*)smpi_get_tmp_recvbuffer(true_extent + (count - 1) * extent);
if (NULL == inplace_temp) {
return -1;
}
}
if (size > 1) {
- free_buffer = (char*)malloc(true_extent + (count - 1) * extent);
+ free_buffer = (char*)smpi_get_tmp_recvbuffer(true_extent + (count - 1) * extent);
pml_buffer = free_buffer - lb;
}
if (NULL != inplace_temp) {
smpi_datatype_copy(inplace_temp, count, dtype,(char*)sbuf
,count , dtype);
- free(inplace_temp);
+ smpi_free_tmp_buffer(inplace_temp);
}
if (NULL != free_buffer) {
- free(free_buffer);
+ smpi_free_tmp_buffer(free_buffer);
}
/* All done */