Actual source code: dlregismat.c

  1: /* Portions of this code are under:
  2:    Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
  3: */
  4: #include <petsc/private/matimpl.h>

  6: const char *MatOptions_Shifted[] = {"UNUSED_NONZERO_LOCATION_ERR", "ROW_ORIENTED", "NOT_A_VALID_OPTION", "SYMMETRIC", "STRUCTURALLY_SYMMETRIC", "FORCE_DIAGONAL_ENTRIES", "IGNORE_OFF_PROC_ENTRIES", "USE_HASH_TABLE", "KEEP_NONZERO_PATTERN", "IGNORE_ZERO_ENTRIES", "USE_INODES", "HERMITIAN", "SYMMETRY_ETERNAL", "NEW_NONZERO_LOCATION_ERR", "IGNORE_LOWER_TRIANGULAR", "ERROR_LOWER_TRIANGULAR", "GETROW_UPPERTRIANGULAR", "SPD", "NO_OFF_PROC_ZERO_ROWS", "NO_OFF_PROC_ENTRIES", "NEW_NONZERO_LOCATIONS", "NEW_NONZERO_ALLOCATION_ERR", "SUBSET_OFF_PROC_ENTRIES", "SUBMAT_SINGLEIS", "STRUCTURE_ONLY", "SORTED_FULL", "FORM_EXPLICIT_TRANSPOSE", "STRUCTURAL_SYMMETRY_ETERNAL", "SPD_ETERNAL", "MatOption", "MAT_", NULL};
  7: const char *const *MatOptions                  = MatOptions_Shifted + 2;
  8: const char *const  MatFactorShiftTypes[]       = {"NONE", "NONZERO", "POSITIVE_DEFINITE", "INBLOCKS", "MatFactorShiftType", "PC_FACTOR_", NULL};
  9: const char *const  MatStructures[]             = {"DIFFERENT", "SUBSET", "SAME", "UNKNOWN", "MatStructure", "MAT_STRUCTURE_", NULL};
 10: const char *const  MatFactorShiftTypesDetail[] = {NULL, "diagonal shift to prevent zero pivot", "Manteuffel shift", "diagonal shift on blocks to prevent zero pivot"};
 11: const char *const  MPPTScotchStrategyTypes[]   = {"DEFAULT", "QUALITY", "SPEED", "BALANCE", "SAFETY", "SCALABILITY", "MPPTScotchStrategyType", "MP_PTSCOTCH_", NULL};
 12: const char *const  MPChacoGlobalTypes[]        = {"", "MULTILEVEL", "SPECTRAL", "", "LINEAR", "RANDOM", "SCATTERED", "MPChacoGlobalType", "MP_CHACO_", NULL};
 13: const char *const  MPChacoLocalTypes[]         = {"", "KERNIGHAN", "NONE", "MPChacoLocalType", "MP_CHACO_", NULL};
 14: const char *const  MPChacoEigenTypes[]         = {"LANCZOS", "RQI", "MPChacoEigenType", "MP_CHACO_", NULL};

 16: extern PetscErrorCode MatMFFDInitializePackage(void);
 17: extern PetscErrorCode MatSolverTypeDestroy(void);
 18: static PetscBool      MatPackageInitialized = PETSC_FALSE;

 20: /*@C
 21:   MatFinalizePackage - This function destroys everything in the Petsc interface to the `Mat`
 22:   package. It is called from `PetscFinalize()`.

 24:   Level: developer

 26: .seealso: `Mat`, `PetscFinalize()`, `MatInitializePackage()`
 27: @*/
 28: PetscErrorCode MatFinalizePackage(void)
 29: {
 30:   MatRootName nnames, names = MatRootNameList;

 32:   PetscFunctionBegin;
 33:   PetscCall(MatSolverTypeDestroy());
 34:   while (names) {
 35:     nnames = names->next;
 36:     PetscCall(PetscFree(names->rname));
 37:     PetscCall(PetscFree(names->sname));
 38:     PetscCall(PetscFree(names->mname));
 39:     PetscCall(PetscFree(names));
 40:     names = nnames;
 41:   }
 42:   PetscCall(PetscFunctionListDestroy(&MatList));
 43:   PetscCall(PetscFunctionListDestroy(&MatOrderingList));
 44:   PetscCall(PetscFunctionListDestroy(&MatColoringList));
 45:   PetscCall(PetscFunctionListDestroy(&MatPartitioningList));
 46:   PetscCall(PetscFunctionListDestroy(&MatCoarsenList));
 47:   MatRootNameList                  = NULL;
 48:   MatPackageInitialized            = PETSC_FALSE;
 49:   MatRegisterAllCalled             = PETSC_FALSE;
 50:   MatOrderingRegisterAllCalled     = PETSC_FALSE;
 51:   MatColoringRegisterAllCalled     = PETSC_FALSE;
 52:   MatPartitioningRegisterAllCalled = PETSC_FALSE;
 53:   MatCoarsenRegisterAllCalled      = PETSC_FALSE;
 54:   /* this is not ideal because it exposes SeqAIJ implementation details directly into the base Mat code */
 55:   PetscCall(PetscFunctionListDestroy(&MatSeqAIJList));
 56:   MatSeqAIJRegisterAllCalled = PETSC_FALSE;
 57:   PetscFunctionReturn(PETSC_SUCCESS);
 58: }

 60: #if defined(PETSC_HAVE_CUDA)
 61: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_DENSECUDA(void);
 62: #endif

 64: #if defined(PETSC_HAVE_HIP)
 65: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_DENSEHIP(void);
 66: #endif

 68: #if defined(PETSC_HAVE_MUMPS)
 69: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_MUMPS(void);
 70: #endif
 71: #if defined(PETSC_HAVE_CUDA)
 72: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_CUSPARSE(void);
 73: #endif
 74: #if defined(PETSC_HAVE_HIP)
 75: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_HIPSPARSE(void);
 76: #endif
 77: #if defined(PETSC_HAVE_KOKKOS_KERNELS)
 78: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_KOKKOS(void);
 79: #endif
 80: #if defined(PETSC_HAVE_VIENNACL)
 81: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_ViennaCL(void);
 82: #endif
 83: #if defined(PETSC_HAVE_ELEMENTAL)
 84: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_Elemental(void);
 85: #endif
 86: #if defined(PETSC_HAVE_SCALAPACK)
 87: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_ScaLAPACK(void);
 88: #endif
 89: #if defined(PETSC_HAVE_MATLAB)
 90: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_Matlab(void);
 91: #endif
 92: #if defined(PETSC_HAVE_ESSL)
 93: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_Essl(void);
 94: #endif
 95: #if defined(PETSC_HAVE_SUPERLU)
 96: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_SuperLU(void);
 97: #endif
 98: #if defined(PETSC_HAVE_STRUMPACK)
 99: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_STRUMPACK(void);
