[petsc-dev] MatPinToCPU

Smith, Barry F. bsmith at mcs.anl.gov
Tue Jul 23 20:18:13 CDT 2019


 
 Yes, it needs to be able to switch back and forth between the CPU and GPU methods so you need to move into it the setting of the methods that is currently directly in the create method. See how  MatConvert_SeqAIJ_SeqAIJViennaCL() calls ierr = MatPinToCPU_SeqAIJViennaCL(A,PETSC_FALSE);CHKERRQ(ierr); to set the methods for the GPU initially.

  Barry


> On Jul 23, 2019, at 7:32 PM, Mark Adams <mfadams at lbl.gov> wrote:
> 
> 
>   What are the symptoms of it not working? Does it appear to be still copying the matrices to the GPU? then running the functions on the GPU?
> 
> 
> The object is dispatching the CUDA mat-vec etc.
> 
>   I suspect the pinning is incompletely done for CUDA (and MPIOpenCL) matrices. 
> 
> 
> Yes, git grep MatPinToCPU shows stuff for ViennaCL but not CUDA.
> 
> I guess I can add something like this below. Do we need to set the device methods? They are already set when this method is set, right?
>  
> We need the equivalent of 
> 
> static PetscErrorCode MatPinToCPU_SeqAIJViennaCL(Mat A,PetscBool flg)
> {
>   PetscFunctionBegin;
>   A->pinnedtocpu = flg;
>   if (flg) {
>     A->ops->mult           = MatMult_SeqAIJ;
>     A->ops->multadd        = MatMultAdd_SeqAIJ;
>     A->ops->assemblyend    = MatAssemblyEnd_SeqAIJ;
>     A->ops->duplicate      = MatDuplicate_SeqAIJ;
>   } else {
>     A->ops->mult           = MatMult_SeqAIJViennaCL;
>     A->ops->multadd        = MatMultAdd_SeqAIJViennaCL;
>     A->ops->assemblyend    = MatAssemblyEnd_SeqAIJViennaCL;
>     A->ops->destroy        = MatDestroy_SeqAIJViennaCL;
>     A->ops->duplicate      = MatDuplicate_SeqAIJViennaCL;
>   }
>   PetscFunctionReturn(0);
> }
> 
> for MPIViennaCL and MPISeqAIJ Cusparse but it doesn't look like it has been written yet. 
> 
> 
> > 
> > It does not seem to work. It does not look like CUDA has an MatCreateVecs. Should I add one and copy this flag over?
> 
>    We do need this function. But I don't see how it relates to pinning. When the matrix is pinned to the CPU we want it to create CPU vectors which I assume it does.
> 
> 
> > 
> > Mark
> 



More information about the petsc-dev mailing list