@@ -3924,16 +3924,16 @@ static PetscErrorCode MatScale_SeqAIJCUSPARSE(Mat Y, PetscScalar a)
39243924
39253925static PetscErrorCode MatZeroEntries_SeqAIJCUSPARSE (Mat A)
39263926{
3927- PetscBool both = PETSC_FALSE;
3928- Mat_SeqAIJ *a = (Mat_SeqAIJ *)A->data ;
3927+ PetscBool gpu = PETSC_FALSE;
3928+ Mat_SeqAIJ *a = (Mat_SeqAIJ *)A->data ;
39293929
39303930 PetscFunctionBegin;
39313931 if (A->factortype == MAT_FACTOR_NONE) {
39323932 Mat_SeqAIJCUSPARSE *spptr = (Mat_SeqAIJCUSPARSE *)A->spptr ;
39333933 if (spptr->mat ) {
39343934 CsrMatrix *matrix = (CsrMatrix *)spptr->mat ->mat ;
39353935 if (matrix->values ) {
3936- both = PETSC_TRUE;
3936+ gpu = PETSC_TRUE;
39373937 thrust::fill (thrust::device, matrix->values ->begin (), matrix->values ->end (), 0 .);
39383938 }
39393939 }
@@ -3942,10 +3942,12 @@ static PetscErrorCode MatZeroEntries_SeqAIJCUSPARSE(Mat A)
39423942 if (matrix->values ) thrust::fill (thrust::device, matrix->values ->begin (), matrix->values ->end (), 0 .);
39433943 }
39443944 }
3945- PetscCall (PetscArrayzero (a->a , a->i [A->rmap ->n ]));
3945+ if (gpu) A->offloadmask = PETSC_OFFLOAD_GPU;
3946+ else {
3947+ PetscCall (PetscArrayzero (a->a , a->i [A->rmap ->n ]));
3948+ A->offloadmask = PETSC_OFFLOAD_CPU;
3949+ }
39463950 PetscCall (MatSeqAIJInvalidateDiagonal (A));
3947- if (both) A->offloadmask = PETSC_OFFLOAD_BOTH;
3948- else A->offloadmask = PETSC_OFFLOAD_CPU;
39493951 PetscFunctionReturn (PETSC_SUCCESS);
39503952}
39513953
0 commit comments