100: #endif
101: #if defined(PETSC_HAVE_PASTIX)
102: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_Pastix(void);
103: #endif
104: #if defined(PETSC_HAVE_SUPERLU_DIST)
105: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_SuperLU_DIST(void);
106: #endif
107: #if defined(PETSC_HAVE_MKL_PARDISO)
108: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_MKL_Pardiso(void);
109: #endif
110: #if defined(PETSC_HAVE_MKL_CPARDISO)
111: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_MKL_CPardiso(void);
112: #endif
113: #if defined(PETSC_HAVE_SUITESPARSE)
114: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_SuiteSparse(void);
115: #endif
116: #if defined(PETSC_HAVE_LUSOL)
117: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_Lusol(void);
118: #endif
119: #if defined(PETSC_HAVE_HTOOL)
120: PETSC_INTERN PetscErrorCode MatSolverTypeRegister_Htool(void);
121: #endif

123: PETSC_INTERN PetscErrorCode MatGetFactor_seqaij_petsc(Mat, MatFactorType, Mat *);
124: PETSC_INTERN PetscErrorCode MatGetFactor_seqbaij_petsc(Mat, MatFactorType, Mat *);
125: PETSC_INTERN PetscErrorCode MatGetFactor_seqsbaij_petsc(Mat, MatFactorType, Mat *);
126: PETSC_INTERN PetscErrorCode MatGetFactor_seqdense_petsc(Mat, MatFactorType, Mat *);
127: #if defined(PETSC_HAVE_CUDA)
128: PETSC_INTERN PetscErrorCode MatGetFactor_seqdense_cuda(Mat, MatFactorType, Mat *);
129: #endif
130: #if defined(PETSC_HAVE_HIP)
131: PETSC_INTERN PetscErrorCode MatGetFactor_seqdense_hip(Mat, MatFactorType, Mat *);
132: #endif
133: PETSC_INTERN PetscErrorCode MatGetFactor_constantdiagonal_petsc(Mat, MatFactorType, Mat *);
134: PETSC_INTERN PetscErrorCode MatGetFactor_seqaij_bas(Mat, MatFactorType, Mat *);

