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 MatSolverTypeDestroy(void);
     17: static PetscBool      MatPackageInitialized = PETSC_FALSE;

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

     23:   Level: developer

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

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

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

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

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

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

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

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

    143:   Level: developer

    145:   Note:
    146:   This function never needs to be called by PETSc users.

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

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

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

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

    277:   PetscCall(PetscLogEventRegister("MatColoringApply", MAT_COLORING_CLASSID, &MATCOLORING_Apply));
    278:   PetscCall(PetscLogEventRegister("MatColoringComm", MAT_COLORING_CLASSID, &MATCOLORING_Comm));
    279:   PetscCall(PetscLogEventRegister("MatColoringLocal", MAT_COLORING_CLASSID, &MATCOLORING_Local));
    280:   PetscCall(PetscLogEventRegister("MatColoringIS", MAT_COLORING_CLASSID, &MATCOLORING_ISCreate));
    281:   PetscCall(PetscLogEventRegister("MatColoringSetUp", MAT_COLORING_CLASSID, &MATCOLORING_SetUp));
    282:   PetscCall(PetscLogEventRegister("MatColoringWeights", MAT_COLORING_CLASSID, &MATCOLORING_Weights));

    284:   PetscCall(PetscLogEventRegister("MatSetPreallCOO", MAT_CLASSID, &MAT_PreallCOO));
    285:   PetscCall(PetscLogEventRegister("MatSetValuesCOO", MAT_CLASSID, &MAT_SetVCOO));

    287:   PetscCall(PetscLogEventRegister("MatH2OpusBuild", MAT_CLASSID, &MAT_H2Opus_Build));
    288:   PetscCall(PetscLogEventRegister("MatH2OpusComp", MAT_CLASSID, &MAT_H2Opus_Compress));
    289:   PetscCall(PetscLogEventRegister("MatH2OpusOrth", MAT_CLASSID, &MAT_H2Opus_Orthog));
    290:   PetscCall(PetscLogEventRegister("MatH2OpusLR", MAT_CLASSID, &MAT_H2Opus_LR));

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

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

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

    327:   /* Register the PETSc built in factorization based solvers */
    328:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
    329:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
    330:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
    331:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJ, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

    333:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
    334:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
    335:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
    336:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJPERM, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

    338:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_LU, MatGetFactor_constantdiagonal_petsc));
    339:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_CHOLESKY, MatGetFactor_constantdiagonal_petsc));
    340:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_ILU, MatGetFactor_constantdiagonal_petsc));
    341:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATCONSTANTDIAGONAL, MAT_FACTOR_ICC, MatGetFactor_constantdiagonal_petsc));

    343: #if defined(PETSC_HAVE_MKL_SPARSE)
    344:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
    345:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
    346:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
    347:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJMKL, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

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

    357:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_LU, MatGetFactor_seqaij_petsc));
    358:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_CHOLESKY, MatGetFactor_seqaij_petsc));
    359:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_ILU, MatGetFactor_seqaij_petsc));
    360:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQAIJCRL, MAT_FACTOR_ICC, MatGetFactor_seqaij_petsc));

    362:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_LU, MatGetFactor_seqbaij_petsc));
    363:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqbaij_petsc));
    364:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_ILU, MatGetFactor_seqbaij_petsc));
    365:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQBAIJ, MAT_FACTOR_ICC, MatGetFactor_seqbaij_petsc));

    367:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQSBAIJ, MAT_FACTOR_CHOLESKY, MatGetFactor_seqsbaij_petsc));
    368:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQSBAIJ, MAT_FACTOR_ICC, MatGetFactor_seqsbaij_petsc));

    370:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_LU, MatGetFactor_seqdense_petsc));
    371:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_ILU, MatGetFactor_seqdense_petsc));
    372:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_CHOLESKY, MatGetFactor_seqdense_petsc));
    373:   PetscCall(MatSolverTypeRegister(MATSOLVERPETSC, MATSEQDENSE, MAT_FACTOR_QR, MatGetFactor_seqdense_petsc));
    374: #if defined(PETSC_HAVE_CUDA)
    375:   PetscCall(MatSolverTypeRegister_DENSECUDA());
    376: #endif
    377: #if defined(PETSC_HAVE_HIP)
    378:   PetscCall(MatSolverTypeRegister_DENSEHIP());
    379: #endif

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

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

    449: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
    450: /*
    451:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

    455:  */
    456: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void)
    457: {
    458:   PetscFunctionBegin;
    459:   PetscCall(MatInitializePackage());
    460:   PetscFunctionReturn(PETSC_SUCCESS);
    461: }

    463: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */