|
SALSA Analysis Modules
|

Go to the source code of this file.
Functions | |
| int | MPIAllGatherIntV (int *array, int n, int **Array, int *N, MPI_Comm comm) |
Definition in file utils.c.
| int MPIAllGatherIntV | ( | int * | array, |
| int | n, | ||
| int ** | Array, | ||
| int * | N, | ||
| MPI_Comm | comm | ||
| ) |
Definition at line 8 of file utils.c.
Referenced by GetUpBiDiagSplits(), and MatSplitPoints().
{
int *sizes,*offsets,*result_array,ntids,i,ierr,s;
PetscFunctionBegin;
ierr = MPI_Comm_size(comm,&ntids);
ierr = PetscMalloc(ntids*sizeof(int),&sizes); CHKERRQ(ierr);
ierr = PetscMalloc(ntids*sizeof(int),&offsets); CHKERRQ(ierr);
ierr = MPI_Allgather(&n,1,MPI_INT,sizes,1,MPI_INT,comm);
s=0; for (i=0; i<ntids; i++) {offsets[i]=s; s+=sizes[i];} *N = s;
ierr = PetscMalloc((*N+1)*sizeof(int),&result_array); CHKERRQ(ierr);
result_array[0] = *N;
ierr = MPI_Allgatherv
((void*)array,n,MPI_INT,(void*)(result_array+1),
sizes,offsets,MPI_INT,comm); CHKERRQ(ierr);
ierr = PetscFree(sizes); CHKERRQ(ierr);
ierr = PetscFree(offsets); CHKERRQ(ierr);
*Array = result_array;
PetscFunctionReturn(0);
}
1.7.6.1