136: #include <petscbm.h>
137: PETSC_INTERN PetscErrorCode PetscBenchCreate_HPL(PetscBench);

139: /*@C
140:   MatInitializePackage - This function initializes everything in the `Mat` package. It is called
141:   from `PetscDLLibraryRegister_petscmat()` when using dynamic libraries, and on the first call to `MatCreate()`
142:   when using shared or static libraries.

144:   Level: developer

146: .seealso: [](ch_matrices), `Mat`, `PetscInitialize()`, `MatFinalizePackage()`
147: @*/
148: PetscErrorCode MatInitializePackage(void)
149: {
150:   char      logList[256];
151:   PetscBool opt, pkg;

153:   PetscFunctionBegin;
154:   if (MatPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
155:   MatPackageInitialized = PETSC_TRUE;
156:   /* Initialize subpackage */
157:   PetscCall(MatMFFDInitializePackage());
158:   /* Register Classes */
159:   PetscCall(PetscClassIdRegister("Matrix", &MAT_CLASSID));
160:   PetscCall(PetscClassIdRegister("Matrix FD Coloring", &MAT_FDCOLORING_CLASSID));
161:   PetscCall(PetscClassIdRegister("Matrix Coloring", &MAT_COLORING_CLASSID));
162:   PetscCall(PetscClassIdRegister("Matrix MatTranspose Coloring", &MAT_TRANSPOSECOLORING_CLASSID));
163:   PetscCall(PetscClassIdRegister("Matrix Partitioning", &MAT_PARTITIONING_CLASSID));
164:   PetscCall(PetscClassIdRegister("Matrix Coarsen", &MAT_COARSEN_CLASSID));
165:   PetscCall(PetscClassIdRegister("Matrix Null Space", &MAT_NULLSPACE_CLASSID));
166:   /* Register Constructors */
167:   PetscCall(MatRegisterAll());
168:   PetscCall(MatOrderingRegisterAll());
169:   PetscCall(MatColoringRegisterAll());
170:   PetscCall(MatPartitioningRegisterAll());
171:   PetscCall(MatCoarsenRegisterAll());
172:   PetscCall(MatSeqAIJRegisterAll());
173:   /* Register Events */
174:   PetscCall(PetscLogEventRegister("MatMult", MAT_CLASSID, &MAT_Mult));
175:   PetscCall(PetscLogEventRegister("MatMultAdd", MAT_CLASSID, &MAT_MultAdd));
176:   PetscCall(PetscLogEventRegister("MatMultTranspose", MAT_CLASSID, &MAT_MultTranspose));
177:   PetscCall(PetscLogEventRegister("MatMultHermitian", MAT_CLASSID, &MAT_MultHermitianTranspose));
178:   PetscCall(PetscLogEventRegister("MatMultTrAdd", MAT_CLASSID, &MAT_MultTransposeAdd));
179:   PetscCall(PetscLogEventRegister("MatMultHTAdd", MAT_CLASSID, &MAT_MultHermitianTransposeAdd));
180:   PetscCall(PetscLogEventRegister("MatSolve", MAT_CLASSID, &MAT_Solve));
181:   PetscCall(PetscLogEventRegister("MatSolves", MAT_CLASSID, &MAT_Solves));
182:   PetscCall(PetscLogEventRegister("MatSolveAdd", MAT_CLASSID, &MAT_SolveAdd));
183:   PetscCall(PetscLogEventRegister("MatSolveTranspos", MAT_CLASSID, &MAT_SolveTranspose));
184:   PetscCall(PetscLogEventRegister("MatSolveTrAdd", MAT_CLASSID, &MAT_SolveTransposeAdd));
185:   PetscCall(PetscLogEventRegister("MatSOR", MAT_CLASSID, &MAT_SOR));
186:   PetscCall(PetscLogEventRegister("MatForwardSolve", MAT_CLASSID, &MAT_ForwardSolve));
187:   PetscCall(PetscLogEventRegister("MatBackwardSolve", MAT_CLASSID, &MAT_BackwardSolve));
188:   PetscCall(PetscLogEventRegister("MatLUFactor", MAT_CLASSID, &MAT_LUFactor));
189:   PetscCall(PetscLogEventRegister("MatLUFactorSym", MAT_CLASSID, &MAT_LUFactorSymbolic));
190:   PetscCall(PetscLogEventRegister("MatLUFactorNum", MAT_CLASSID, &MAT_LUFactorNumeric));
191:   PetscCall(PetscLogEventRegister("MatQRFactor", MAT_CLASSID, &MAT_QRFactor));
192:   PetscCall(PetscLogEventRegister("MatQRFactorSym", MAT_CLASSID, &MAT_QRFactorSymbolic));
193:   PetscCall(PetscLogEventRegister("MatQRFactorNum", MAT_CLASSID, &MAT_QRFactorNumeric));
194:   PetscCall(PetscLogEventRegister("MatCholeskyFctr", MAT_CLASSID, &MAT_CholeskyFactor));
195:   PetscCall(PetscLogEventRegister("MatCholFctrSym", MAT_CLASSID, &MAT_CholeskyFactorSymbolic));
196:   PetscCall(PetscLogEventRegister("MatCholFctrNum", MAT_CLASSID, &MAT_CholeskyFactorNumeric));
197:   PetscCall(PetscLogEventRegister("MatFctrFactSchur", MAT_CLASSID, &MAT_FactorFactS));
198:   PetscCall(PetscLogEventRegister("MatFctrInvSchur", MAT_CLASSID, &MAT_FactorInvS));
199:   PetscCall(PetscLogEventRegister("MatILUFactor", MAT_CLASSID, &MAT_ILUFactor));
200:   PetscCall(PetscLogEventRegister("MatILUFactorSym", MAT_CLASSID, &MAT_ILUFactorSymbolic));
201:   PetscCall(PetscLogEventRegister("MatICCFactorSym", MAT_CLASSID, &MAT_ICCFactorSymbolic));
202:   PetscCall(PetscLogEventRegister("MatCopy", MAT_CLASSID, &MAT_Copy));
203:   PetscCall(PetscLogEventRegister("MatConvert", MAT_CLASSID, &MAT_Convert));
204:   PetscCall(PetscLogEventRegister("MatScale", MAT_CLASSID, &MAT_Scale));
205:   PetscCall(PetscLogEventRegister("MatResidual", MAT_CLASSID, &MAT_Residual));
206:   PetscCall(PetscLogEventRegister("MatAssemblyBegin", MAT_CLASSID, &MAT_AssemblyBegin));
207:   PetscCall(PetscLogEventRegister("MatAssemblyEnd", MAT_CLASSID, &MAT_AssemblyEnd));
208:   PetscCall(PetscLogEventRegister("MatSetValues", MAT_CLASSID, &MAT_SetValues));
209:   PetscCall(PetscLogEventRegister("MatGetValues", MAT_CLASSID, &MAT_GetValues));
210:   PetscCall(PetscLogEventRegister("MatGetRow", MAT_CLASSID, &MAT_GetRow));
211:   PetscCall(PetscLogEventRegister("MatGetRowIJ", MAT_CLASSID, &MAT_GetRowIJ));
212:   PetscCall(PetscLogEventRegister("MatCreateSubMats", MAT_CLASSID, &MAT_CreateSubMats));
213:   PetscCall(PetscLogEventRegister("MatCreateSubMat", MAT_CLASSID, &MAT_CreateSubMat));
214:   PetscCall(PetscLogEventRegister("MatGetOrdering", MAT_CLASSID, &MAT_GetOrdering));
215:   PetscCall(PetscLogEventRegister("MatIncreaseOvrlp", MAT_CLASSID, &MAT_IncreaseOverlap));
216:   PetscCall(PetscLogEventRegister("MatPartitioning", MAT_PARTITIONING_CLASSID, &MAT_Partitioning));
217:   PetscCall(PetscLogEventRegister("MatPartitioningND", MAT_PARTITIONING_CLASSID, &MAT_PartitioningND));
218:   PetscCall(PetscLogEventRegister("MatCoarsen", MAT_COARSEN_CLASSID, &MAT_Coarsen));
219:   PetscCall(PetscLogEventRegister("MatZeroEntries", MAT_CLASSID, &MAT_ZeroEntries));
220:   PetscCall(PetscLogEventRegister("MatLoad", MAT_CLASSID, &MAT_Load));
221:   PetscCall(PetscLogEventRegister("MatView", MAT_CLASSID, &MAT_View));
222:   PetscCall(PetscLogEventRegister("MatAXPY", MAT_CLASSID, &MAT_AXPY));
223:   PetscCall(PetscLogEventRegister("MatFDColorCreate", MAT_FDCOLORING_CLASSID, &MAT_FDColoringCreate));
224:   PetscCall(PetscLogEventRegister("MatFDColorSetUp", MAT_FDCOLORING_CLASSID, &MAT_FDColoringSetUp));
225:   PetscCall(PetscLogEventRegister("MatFDColorApply", MAT_FDCOLORING_CLASSID, &MAT_FDColoringApply));
226:   PetscCall(PetscLogEventRegister("MatFDColorFunc", MAT_FDCOLORING_CLASSID, &MAT_FDColoringFunction));
227:   PetscCall(PetscLogEventRegister("MatTranspose", MAT_CLASSID, &MAT_Transpose));
228:   PetscCall(PetscLogEventRegister("MatMatSolve", MAT_CLASSID, &MAT_MatSolve));
229:   PetscCall(PetscLogEventRegister("MatMatTrSolve", MAT_CLASSID, &MAT_MatTrSolve));
230:   PetscCall(PetscLogEventRegister("MatMatMultSym", MAT_CLASSID, &MAT_MatMultSymbolic));
231:   PetscCall(PetscLogEventRegister("MatMatMultNum", MAT_CLASSID, &MAT_MatMultNumeric));
232:   PetscCall(PetscLogEventRegister("MatMatMatMultSym", MAT_CLASSID, &MAT_MatMatMultSymbolic));
233:   PetscCall(PetscLogEventRegister("MatMatMatMultNum", MAT_CLASSID, &MAT_MatMatMultNumeric));
234:   PetscCall(PetscLogEventRegister("MatPtAPSymbolic", MAT_CLASSID, &MAT_PtAPSymbolic));
235:   PetscCall(PetscLogEventRegister("MatPtAPNumeric", MAT_CLASSID, &MAT_PtAPNumeric));
236:   PetscCall(PetscLogEventRegister("MatRARtSym", MAT_CLASSID, &MAT_RARtSymbolic));
237:   PetscCall(PetscLogEventRegister("MatRARtNum", MAT_CLASSID, &MAT_RARtNumeric));
238:   PetscCall(PetscLogEventRegister("MatMatTrnMultSym", MAT_CLASSID, &MAT_MatTransposeMultSymbolic));
239:   PetscCall(PetscLogEventRegister("MatMatTrnMultNum", MAT_CLASSID, &MAT_MatTransposeMultNumeric));
240:   PetscCall(PetscLogEventRegister("MatTrnMatMultSym", MAT_CLASSID, &MAT_TransposeMatMultSymbolic));
241:   PetscCall(PetscLogEventRegister("MatTrnMatMultNum", MAT_CLASSID, &MAT_TransposeMatMultNumeric));
242:   PetscCall(PetscLogEventRegister("MatTrnColorCreate", MAT_CLASSID, &MAT_TransposeColoringCreate));
243:   PetscCall(PetscLogEventRegister("MatRedundantMat", MAT_CLASSID, &MAT_RedundantMat));
244:   PetscCall(PetscLogEventRegister("MatGetSeqNZStrct", MAT_CLASSID, &MAT_GetSeqNonzeroStructure));
245:   PetscCall(PetscLogEventRegister("MatGetMultiProcB", MAT_CLASSID, &MAT_GetMultiProcBlock));
246:   PetscCall(PetscLogEventRegister("MatSetRandom", MAT_CLASSID, &MAT_SetRandom));

248:   /* these may be specific to MPIAIJ matrices */
249:   PetscCall(PetscLogEventRegister("MatMPISumSeqNumeric", MAT_CLASSID, &MAT_Seqstompinum));
250:   PetscCall(PetscLogEventRegister("MatMPISumSeqSymbolic", MAT_CLASSID, &MAT_Seqstompisym));
251:   PetscCall(PetscLogEventRegister("MatMPISumSeq", MAT_CLASSID, &MAT_Seqstompi));
252:   PetscCall(PetscLogEventRegister("MatMPIConcateSeq", MAT_CLASSID, &MAT_Merge));
253:   PetscCall(PetscLogEventRegister("MatGetLocalMat", MAT_CLASSID, &MAT_Getlocalmat));
254:   PetscCall(PetscLogEventRegister("MatGetLocalMatCondensed", MAT_CLASSID, &MAT_Getlocalmatcondensed));
255:   PetscCall(PetscLogEventRegister("MatGetBrowsOfAcols", MAT_CLASSID, &MAT_GetBrowsOfAcols));
256:   PetscCall(PetscLogEventRegister("MatGetBrAoCol", MAT_CLASSID, &MAT_GetBrowsOfAocols));

258:   PetscCall(PetscLogEventRegister("MatGetSymTransR", MAT_CLASSID, &MAT_Getsymtransreduced));
259:   PetscCall(PetscLogEventRegister("MatCUSPARSCopyTo", MAT_CLASSID, &MAT_CUSPARSECopyToGPU));
260:   PetscCall(PetscLogEventRegister("MatCUSPARSCopyFr", MAT_CLASSID, &MAT_CUSPARSECopyFromGPU));
261:   PetscCall(PetscLogEventRegister("MatCUSPARSSolAnl", MAT_CLASSID, &MAT_CUSPARSESolveAnalysis));
262:   PetscCall(PetscLogEventRegister("MatCUSPARSGenT", MAT_CLASSID, &MAT_CUSPARSEGenerateTranspose));
263:   PetscCall(PetscLogEventRegister("MatHIPSPARSCopyTo", MAT_CLASSID, &MAT_HIPSPARSECopyToGPU));
264:   PetscCall(PetscLogEventRegister("MatHIPSPARSCopyFr", MAT_CLASSID, &MAT_HIPSPARSECopyFromGPU));
265:   PetscCall(PetscLogEventRegister("MatHIPSPARSSolAnl", MAT_CLASSID, &MAT_HIPSPARSESolveAnalysis));
266:   PetscCall(PetscLogEventRegister("MatHIPSPARSGenT", MAT_CLASSID, &MAT_HIPSPARSEGenerateTranspose));
267:   PetscCall(PetscLogEventRegister("MatVCLCopyTo", MAT_CLASSID, &MAT_ViennaCLCopyToGPU));
268:   PetscCall(PetscLogEventRegister("MatDenseCopyTo", MAT_CLASSID, &MAT_DenseCopyToGPU));
269:   PetscCall(PetscLogEventRegister("MatDenseCopyFrom", MAT_CLASSID, &MAT_DenseCopyFromGPU));
270:   PetscCall(PetscLogEventRegister("MatSetValBatch", MAT_CLASSID, &MAT_SetValuesBatch));
271:   PetscCall(PetscLogEventRegister("MatCreateGraph", MAT_CLASSID, &MAT_CreateGraph));

273:   PetscCall(PetscLogEventRegister("MatColoringApply", MAT_COLORING_CLASSID, &MATCOLORING_Apply));
274:   PetscCall(PetscLogEventRegister("MatColoringComm", MAT_COLORING_CLASSID, &MATCOLORING_Comm));
275:   PetscCall(PetscLogEventRegister("MatColoringLocal", MAT_COLORING_CLASSID, &MATCOLORING_Local));
276:   PetscCall(PetscLogEventRegister("MatColoringIS", MAT_COLORING_CLASSID, &MATCOLORING_ISCreate));
277:   PetscCall(PetscLogEventRegister("MatColoringSetUp", MAT_COLORING_CLASSID, &MATCOLORING_SetUp));
278:   PetscCall(PetscLogEventRegister("MatColoringWeights", MAT_COLORING_CLASSID, &MATCOLORING_Weights));

280:   PetscCall(PetscLogEventRegister("MatSetPreallCOO", MAT_CLASSID, &MAT_PreallCOO));
281:   PetscCall(PetscLogEventRegister("MatSetValuesCOO", MAT_CLASSID, &MAT_SetVCOO));

283:   PetscCall(PetscLogEventRegister("MatH2OpusBuild", MAT_CLASSID, &MAT_H2Opus_Build));
284:   PetscCall(PetscLogEventRegister("MatH2OpusComp", MAT_CLASSID, &MAT_H2Opus_Compress));
285:   PetscCall(PetscLogEventRegister("MatH2OpusOrth", MAT_CLASSID, &MAT_H2Opus_Orthog));
286:   PetscCall(PetscLogEventRegister("MatH2OpusLR", MAT_CLASSID, &MAT_H2Opus_LR));

288:   /* Mark non-collective events */
289:   PetscCall(PetscLogEventSetCollective(MAT_SetValues, PETSC_FALSE));
290:   PetscCall(PetscLogEventSetCollective(MAT_SetValuesBatch, PETSC_FALSE));
291:   PetscCall(PetscLogEventSetCollective(MAT_GetRow, PETSC_FALSE));
292:   /* Turn off high traffic events by default */
293:   PetscCall(PetscLogEventSetActiveAll(MAT_SetValues, PETSC_FALSE));
294:   PetscCall(PetscLogEventSetActiveAll(MAT_GetValues, PETSC_FALSE));
295:   PetscCall(PetscLogEventSetActiveAll(MAT_GetRow, PETSC_FALSE));
296:   /* Process Info */
297:   {
298:     PetscClassId classids[7];

300:     classids[0] = MAT_CLASSID;
301:     classids[1] = MAT_FDCOLORING_CLASSID;
302:     classids[2] = MAT_COLORING_CLASSID;
303:     classids[3] = MAT_TRANSPOSECOLORING_CLASSID;
304:     classids[4] = MAT_PARTITIONING_CLASSID;
305:     classids[5] = MAT_COARSEN_CLASSID;
306:     classids[6] = MAT_NULLSPACE_CLASSID;
307:     PetscCall(PetscInfoProcessClass("mat", 7, classids));
308:   }

310:   /* Process summary exclusions */
311:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
312:   if (opt) {
313:     PetscCall(PetscStrInList("mat", logList, ',', &pkg));
314:     if (pkg) PetscCall(PetscLogEventExcludeClass(MAT_CLASSID));
315:     if (pkg) PetscCall(PetscLogEventExcludeClass(MAT_FDCOLORING_CLASSID));
316:     if (pkg) PetscCall(PetscLogEventExcludeClass(MAT_COLORING_CLASSID));
317:     if (pkg) PetscCall(PetscLogEventExcludeClass(MAT_TRANSPOSECOLORING_CLASSID));
318:     if (pkg) PetscCall(PetscLogEventExcludeClass(MAT_PARTITIONING_CLASSID));
319:     if (pkg) PetscCall(PetscLogEventExcludeClass(MAT_COARSEN_CLASSID));
320:     if (pkg) PetscCall(PetscLogEventExcludeClass(MAT_NULLSPACE_CLASSID));
321:   }

323:   /* Register the PETSc built in factorization based solvers */
324:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
325:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
326:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
327:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

329:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
330:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
331:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
332:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

334:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_LU, MatGetFactor_constantdiagonal_petsc));
335:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_CHOLESKY, MatGetFactor_constantdiagonal_petsc));
336:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_ILU, MatGetFactor_constantdiagonal_petsc));
337:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_ICC, MatGetFactor_constantdiagonal_petsc));

