/* Support for the parallel AIJ matrix vector multiply */ #include "mpiaij.h" #include "vec/vecimpl.h" #include "../seq/aij.h" int MPIAIJSetUpMultiply(Mat mat) { Matimpiaij *aij = (Matimpiaij *) mat->data; Matiaij *B = (Matiaij *) (aij->B->data); int N = aij->N,i,j,*indices,n = B->i[B->m] - 1,*aj = B->j; int ierr,ec = 0,*garray; IS from,to; Vec gvec; /* For the first stab we make an array as long as the number of columns */ /* mark those columns that are in aij->B */ indices = (int *) MALLOC( N*sizeof(int) ); CHKPTR(indices); MEMSET(indices,0,N*sizeof(int)); for ( i=0; ilvec); CHKERR(ierr); /* create two temporary Index sets fot build scatter gather */ ierr = ISCreateSequential(ec,garray,&from); CHKERR(ierr); ierr = ISCreateStrideSequential(ec,0,1,&to); CHKERR(ierr); /* create temporary global vector to generate scatter context */ /* this is inefficient, but otherwise we must do either 1) save garray until the first actual scatter when the vector is known or 2) have another way of generating a scatter context without a vector.*/ ierr = VecCreateMPI(aij->comm,aij->n,aij->N,&gvec); CHKERR(ierr); /* gnerate the scatter context */ ierr = VecScatterCtxCreate(gvec,from,aij->lvec,to,&aij->Mvctx); CHKERR(ierr); FREE(garray); ierr = ISDestroy(from); CHKERR(ierr); ierr = ISDestroy(to); CHKERR(ierr); ierr = VecDestroy(gvec); return 0; }