1. petsc
  2. PETSc
  3. petsc

Commits

BarryFSmith  committed 11e456e

removed Mat option for skipping checking of compressed row format since it is now free using the nonzerorowcnt previously introduced

  • Participants
  • Parent commits 7c56577
  • Branches master

Comments (0)

Files changed (13)

File include/finclude/petscmat.h

View file
       PetscEnum MAT_USE_INODES
       PetscEnum MAT_HERMITIAN
       PetscEnum MAT_SYMMETRY_ETERNAL
-      PetscEnum MAT_CHECK_COMPRESSED_ROW
+      PetscEnum MAT_DUMMY
       PetscEnum MAT_IGNORE_LOWER_TRIANGULAR
       PetscEnum MAT_ERROR_LOWER_TRIANGULAR
       PetscEnum MAT_GETROW_UPPERTRIANGULAR
       parameter (MAT_USE_INODES=8)
       parameter (MAT_HERMITIAN=9)
       parameter (MAT_SYMMETRY_ETERNAL=10)
-      parameter (MAT_CHECK_COMPRESSED_ROW=11)
+      parameter (MAT_DUMMY=11)
       parameter (MAT_IGNORE_LOWER_TRIANGULAR=12)
       parameter (MAT_ERROR_LOWER_TRIANGULAR=13)
       parameter (MAT_GETROW_UPPERTRIANGULAR=14)

File include/petsc-private/matimpl.h

View file
 
 /* Info about using compressed row format */
 typedef struct {
-  PetscBool  check;                         /* indicates that at MatAssembly() it should check if compressed rows will be efficient */
   PetscBool  use;                           /* indicates compressed rows have been checked and will be used */
   PetscInt   nrows;                         /* number of non-zero rows */
   PetscInt   *i;                            /* compressed row pointer  */
   PetscInt   *rindex;                       /* compressed row index               */
 } Mat_CompressedRow;
-PETSC_EXTERN PetscErrorCode MatCheckCompressedRow(Mat,Mat_CompressedRow*,PetscInt*,PetscInt,PetscReal);
+PETSC_EXTERN PetscErrorCode MatCheckCompressedRow(Mat,PetscInt,Mat_CompressedRow*,PetscInt*,PetscInt,PetscReal);
 
 struct _p_Mat {
   PETSCHEADER(struct _MatOps);

File include/petscmat.h

View file
               MAT_USE_INODES = 8,
               MAT_HERMITIAN = 9,
               MAT_SYMMETRY_ETERNAL = 10,
-              MAT_CHECK_COMPRESSED_ROW = 11,
+              MAT_DUMMY = 11,
               MAT_IGNORE_LOWER_TRIANGULAR = 12,
               MAT_ERROR_LOWER_TRIANGULAR = 13,
               MAT_GETROW_UPPERTRIANGULAR = 14,

File src/ksp/pc/impls/gamg/agg.c

View file
     matB_2   = (Mat_SeqAIJ*)mpimat_2->B->data;
 
     /* force compressed row storage for B matrix in AuxMat */
-    matB_1->compressedrow.check = PETSC_TRUE;
-
-    ierr = MatCheckCompressedRow(mpimat_1->B,&matB_1->compressedrow,matB_1->i,Gmat_1->rmap->n,-1.0);CHKERRQ(ierr);
+    ierr = MatCheckCompressedRow(mpimat_1->B,matB_1->nonzerorowcnt,&matB_1->compressedrow,matB_1->i,Gmat_1->rmap->n,-1.0);CHKERRQ(ierr);
 
     ierr = PetscMalloc(nloc*sizeof(PetscInt), &lid_cprowID_1);CHKERRQ(ierr);
     for (lid = 0; lid < nloc; lid++) lid_cprowID_1[lid] = -1;

File src/mat/coarsen/impls/hem/hem.c

View file
       mpimat = (Mat_MPIAIJ*)cMat->data;
       matA   = (Mat_SeqAIJ*)mpimat->A->data;
       matB   = (Mat_SeqAIJ*)mpimat->B->data;
-      /* force compressed storage of B */
-      matB->compressedrow.check = PETSC_TRUE;
-
-      ierr = MatCheckCompressedRow(mpimat->B,&matB->compressedrow,matB->i,cMat->rmap->n,-1.0);CHKERRQ(ierr);
       if (!matB->compressedrow.use) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"matB must have compressed row usage");
     } else {
       matA = (Mat_SeqAIJ*)cMat->data;

File src/mat/coarsen/impls/mis/mis.c

View file
     matA   = (Mat_SeqAIJ*)mpimat->A->data;
     matB   = (Mat_SeqAIJ*)mpimat->B->data;
     /* force compressed storage of B */
-    matB->compressedrow.check = PETSC_TRUE;
-    ierr                      = MatCheckCompressedRow(mpimat->B,&matB->compressedrow,matB->i,Gmat->rmap->n,-1.0);CHKERRQ(ierr);
+    ierr   = MatCheckCompressedRow(mpimat->B,matB->nonzerorowcnt,&matB->compressedrow,matB->i,Gmat->rmap->n,-1.0);CHKERRQ(ierr);
   } else {
     PetscBool isAIJ;
     ierr = PetscObjectTypeCompare((PetscObject)Gmat, MATSEQAIJ, &isAIJ);CHKERRQ(ierr);

File src/mat/impls/aij/mpi/mpiaij.c

View file
     ierr = MatSetUpMultiply_MPIAIJ(mat);CHKERRQ(ierr);
   }
   ierr = MatSetOption(aij->B,MAT_USE_INODES,PETSC_FALSE);CHKERRQ(ierr);
-  ierr = MatSetOption(aij->B,MAT_CHECK_COMPRESSED_ROW,PETSC_FALSE);CHKERRQ(ierr);
   ierr = MatAssemblyBegin(aij->B,mode);CHKERRQ(ierr);
   ierr = MatAssemblyEnd(aij->B,mode);CHKERRQ(ierr);
 

File src/mat/impls/aij/seq/aij.c

View file
   A->info.nz_unneeded = (double)fshift;
   a->rmax             = rmax;
 
-  ierr = MatCheckCompressedRow(A,&a->compressedrow,a->i,m,ratio);CHKERRQ(ierr);
+  ierr = MatCheckCompressedRow(A,a->nonzerorowcnt,&a->compressedrow,a->i,m,ratio);CHKERRQ(ierr);
 
   A->same_nonzero = PETSC_TRUE;
 
   case MAT_IGNORE_ZERO_ENTRIES:
     a->ignorezeroentries = flg;
     break;
-  case MAT_CHECK_COMPRESSED_ROW:
-    a->compressedrow.check = flg;
-    break;
   case MAT_SPD:
   case MAT_SYMMETRIC:
   case MAT_STRUCTURALLY_SYMMETRIC:
 
   c->compressedrow.use   = a->compressedrow.use;
   c->compressedrow.nrows = a->compressedrow.nrows;