339: #if defined(PETSC_HAVE_MKL_SPARSE)
340:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
341:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
342:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
343:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

345:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJMKL, MAT_FACTOR_LU, MatGetFactor_seqbaij_petsc));
346:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJMKL, MAT_FACTOR_CHOLESKY, MatGetFactor_seqbaij_petsc));
347:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJMKL, MAT_FACTOR_ILU, MatGetFactor_seqbaij_petsc));
348:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJMKL, MAT_FACTOR_ICC, MatGetFactor_seqbaij_petsc));
349: #endif
350:   /* Above, we register the PETSc built-in factorization solvers for MATSEQAIJMKL.  In the future, we may want to use
351:      * some of the MKL-provided ones instead. */

353:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
354:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
355:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
356:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

358:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_LU, MatGetFactor_seqbaij_petsc));
359:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqbaij_petsc));
360:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_ILU, MatGetFactor_seqbaij_petsc));
361:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_ICC, MatGetFactor_seqbaij_petsc));

363:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQSBAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqsbaij_petsc));
364:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQSBAIJ, MAT_FACTOR_ICC, MatGetFactor_seqsbaij_petsc));

366:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_LU, MatGetFactor_seqdense_petsc));
367:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_ILU, MatGetFactor_seqdense_petsc));
368:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_CHOLESKY, MatGetFactor_seqdense_petsc));
369:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_QR, MatGetFactor_seqdense_petsc));
370: #if defined(PETSC_HAVE_CUDA)
371:   PetscCall(MatSolverTypeRegister_DENSECUDA());
372: #endif
373: #if defined(PETSC_HAVE_HIP)
374:   PetscCall(MatSolverTypeRegister_DENSEHIP());
375: #endif

