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

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

133: #include <petscbm.h>
134: PETSC_INTERN PetscErrorCode PetscBenchCreate_HPL(PetscBench);

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

141:   Level: developer

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

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

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

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

269:   PetscCall(PetscLogEventRegister("MatColoringApply", MAT_COLORING_CLASSID, &MATCOLORING_Apply));
270:   PetscCall(PetscLogEventRegister("MatColoringComm", MAT_COLORING_CLASSID, &MATCOLORING_Comm));
271:   PetscCall(PetscLogEventRegister("MatColoringLocal", MAT_COLORING_CLASSID, &MATCOLORING_Local));
272:   PetscCall(PetscLogEventRegister("MatColoringIS", MAT_COLORING_CLASSID, &MATCOLORING_ISCreate));
273:   PetscCall(PetscLogEventRegister("MatColoringSetUp", MAT_COLORING_CLASSID, &MATCOLORING_SetUp));
274:   PetscCall(PetscLogEventRegister("MatColoringWeights", MAT_COLORING_CLASSID, &MATCOLORING_Weights));

276:   PetscCall(PetscLogEventRegister("MatSetPreallCOO", MAT_CLASSID, &MAT_PreallCOO));
277:   PetscCall(PetscLogEventRegister("MatSetValuesCOO", MAT_CLASSID, &MAT_SetVCOO));

279:   PetscCall(PetscLogEventRegister("MatH2OpusBuild", MAT_CLASSID, &MAT_H2Opus_Build));
280:   PetscCall(PetscLogEventRegister("MatH2OpusComp", MAT_CLASSID, &MAT_H2Opus_Compress));
281:   PetscCall(PetscLogEventRegister("MatH2OpusOrth", MAT_CLASSID, &MAT_H2Opus_Orthog));
282:   PetscCall(PetscLogEventRegister("MatH2OpusLR", MAT_CLASSID, &MAT_H2Opus_LR));

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

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

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

319:   /* Register the PETSc built in factorization based solvers */
320:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
321:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
322:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
323:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

325:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
326:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
327:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
328:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

330:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_LU, MatGetFactor_constantdiagonal_petsc));
331:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_CHOLESKY, MatGetFactor_constantdiagonal_petsc));
332:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_ILU, MatGetFactor_constantdiagonal_petsc));
333:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_ICC, MatGetFactor_constantdiagonal_petsc));

335: #if defined(PETSC_HAVE_MKL_SPARSE)
336:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
337:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
338:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
339:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

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

349:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
350:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
351:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
352:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

354:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_LU, MatGetFactor_seqbaij_petsc));
355:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqbaij_petsc));
356:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_ILU, MatGetFactor_seqbaij_petsc));
357:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_ICC, MatGetFactor_seqbaij_petsc));

359:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQSBAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqsbaij_petsc));
360:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQSBAIJ, MAT_FACTOR_ICC, MatGetFactor_seqsbaij_petsc));

362:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_LU, MatGetFactor_seqdense_petsc));
363:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_ILU, MatGetFactor_seqdense_petsc));
364:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_CHOLESKY, MatGetFactor_seqdense_petsc));
365:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_QR, MatGetFactor_seqdense_petsc));
366: #if defined(PETSC_HAVE_CUDA)
367:   PetscCall(MatSolverTypeRegister_DENSECUDA());
368: #endif
369: #if defined(PETSC_HAVE_HIP)
370:   PetscCall(MatSolverTypeRegister_DENSEHIP());
371: #endif

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

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

438: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
439: /*
440:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

444:  */
445: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void)
446: {
447:   PetscFunctionBegin;
448:   PetscCall(MatInitializePackage());
449:   PetscFunctionReturn(PETSC_SUCCESS);
450: }

452: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */