Actual source code: inode2.c
petsc-3.12.5 2020-03-29
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.node_count = 0;
68: b->inode.size = 0;
69: b->inode.limit = 5;
70: b->inode.max_limit = 5;
71: b->inode.ibdiagvalid = PETSC_FALSE;
72: b->inode.ibdiag = 0;
73: b->inode.bdiag = 0;
75: PetscOptionsBegin(PetscObjectComm((PetscObject)B),((PetscObject)B)->prefix,"Options for SEQAIJ matrix","Mat");
76: PetscOptionsBool("-mat_no_unroll","Do not optimize for inodes (slower)",NULL,no_unroll,&no_unroll,NULL);
77: if (no_unroll) {
78: PetscInfo(B,"Not using Inode routines due to -mat_no_unroll\n");
79: }
80: PetscOptionsBool("-mat_no_inode","Do not optimize for inodes -slower-",NULL,no_inode,&no_inode,NULL);
81: if (no_inode) {
82: PetscInfo(B,"Not using Inode routines due to -mat_no_inode\n");
83: }
84: PetscOptionsInt("-mat_inode_limit","Do not use inodes larger then this value",NULL,b->inode.limit,&b->inode.limit,NULL);
85: PetscOptionsEnd();
87: b->inode.use = (PetscBool)(!(no_unroll || no_inode));
88: if (b->inode.limit > b->inode.max_limit) b->inode.limit = b->inode.max_limit;
90: PetscObjectComposeFunction((PetscObject)B,"MatInodeAdjustForInodes_C",MatInodeAdjustForInodes_SeqAIJ_Inode);
91: PetscObjectComposeFunction((PetscObject)B,"MatInodeGetInodeSizes_C",MatInodeGetInodeSizes_SeqAIJ_Inode);
92: return(0);
93: }
95: PetscErrorCode MatSetOption_SeqAIJ_Inode(Mat A,MatOption op,PetscBool flg)
96: {
97: Mat_SeqAIJ *a=(Mat_SeqAIJ*)A->data;
100: switch (op) {
101: case MAT_USE_INODES:
102: a->inode.use = flg;
103: break;
104: default:
105: break;
106: }
107: return(0);
108: }