/*$Id: sbaijov.c,v 1.65 2001/08/06 21:15:42 bsmith Exp $*/ /* Routines to compute overlapping regions of a parallel MPI matrix. Used for finding submatrices that were shared across processors. */ #include "src/mat/impls/sbaij/mpi/mpisbaij.h" #include "petscbt.h" static int MatIncreaseOverlap_MPISBAIJ_Once(Mat,int,IS *); static int MatIncreaseOverlap_MPISBAIJ_Local(Mat,int *,int,int **,PetscBT*); #undef __FUNCT__ #define __FUNCT__ "MatIncreaseOverlap_MPISBAIJ" int MatIncreaseOverlap_MPISBAIJ(Mat C,int is_max,IS is[],int ov) { Mat_MPISBAIJ *c = (Mat_MPISBAIJ*)C->data; int i,ierr,N=C->N, bs=c->bs; IS *is_new; PetscFunctionBegin; ierr = PetscMalloc(is_max*sizeof(IS),&is_new);CHKERRQ(ierr); /* Convert the indices into block format */ ierr = ISCompressIndicesGeneral(N,bs,is_max,is,is_new);CHKERRQ(ierr); if (ov < 0){ SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Negative overlap specified\n");} for (i=0; idata; int len,*idx_i,isz,col,*n,*data1,*data2,*data2_i,*data,*data_i, size,rank,Mbs,i,j,k,ierr,nrqs,*odata1,*odata2, tag1,tag2,flag,proc_id,**odata2_ptr; char *t_p; MPI_Comm comm; MPI_Request *s_waits,r_req; MPI_Status *s_status,r_status; PetscBT *table; /* mark indices of this processor's is[] */ PetscBT table_i; PetscBT otable; /* mark indices of other processors' is[] */ PetscFunctionBegin; comm = C->comm; size = c->size; rank = c->rank; Mbs = c->Mbs; ierr = PetscObjectGetNewTag((PetscObject)C,&tag1);CHKERRQ(ierr); ierr = PetscObjectGetNewTag((PetscObject)C,&tag2);CHKERRQ(ierr); /* create tables for marking indices */ len = is_max*sizeof(PetscBT) + (Mbs/PETSC_BITS_PER_BYTE+1)*is_max*sizeof(char) + 1; ierr = PetscMalloc(len,&table);CHKERRQ(ierr); t_p = (char *)(table + is_max); for (i=0; idata; Mat_SeqSBAIJ *a = (Mat_SeqSBAIJ*)(c->A)->data; Mat_SeqBAIJ *b = (Mat_SeqBAIJ*)(c->B)->data; int ierr,row,mbs,Mbs,*nidx,*nidx_i,col,isz,isz0,*ai,*aj,*bi,*bj,*garray,rstart,l; int a_start,a_end,b_start,b_end,i,j,k,is_max,*idx_i,n; PetscBT table0; /* mark the indices of input is[] for look up */ PetscBT table_i; /* poits to i-th table. When whose=OTHER, a single table is used for all is[] */ PetscFunctionBegin; Mbs = c->Mbs; mbs = a->mbs; ai = a->i; aj = a->j; bi = b->i; bj = b->j; garray = c->garray; rstart = c->rstart; is_max = data[0]; ierr = PetscBTCreate(Mbs,table0);CHKERRQ(ierr); ierr = PetscMalloc((1+is_max*(Mbs+1))*sizeof(int),&nidx);CHKERRQ(ierr); nidx[0] = is_max; idx_i = data + is_max + 1; /* ptr to input is[0] array */ nidx_i = nidx + is_max + 1; /* ptr to output is[0] array */ for (i=0; i 0) { isz0 = 0; for (j=0; j= Mbs) SETERRQ2(PETSC_ERR_ARG_OUTOFRANGE,"index col %d >= Mbs %d",col,Mbs); if(!PetscBTLookupSet(table_i,col)) { ierr = PetscBTSet(table0,col);CHKERRQ(ierr); if (whose == MINE) {nidx_i[isz0] = col;} isz0++; } } if (whose == MINE) {isz = isz0;} k = 0; /* no. of indices from input is[i] that have been examined */ for (row=0; row= isz0) break; /* for (row=0; row 0) */ if (i < is_max - 1){ idx_i += n; /* ptr to input is[i+1] array */ nidx_i += isz; /* ptr to output is[i+1] array */ } nidx[1+i] = isz; /* size of new is[i] */ } /* for each is */ *data_new = nidx; ierr = PetscBTDestroy(table0);CHKERRQ(ierr); PetscFunctionReturn(0); }