Actual source code: inode2.c

      2: #include <../src/mat/impls/aij/seq/aij.h>

      4: extern PetscErrorCode MatInodeAdjustForInodes_SeqAIJ_Inode(Mat,IS*,IS*);
      5: extern PetscErrorCode MatInodeGetInodeSizes_SeqAIJ_Inode(Mat,PetscInt*,PetscInt*[],PetscInt*);

      7: PetscErrorCode MatView_SeqAIJ_Inode(Mat A,PetscViewer viewer)
      8: {
      9:   Mat_SeqAIJ        *a=(Mat_SeqAIJ*)A->data;
     10:   PetscErrorCode    ierr;
     11:   PetscBool         iascii;
     12:   PetscViewerFormat format;

     15:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);
     16:   if (iascii) {
     17:     PetscViewerGetFormat(viewer,&format);
     18:     if (format == PETSC_VIEWER_ASCII_INFO_DETAIL || format == PETSC_VIEWER_ASCII_INFO) {
     19:       if (a->inode.size) {
     20:         PetscViewerASCIIPrintf(viewer,"using I-node routines: found %D nodes, limit used is %D\n",a->inode.node_count,a->inode.limit);
     21:       } else {
     22:         PetscViewerASCIIPrintf(viewer,"not using I-node routines\n");
     23:       }
     24:     }
     25:   }
     26:   return(0);
     27: }

     29: PetscErrorCode MatAssemblyEnd_SeqAIJ_Inode(Mat A, MatAssemblyType mode)
     30: {
     31:   Mat_SeqAIJ     *a = (Mat_SeqAIJ*)A->data;

     35:   MatSeqAIJCheckInode(A);
     36:   a->inode.ibdiagvalid = PETSC_FALSE;
     37:   return(0);
     38: }

     40: PetscErrorCode MatDestroy_SeqAIJ_Inode(Mat A)
     41: {
     43:   Mat_SeqAIJ     *a=(Mat_SeqAIJ*)A->data;

     46:   PetscFree(a->inode.size);
     47:   PetscFree3(a->inode.ibdiag,a->inode.bdiag,a->inode.ssor_work);
     48:   PetscObjectComposeFunction((PetscObject)A,"MatInodeAdjustForInodes_C",NULL);
     49:   PetscObjectComposeFunction((PetscObject)A,"MatInodeGetInodeSizes_C",NULL);
     50:   return(0);
     51: }

     53: /* MatCreate_SeqAIJ_Inode is not DLLEXPORTed because it is not a constructor for a complete type.    */
     54: /* It is also not registered as a type for use within MatSetType.                             */
     55: /* It is intended as a helper for the MATSEQAIJ class, so classes which desire Inodes should  */
     56: /*    inherit off of MATSEQAIJ instead by calling MatSetType(MATSEQAIJ) in their constructor. */
     57: /* Maybe this is a bad idea. (?) */
     58: PetscErrorCode MatCreate_SeqAIJ_Inode(Mat B)
     59: {
     60:   Mat_SeqAIJ     *b=(Mat_SeqAIJ*)B->data;
     62:   PetscBool      no_inode,no_unroll;

     65:   no_inode             = PETSC_FALSE;
     66:   no_unroll            = PETSC_FALSE;
     67:   b->inode.checked     = PETSC_FALSE;
     68:   b->inode.node_count  = 0;
     69:   b->inode.size        = NULL;
     70:   b->inode.limit       = 5;
     71:   b->inode.max_limit   = 5;
     72:   b->inode.ibdiagvalid = PETSC_FALSE;
     73:   b->inode.ibdiag      = NULL;
     74:   b->inode.bdiag       = NULL;

     76:   PetscOptionsBegin(PetscObjectComm((PetscObject)B),((PetscObject)B)->prefix,"Options for SEQAIJ matrix","Mat");
     77:   PetscOptionsBool("-mat_no_unroll","Do not optimize for inodes (slower)",NULL,no_unroll,&no_unroll,NULL);
     78:   if (no_unroll) {
     79:     PetscInfo(B,"Not using Inode routines due to -mat_no_unroll\n");
     80:   }
     81:   PetscOptionsBool("-mat_no_inode","Do not optimize for inodes -slower-",NULL,no_inode,&no_inode,NULL);
     82:   if (no_inode) {
     83:     PetscInfo(B,"Not using Inode routines due to -mat_no_inode\n");
     84:   }
     85:   PetscOptionsInt("-mat_inode_limit","Do not use inodes larger then this value",NULL,b->inode.limit,&b->inode.limit,NULL);
     86:   PetscOptionsEnd();

     88:   b->inode.use = (PetscBool)(!(no_unroll || no_inode));
     89:   if (b->inode.limit > b->inode.max_limit) b->inode.limit = b->inode.max_limit;

     91:   PetscObjectComposeFunction((PetscObject)B,"MatInodeAdjustForInodes_C",MatInodeAdjustForInodes_SeqAIJ_Inode);
     92:   PetscObjectComposeFunction((PetscObject)B,"MatInodeGetInodeSizes_C",MatInodeGetInodeSizes_SeqAIJ_Inode);
     93:   return(0);
     94: }

     96: PetscErrorCode MatSetOption_SeqAIJ_Inode(Mat A,MatOption op,PetscBool flg)
     97: {
     98:   Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data;

    101:   switch (op) {
    102:   case MAT_USE_INODES:
    103:     a->inode.use = flg;
    104:     break;
    105:   default:
    106:     break;
    107:   }
    108:   return(0);
    109: }