377:   PetscCall(MatSolverTypeRegister(MATSOLVERBAS, MATSEQAIJ, MAT_FACTOR_ICC, MatGetFactor_seqaij_bas));

379:   /*
380:      Register the external package factorization based solvers
381:         Eventually we don't want to have these hardwired here at compile time of PETSc
382:   */
383: #if defined(PETSC_HAVE_MUMPS)
384:   PetscCall(MatSolverTypeRegister_MUMPS());
385: #endif
386: #if defined(PETSC_HAVE_CUDA)
387:   PetscCall(MatSolverTypeRegister_CUSPARSE());
388: #endif
389: #if defined(PETSC_HAVE_HIP)
390:   PetscCall(MatSolverTypeRegister_HIPSPARSE());
391: #endif
392: #if defined(PETSC_HAVE_KOKKOS_KERNELS)
393:   PetscCall(MatSolverTypeRegister_KOKKOS());
394: #endif
395: #if defined(PETSC_HAVE_VIENNACL)
396:   PetscCall(MatSolverTypeRegister_ViennaCL());
397: #endif
398: #if defined(PETSC_HAVE_ELEMENTAL)
399:   PetscCall(MatSolverTypeRegister_Elemental());
400: #endif
401: #if defined(PETSC_HAVE_SCALAPACK)
402:   PetscCall(MatSolverTypeRegister_ScaLAPACK());
403: #endif
404: #if defined(PETSC_HAVE_MATLAB)
405:   PetscCall(MatSolverTypeRegister_Matlab());
406: #endif
407: #if defined(PETSC_HAVE_ESSL)
408:   PetscCall(MatSolverTypeRegister_Essl());
409: #endif
410: #if defined(PETSC_HAVE_SUPERLU)
411:   PetscCall(MatSolverTypeRegister_SuperLU());
412: #endif
413: #if defined(PETSC_HAVE_STRUMPACK)
414:   PetscCall(MatSolverTypeRegister_STRUMPACK());
415: #endif
416: #if defined(PETSC_HAVE_PASTIX)
417:   PetscCall(MatSolverTypeRegister_Pastix());
418: #endif
419: #if defined(PETSC_HAVE_SUPERLU_DIST)
420:   PetscCall(MatSolverTypeRegister_SuperLU_DIST());
421: #endif
422: #if defined(PETSC_HAVE_MKL_PARDISO)
423:   PetscCall(MatSolverTypeRegister_MKL_Pardiso());
424: #endif
425: #if defined(PETSC_HAVE_MKL_CPARDISO)
426:   PetscCall(MatSolverTypeRegister_MKL_CPardiso());
427: #endif
428: #if defined(PETSC_HAVE_SUITESPARSE)
429:   PetscCall(MatSolverTypeRegister_SuiteSparse());
430: #endif
431: #if defined(PETSC_HAVE_LUSOL)
432:   PetscCall(MatSolverTypeRegister_Lusol());
433: #endif
434: #if defined(PETSC_HAVE_HTOOL)
435:   PetscCall(MatSolverTypeRegister_Htool());
436: #endif
437: #if defined(PETSC_HAVE_HPL)
438:   PetscCall(PetscBenchRegister(PETSCBMHPL, PetscBenchCreate_HPL));
439: #endif
440:   /* Register package finalizer */
441:   PetscCall(PetscRegisterFinalize(MatFinalizePackage));
442:   PetscFunctionReturn(PETSC_SUCCESS);
443: }

445: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
446: /*
447:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

449:   This one registers all the matrix methods that are in the basic PETSc Matrix library.

451:  */
452: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void)
453: {
454:   PetscFunctionBegin;
455:   PetscCall(MatInitializePackage());
456:   PetscFunctionReturn(PETSC_SUCCESS);
457: }

459: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */