1 2 #include <../src/mat/impls/aij/seq/aij.h> 3 4 extern PetscErrorCode MatInodeAdjustForInodes_SeqAIJ_Inode(Mat,IS*,IS*); 5 extern PetscErrorCode MatInodeGetInodeSizes_SeqAIJ_Inode(Mat,PetscInt*,PetscInt*[],PetscInt*); 6 7 PetscErrorCode MatView_SeqAIJ_Inode(Mat A,PetscViewer viewer) 8 { 9 Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data; 10 PetscBool iascii; 11 PetscViewerFormat format; 12 13 PetscFunctionBegin; 14 PetscCall(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii)); 15 if (iascii) { 16 PetscCall(PetscViewerGetFormat(viewer,&format)); 17 if (format == PETSC_VIEWER_ASCII_INFO_DETAIL || format == PETSC_VIEWER_ASCII_INFO) { 18 if (a->inode.size) { 19 PetscCall(PetscViewerASCIIPrintf(viewer,"using I-node routines: found %" PetscInt_FMT " nodes, limit used is %" PetscInt_FMT "\n",a->inode.node_count,a->inode.limit)); 20 } else { 21 PetscCall(PetscViewerASCIIPrintf(viewer,"not using I-node routines\n")); 22 } 23 } 24 } 25 PetscFunctionReturn(0); 26 } 27 28 PetscErrorCode MatAssemblyEnd_SeqAIJ_Inode(Mat A, MatAssemblyType mode) 29 { 30 Mat_SeqAIJ *a = (Mat_SeqAIJ*)A->data; 31 32 PetscFunctionBegin; 33 PetscCall(MatSeqAIJCheckInode(A)); 34 a->inode.ibdiagvalid = PETSC_FALSE; 35 PetscFunctionReturn(0); 36 } 37 38 PetscErrorCode MatDestroy_SeqAIJ_Inode(Mat A) 39 { 40 Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data; 41 42 PetscFunctionBegin; 43 PetscCall(PetscFree(a->inode.size)); 44 PetscCall(PetscFree3(a->inode.ibdiag,a->inode.bdiag,a->inode.ssor_work)); 45 PetscCall(PetscObjectComposeFunction((PetscObject)A,"MatInodeAdjustForInodes_C",NULL)); 46 PetscCall(PetscObjectComposeFunction((PetscObject)A,"MatInodeGetInodeSizes_C",NULL)); 47 PetscFunctionReturn(0); 48 } 49 50 /* MatCreate_SeqAIJ_Inode is not DLLEXPORTed because it is not a constructor for a complete type. */ 51 /* It is also not registered as a type for use within MatSetType. */ 52 /* It is intended as a helper for the MATSEQAIJ class, so classes which desire Inodes should */ 53 /* inherit off of MATSEQAIJ instead by calling MatSetType(MATSEQAIJ) in their constructor. */ 54 /* Maybe this is a bad idea. (?) */ 55 PetscErrorCode MatCreate_SeqAIJ_Inode(Mat B) 56 { 57 Mat_SeqAIJ *b=(Mat_SeqAIJ*)B->data; 58 PetscBool no_inode,no_unroll; 59 60 PetscFunctionBegin; 61 no_inode = PETSC_FALSE; 62 no_unroll = PETSC_FALSE; 63 b->inode.checked = PETSC_FALSE; 64 b->inode.node_count = 0; 65 b->inode.size = NULL; 66 b->inode.limit = 5; 67 b->inode.max_limit = 5; 68 b->inode.ibdiagvalid = PETSC_FALSE; 69 b->inode.ibdiag = NULL; 70 b->inode.bdiag = NULL; 71 72 PetscOptionsBegin(PetscObjectComm((PetscObject)B),((PetscObject)B)->prefix,"Options for SEQAIJ matrix","Mat"); 73 PetscCall(PetscOptionsBool("-mat_no_unroll","Do not optimize for inodes (slower)",NULL,no_unroll,&no_unroll,NULL)); 74 if (no_unroll) { 75 PetscCall(PetscInfo(B,"Not using Inode routines due to -mat_no_unroll\n")); 76 } 77 PetscCall(PetscOptionsBool("-mat_no_inode","Do not optimize for inodes -slower-",NULL,no_inode,&no_inode,NULL)); 78 if (no_inode) { 79 PetscCall(PetscInfo(B,"Not using Inode routines due to -mat_no_inode\n")); 80 } 81 PetscCall(PetscOptionsInt("-mat_inode_limit","Do not use inodes larger then this value",NULL,b->inode.limit,&b->inode.limit,NULL)); 82 PetscOptionsEnd(); 83 84 b->inode.use = (PetscBool)(!(no_unroll || no_inode)); 85 if (b->inode.limit > b->inode.max_limit) b->inode.limit = b->inode.max_limit; 86 87 PetscCall(PetscObjectComposeFunction((PetscObject)B,"MatInodeAdjustForInodes_C",MatInodeAdjustForInodes_SeqAIJ_Inode)); 88 PetscCall(PetscObjectComposeFunction((PetscObject)B,"MatInodeGetInodeSizes_C",MatInodeGetInodeSizes_SeqAIJ_Inode)); 89 PetscFunctionReturn(0); 90 } 91 92 PetscErrorCode MatSetOption_SeqAIJ_Inode(Mat A,MatOption op,PetscBool flg) 93 { 94 Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data; 95 96 PetscFunctionBegin; 97 switch (op) { 98 case MAT_USE_INODES: 99 a->inode.use = flg; 100 break; 101 default: 102 break; 103 } 104 PetscFunctionReturn(0); 105 } 106