Cluster Mode
Replaceability
You can control the solution process by configuring variables in the structure, for example, JOB that specifies the operation performed by MUMPS, and arrays ICNTL and CNTL that are used to configure the MUMPS solution function. You can also obtain the intermediate or final solution result by using the structure. KML_SCASOLVER supports multiple processes and threads on multiple nodes, which can replace the multi-node and multi-process function of MUMPS. Currently, the MUMPS interface of the double type has been implemented. The JOB parameter can be -1, -2, 1, 2, 3, or 6. General matrices, symmetric positive definite matrices, and general symmetric matrices are supported.
MUMPS Interface |
KML_SOLVER Interface |
|---|---|
id.job=JOB_INIT; dmumps_c(&id); |
KmlScadssInit |
id.job=1; dmumps_c(&id); |
KmlScadssAnalyze |
id.job=2; dmumps_c(&id); |
KmlScadssFactorize |
id.job=3; dmumps_c(&id); |
KmlScadssSolve |
id.job=JOB_END; dmumps_c(&id); |
KmlScadssClean |
Migration Procedure
Migration Through the Adaptation Layer
Both MUMPS and KML_SCASOLVER provide C interfaces. You can directly migrate them through the adaptation layer.
- Change #include "dmumps_c.h" to #include "MUMPS_kp.h".
- Load the HPCKit environment variables to set the MUMPS_kp.h path of the KML solver adapter and the kscasolver dynamic library path by referring to "Setting Environment Variables" in the Kunpeng HPCKit 26.1.RC1 Installation Guide. Then, recompile the application.
mpicc program.c -ldmumps_kp -lkscasolver -lkservice -lklapack -lkblas -lkm -lm
Before and after the migration, the initialization interface of MUMPS is different from that of the KML adaptation layer. The initialization of MUMPS is performed before the matrix A is input, while the initialization of the KML adaptation layer is performed after the matrix A is input.
* Real-world application scenarios often require flexible invocation. For more information, refer to the internal implementation of the adaptation layer in dmumps_kunpeng.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include <stdio.h> #include <stdlib.h> #include "mpi.h" #include "dmumps_c.h" int main ( int argc , char**argv ) { DMUMPS_STRUC_C id ; int n = 2; int64_t nnz = 2; int irn[] = { 1, 2 }; // MUMPS supports only the COO storage format. int jcn[] = { 1, 2 }; double *a = (double *)malloc(2*sizeof(double)); double *rhs = (double *)malloc(2*sizeof(double)); //double a[2]; //double rhs[2]; double sol[] = {0, 0}; int myid, ierr; ierr = MPI_Init(&argc, &argv); ierr = MPI_Comm_rank(MPI_COMM_WORLD, &myid); /*Define A and rhs */ rhs[0] = 1.0; rhs[1] = 4.0; a[0] = 1.0; a[1] = 2.0; /*Initialize MUMPS instance.Use MPI COMM WORLD.*/ id.job = JOB_INIT; id.par = 1; id.sym = 0; id.comm_fortran = USE_COMM_WORLD; dmumps_c(&id); /*Define the problem on the host */ if (myid == 0) { id.n = n; id.nnz = nnz; id.irn = irn; id.jcn = jcn; id.a = a; id.rhs = rhs; } #define ICNTL(I) icntl[(I)-1] /*macro s.t.indices match documentation*/ /*No outputs */ id.ICNTL(1) = -1; id.ICNTL(2) = -1; id.ICNTL(3) = -1; id.ICNTL(4) = 0; /*Call the MUMPS package.*/ id.job = 6; //Analyze + Factorize + Solve dmumps_c(&id); id.job = JOB_END; dmumps_c(&id); /*Terminate instance */ if (myid == 0) { printf( " Solution is : (%8.2f %8.2f)\n", rhs[0], rhs[1]); } ierr = MPI_Finalize(); return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #include <stdio.h> #include <stdlib.h> #include "mpi.h" #include "MUMPS_kp.h" int main ( int argc , char**argv ) { DMUMPS_STRUC_C id ; int n = 2; int64_t nnz = 2; int irn[] = { 1, 2 }; // MUMPS supports only the COO storage format. int jcn[] = { 1, 2 }; double *a = (double *)malloc(2*sizeof(double)); double *rhs = (double *)malloc(2*sizeof(double)); //double a[2]; //double rhs[2]; double sol[] = {0, 0}; int myid, ierr; ierr = MPI_Init(&argc, &argv); ierr = MPI_Comm_rank(MPI_COMM_WORLD, &myid); /*Define A and rhs */ rhs[0] = 1.0; rhs[1] = 4.0; a[0] = 1.0; a[1] = 2.0; /*Initialize MUMPS instance.Use MPI COMM WORLD.*/ id.job = JOB_INIT; id.par = 1; id.sym = 0; id.comm_fortran = USE_COMM_WORLD; if (myid == 0) { id.n = n; id.nnz = nnz; id.irn = irn; id.jcn = jcn; id.a = a; id.rhs = rhs; } dmumps_c(&id); /*Define the problem on the host */ #define ICNTL(I) icntl[(I)-1] /*macro s.t.indices match documentation*/ /*No outputs */ id.ICNTL(1) = -1; id.ICNTL(2) = -1; id.ICNTL(3) = -1; id.ICNTL(4) = 0; /*Call the MUMPS package.*/ id.job = 6; //Analyze + Factorize + Solve dmumps_c(&id); id.job = JOB_END; dmumps_c(&id); /*Terminate instance */ if (myid == 0) { printf( " Solution is : (%8.2f %8.2f)\n", rhs[0], rhs[1]); } ierr = MPI_Finalize(); return 0; } |