-  c->compressedrow.check = a->compressedrow.check;
   if (a->compressedrow.use) {
     i    = a->compressedrow.nrows;
     ierr = PetscMalloc2(i+1,PetscInt,&c->compressedrow.i,i,PetscInt,&c->compressedrow.rindex);CHKERRQ(ierr);

File src/mat/impls/baij/mpi/mpibaij.c

View file
   if (!mat->was_assembled && mode == MAT_FINAL_ASSEMBLY) {
     ierr = MatSetUpMultiply_MPIBAIJ(mat);CHKERRQ(ierr);
   }
-  ierr = MatSetOption(baij->B,MAT_CHECK_COMPRESSED_ROW,PETSC_FALSE);CHKERRQ(ierr);
   ierr = MatAssemblyBegin(baij->B,mode);CHKERRQ(ierr);
   ierr = MatAssemblyEnd(baij->B,mode);CHKERRQ(ierr);
 

File src/mat/impls/baij/seq/baij.c

View file
   case MAT_UNUSED_NONZERO_LOCATION_ERR:
     a->nounused = (flg ? -1 : 0);
     break;
-  case MAT_CHECK_COMPRESSED_ROW:
-    a->compressedrow.check = flg;
-    break;
   case MAT_NEW_DIAGONALS:
   case MAT_IGNORE_OFF_PROC_ENTRIES:
   case MAT_USE_HASH_TABLE:
   a->reallocs         = 0;
   A->info.nz_unneeded = (PetscReal)fshift*bs2;
 
-  ierr = MatCheckCompressedRow(A,&a->compressedrow,a->i,mbs,ratio);CHKERRQ(ierr);
+  ierr = MatCheckCompressedRow(A,a->nonzerorowcnt,&a->compressedrow,a->i,mbs,ratio);CHKERRQ(ierr);
 
   A->same_nonzero = PETSC_TRUE;
   PetscFunctionReturn(0);
 
   c->compressedrow.use   = a->compressedrow.use;
   c->compressedrow.nrows = a->compressedrow.nrows;
-  c->compressedrow.check = a->compressedrow.check;
   if (a->compressedrow.use) {
     i    = a->compressedrow.nrows;
     ierr = PetscMalloc2(i+1,PetscInt,&c->compressedrow.i,i+1,PetscInt,&c->compressedrow.rindex);CHKERRQ(ierr);

File src/mat/impls/sbaij/mpi/mpisbaij.c

View file
   if (!mat->was_assembled && mode == MAT_FINAL_ASSEMBLY) {
     ierr = MatSetUpMultiply_MPISBAIJ(mat);CHKERRQ(ierr); /* setup Mvctx and sMvctx */
   }
-  ierr = MatSetOption(baij->B,MAT_CHECK_COMPRESSED_ROW,PETSC_TRUE);CHKERRQ(ierr);
   ierr = MatAssemblyBegin(baij->B,mode);CHKERRQ(ierr);
   ierr = MatAssemblyEnd(baij->B,mode);CHKERRQ(ierr);
 

File src/mat/interface/dlregismat.c

View file
                                   "KEEP_NONZERO_PATTERN","IGNORE_ZERO_ENTRIES","USE_INODES",
                                   "HERMITIAN",
                                   "SYMMETRY_ETERNAL",
-                                  "CHECK_COMPRESSED_ROW",
+                                  "DUMMY",
                                   "IGNORE_LOWER_TRIANGULAR","ERROR_LOWER_TRIANGULAR","GETROW_UPPERTRIANGULAR","SPD","NO_OFF_PROC_ENTRIES","NO_OFF_PROC_ZERO_ROWS","MatOption","MAT_",0};
 const char *const MatFactorShiftTypes[] = {"NONE","NONZERO","POSITIVE_DEFINITE","INBLOCKS","MatFactorShiftType","PC_FACTOR_",0};
 const char *const MatFactorShiftTypesDetail[] = {NULL,"diagonal shift to prevent zero pivot","Manteuffel shift","diagonal shift on blocks to prevent zero pivot"};

File src/mat/utils/compressedrow.c

View file
 
    Input Parameters:
 +  A             - the matrix
+.  nrows         - number of rows with nonzero entries
 .  compressedrow - pointer to the struct Mat_CompressedRow
 .  ai            - row pointer used by seqaij and seqbaij
 .  mbs           - number of (block) rows represented by ai
 
    Level: developer
 @*/
-PETSC_EXTERN PetscErrorCode MatCheckCompressedRow(Mat A,Mat_CompressedRow *compressedrow,PetscInt *ai,PetscInt mbs,PetscReal ratio)
+PETSC_EXTERN PetscErrorCode MatCheckCompressedRow(Mat A,PetscInt nrows,Mat_CompressedRow *compressedrow,PetscInt *ai,PetscInt mbs,PetscReal ratio)
 {
   PetscErrorCode ierr;
-  PetscInt       nrows,*cpi=NULL,*ridx=NULL,nz,i,row;
+  PetscInt       *cpi=NULL,*ridx=NULL,nz,i,row;
 
   PetscFunctionBegin;
-  if (!compressedrow->check) PetscFunctionReturn(0);
-
   /* in case this is being reused, delete old space */
   ierr = PetscFree2(compressedrow->i,compressedrow->rindex);CHKERRQ(ierr);
 
 
 
   /* compute number of zero rows */
-  nrows = 0;
-  for (i=0; i<mbs; i++) {        /* for each row */
-    nz = ai[i+1] - ai[i];       /* number of nonzeros */
-    if (nz == 0) nrows++;
-  }
+  nrows = mbs - nrows;
 
   /* if a large number of zero rows is found, use compressedrow data structure */
   if (nrows < ratio*mbs) {