[petsc-dev] MatCreateVecs interface

Stefano Zampini stefano.zampini at gmail.com
Thu Jun 25 14:10:36 CDT 2015


Yes. With this approach, only MatNest will need a specialized getvecs operation and we can get rid of the others.

On Jun 25, 2015, at 7:06 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

> 
>> On Jun 25, 2015, at 12:32 PM, Stefano Zampini <stefano.zampini at gmail.com> wrote:
>> 
>> pushed a fix
>> https://bitbucket.org/petsc/petsc/commits/ae287a2e7a141494f7c41f9dd537addb63b556e3
>> 
>> However, it appears that the functions below for CUSP, CUSPARSE and VIENNACL are mere copies of the interface.
>> What  about defining the type of the Vec in the interface and get rid of these?
> 
>   What do you mean by "the type of Vec in the interface"?   Do you mean have a method such as
> 
> MatGetDefaultVecType(mat,const VecType *vtype);
> 
> that defines the default vector type compatible with the matrix?  So we could have 
> 
> #undef __FUNCT__
> #define __FUNCT__ "MatCreateVecs_Default"
> PetscErrorCode  MatCreateVecs_Default(Mat mat,Vec *right,Vec *left)
> {
>  PetscErrorCode ierr;
>  PetscInt rbs,cbs;
>  const VecType vtype;
> 
>  PetscFunctionBegin;
>  ierr = MatGetDefaultVecType(mat,&vtype);CHKERRQ(ierr);
>  ierr = MatGetBlockSizes(mat,&rbs,&cbs);CHKERRQ(ierr);
>  if (right) {
>    ierr = VecCreate(PetscObjectComm((PetscObject)mat),right);CHKERRQ(ierr);
>    ierr = VecSetSizes(*right,mat->cmap->n,PETSC_DETERMINE);CHKERRQ(ierr);
>    ierr = VecSetBlockSize(*right,cbs);CHKERRQ(ierr);
>    ierr = VecSetType(*right,vtype);CHKERRQ(ierr);
>    ierr = VecSetLayout(*right,mat->cmap);CHKERRQ(ierr);
>  }
>  if (left) {
>    ierr = VecCreate(PetscObjectComm((PetscObject)mat),left);CHKERRQ(ierr);
>    ierr = VecSetSizes(*left,mat->rmap->n,PETSC_DETERMINE);CHKERRQ(ierr);
>    ierr = VecSetBlockSize(*left,rbs);CHKERRQ(ierr);
>    ierr = VecSetType(*left,vtype);CHKERRQ(ierr);
>    ierr = VecSetLayout(*left,mat->rmap);CHKERRQ(ierr);
>  }
>  PetscFunctionReturn(0);
> }
> 
> or something else?
> 
>  Barry
> 
> 
>> 
>> src/mat/impls/aij/mpi/mpicusp/mpiaijcusp.cu:  A->ops->getvecs        = MatCreateVecs_MPIAIJCUSP;
>> src/mat/impls/aij/mpi/mpicusparse/mpiaijcusparse.cu:  A->ops->getvecs        = MatCreateVecs_MPIAIJCUSPARSE;
>> src/mat/impls/aij/mpi/mpiviennacl/mpiaijviennacl.cxx:  A->ops->getvecs        = MatCreateVecs_MPIAIJViennaCL;
>> src/mat/impls/aij/seq/seqcusp/aijcusp.cu:  B->ops->getvecs        = MatCreateVecs_SeqAIJCUSP;
>> src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu:  B->ops->getvecs          = MatCreateVecs_SeqAIJCUSPARSE;
>> src/mat/impls/aij/seq/seqviennacl/aijviennacl.cxx:  B->ops->getvecs        = MatCreateVecs_SeqAIJViennaCL;
>> 
>> Stefano
>> 
>> 
>> On Jun 25, 2015, at 4:34 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>>> 
>>> I think you are right, go ahead and make a pull request or send a patch
>>> 
>>> Barry
>>> 
>>>> On Jun 25, 2015, at 9:43 AM, Stefano Zampini <stefano.zampini at gmail.com> wrote:
>>>> 
>>>> Why the current interface in MatCreateVecs requires that a matrix has been already either allocated or setup ?
>>>> Shouldn’t be enough to check if the layout has been already setup?
>>>> 
>>>> Stefano
>>>> 
>>> 
>> 
> 




More information about the petsc-dev mailing list