funceval
2009-08-14 13:54:53 UTC
Hi,
Does MPI_Reduce expect us to allocate memory to the receive buffer on
processors other than the root node? Is something like this guaranteed
to work:
int* local_sum = (int*)calloc(sizeof(int), count);
int* total_sum = 0;
//processor 0 is the root node
if (proc_id == 0)
{
total_sum = (int*)calloc(sizeof(int), count);
}
MPI_Reduce(local_sum, total_sum, count, MPI_INT, 0, MPI_COMM_WORLD);
free(local_sum);
if (proc_id == 0)
{
free(total_sum);
}
Does MPI_Reduce expect us to allocate memory to the receive buffer on
processors other than the root node? Is something like this guaranteed
to work:
int* local_sum = (int*)calloc(sizeof(int), count);
int* total_sum = 0;
//processor 0 is the root node
if (proc_id == 0)
{
total_sum = (int*)calloc(sizeof(int), count);
}
MPI_Reduce(local_sum, total_sum, count, MPI_INT, 0, MPI_COMM_WORLD);
free(local_sum);
if (proc_id == 0)
{
free(total_sum);
}