-#include "colls.h"
+#include "colls_private.h"
#ifndef REDUCE_STUFF
#define REDUCE_STUFF
/*****************************************************************************
MPI_Status status;
void *tmp_buf = NULL;
MPI_User_function *func = get_op_func(op);
- MPI_Comm_size(comm, &nprocs);
- MPI_Comm_rank(comm, &rank);
-
- MPI_Type_extent(dtype, &extent);
- tmp_buf = (void *) malloc(count * extent);
- if (!tmp_buf) {
- printf("Could not allocate memory for tmp_buf\n");
- return 1;
- }
+ nprocs = smpi_comm_size(comm);
+ rank = smpi_comm_rank(comm);
+
+ extent = smpi_datatype_get_extent(dtype);
+ tmp_buf = (void *) xbt_malloc(count * extent);
MPIR_Localcopy(sbuff, count, dtype, rbuff, count, dtype);
- MPI_Type_size(dtype, &type_size);
+ type_size = smpi_datatype_size(dtype);
// find nearest power-of-two less than or equal to comm_size
pof2 = 1;
// reduce-scatter, calculate the count that each process receives
// and the displacement within the buffer
- cnts = (int *) malloc(pof2 * sizeof(int));
- disps = (int *) malloc(pof2 * sizeof(int));
+ cnts = (int *) xbt_malloc(pof2 * sizeof(int));
+ disps = (int *) xbt_malloc(pof2 * sizeof(int));
for (i = 0; i < (pof2 - 1); i++)
cnts[i] = count / pof2;
}
free(tmp_buf);
- return 0;
+ return MPI_SUCCESS;
}