mask <<= 1;
}
-if (!is_commutative && (root != 0)){
- if (rank == 0){
- smpi_mpi_send(recvbuf, count, datatype, root,tag, comm);
- }else if (rank == root){
- smpi_mpi_recv(recvbuf, count, datatype, 0, tag, comm, &status);
+ if (!is_commutative && (root != 0)){
+ if (rank == 0){
+ smpi_mpi_send(recvbuf, count, datatype, root,tag, comm);
+ }else if (rank == root){
+ smpi_mpi_recv(recvbuf, count, datatype, 0, tag, comm, &status);
+ }
}
-}
+ if (rank != root) {
+ xbt_free(recvbuf);
+ }
free(tmp_buf);
return 0;
tmp_buf0=( void *)xbt_malloc( true_extent * total_count);
tmp_buf1=( void *)xbt_malloc( true_extent * total_count);
+ void *tmp_buf0_save=tmp_buf0;
+ void *tmp_buf1_save=tmp_buf1;
+
/* adjust for potential negative lower bound in datatype */
tmp_buf0 = (void *)((char*)tmp_buf0 - true_lb);
tmp_buf1 = (void *)((char*)tmp_buf1 - true_lb);
result_ptr = (char *)(buf0_was_inout ? tmp_buf0 : tmp_buf1) + recv_offset * true_extent;
mpi_errno = smpi_datatype_copy(result_ptr, size, datatype,
recvbuf, size, datatype);
+ xbt_free(tmp_buf0_save);
+ xbt_free(tmp_buf1_save);
if (mpi_errno) return(mpi_errno);
return MPI_SUCCESS;
}
}
}
- //smpi_datatype_free(&sendtype);
- //smpi_datatype_free(&recvtype);
+ smpi_datatype_free(&sendtype);
+ smpi_datatype_free(&recvtype);
mask <<= 1;
i++;
recvcounts[rank], datatype, recvbuf,
recvcounts[rank], datatype);
if (mpi_errno) return(mpi_errno);
+
xbt_free(disps);
xbt_free(tmp_recvbuf);
xbt_free(tmp_results);
for (i=0; i<size; i++)
sendbuf[i] = rank + i;
recvcounts = (int *)malloc( size * sizeof(int) );
- recvbuf = (int *)malloc( size * sizeof(int) );
+ recvbuf = (int *)malloc( size * sizeof(int) );
for (i=0; i<size; i++)
recvcounts[i] = 1;
MPI_Reduce_scatter( sendbuf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm );
if (rank == 0 && toterr == 0) {
printf( " No Errors\n" );
}
+ free(sendbuf);
+ free(recvcounts);
+ free(recvbuf);
+
MPI_Finalize( );
return toterr;