#include <stdlib.h>
#include "petsc.h"
Go to the source code of this file.
Functions | |
int | MPIAllGatherIntV (int *array, int n, int **Array, int *N, MPI_Comm comm) |
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().
00009 { 00010 int *sizes,*offsets,*result_array,ntids,i,ierr,s; 00011 00012 PetscFunctionBegin; 00013 MPI_Comm_size(comm,&ntids); 00014 ierr = PetscMalloc(ntids*sizeof(int),&sizes); CHKERRQ(ierr); 00015 ierr = PetscMalloc(ntids*sizeof(int),&offsets); CHKERRQ(ierr); 00016 MPI_Allgather(&n,1,MPI_INT,sizes,1,MPI_INT,comm); 00017 s=0; for (i=0; i<ntids; i++) {offsets[i]=s; s+=sizes[i];} *N = s; 00018 ierr = PetscMalloc((*N+1)*sizeof(int),&result_array); CHKERRQ(ierr); 00019 result_array[0] = *N; 00020 ierr = MPI_Allgatherv 00021 ((void*)array,n,MPI_INT,(void*)(result_array+1), 00022 sizes,offsets,MPI_INT,comm); CHKERRQ(ierr); 00023 ierr = PetscFree(sizes); CHKERRQ(ierr); 00024 ierr = PetscFree(offsets); CHKERRQ(ierr); 00025 *Array = result_array; 00026 00027 PetscFunctionReturn(0); 00028 }