[23186] | 1 | Index: ../trunk-jpl/src/c/toolkits/issm/IssmMat.h
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/toolkits/issm/IssmMat.h (revision 23043)
|
---|
| 4 | +++ ../trunk-jpl/src/c/toolkits/issm/IssmMat.h (revision 23044)
|
---|
| 5 | @@ -16,7 +16,7 @@
|
---|
| 6 | #include "../../shared/shared.h"
|
---|
| 7 | #include "../ToolkitOptions.h"
|
---|
| 8 | #include "./IssmToolkitUtils.h"
|
---|
| 9 | -
|
---|
| 10 | +#include "../mumps/mumpsincludes.h"
|
---|
| 11 | /*}}}*/
|
---|
| 12 |
|
---|
| 13 | /*We need to template this class, in case we want to create Matrices that hold
|
---|
| 14 | Index: ../trunk-jpl/src/c/toolkits/mumps/mumpsincludes.h
|
---|
| 15 | ===================================================================
|
---|
| 16 | --- ../trunk-jpl/src/c/toolkits/mumps/mumpsincludes.h (revision 23043)
|
---|
| 17 | +++ ../trunk-jpl/src/c/toolkits/mumps/mumpsincludes.h (revision 23044)
|
---|
| 18 | @@ -18,8 +18,11 @@
|
---|
| 19 | class Parameters;
|
---|
| 20 | template <class doubletype> class SparseRow;
|
---|
| 21 |
|
---|
| 22 | +#ifdef _HAVE_MPI_
|
---|
| 23 | void MpiDenseMumpsSolve(IssmDouble* uf,int uf_M,int uf_n, IssmDouble* Kff,int Kff_M, int Kff_N, int Kff_m, IssmDouble* pf, int pf_M, int pf_m, Parameters* parameters);
|
---|
| 24 | void MpiSparseMumpsSolve(IssmDouble* uf,int uf_M,int uf_n, SparseRow<IssmDouble>** Kff,int Kff_M, int Kff_N, int Kff_m, IssmDouble* pf, int pf_M, int pf_m, Parameters* parameters);
|
---|
| 25 | +#endif
|
---|
| 26 | +void SeqDenseMumpsSolve(IssmDouble* uf,int uf_M,int uf_n, IssmDouble* Kff,int Kff_M, int Kff_N, int Kff_m, IssmDouble* pf, int pf_M, int pf_m, Parameters* parameters);
|
---|
| 27 |
|
---|
| 28 | #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)
|
---|
| 29 | // call back functions:
|
---|
| 30 | Index: ../trunk-jpl/src/c/toolkits/issm/IssmDenseMat.h
|
---|
| 31 | ===================================================================
|
---|
| 32 | --- ../trunk-jpl/src/c/toolkits/issm/IssmDenseMat.h (revision 23043)
|
---|
| 33 | +++ ../trunk-jpl/src/c/toolkits/issm/IssmDenseMat.h (revision 23044)
|
---|
| 34 | @@ -271,15 +271,23 @@
|
---|
| 35 | /*Assume we are getting an IssmMpiVec in input, downcast: */
|
---|
| 36 | pf=(IssmSeqVec<IssmDouble>*)pfin;
|
---|
| 37 |
|
---|
| 38 | + #ifdef _HAVE_MUMPS_
|
---|
| 39 | + /*Assume we have a sequential vec, downcast*/
|
---|
| 40 | + uf=((IssmSeqVec<IssmDouble>*)pfin)->Duplicate();
|
---|
| 41 | + SeqDenseMumpsSolve(uf->vector,uf->M,uf->M, /*stiffness matrix:*/ this->matrix,this->M,this->N,this->M, /*right hand side load vector: */ pf->vector,pf->M,pf->M,parameters);
|
---|
| 42 | + return uf;
|
---|
| 43 | + #endif
|
---|
| 44 | +
|
---|
| 45 | #ifdef _HAVE_GSL_
|
---|
| 46 | DenseGslSolve(/*output*/ &x,/*stiffness matrix:*/ this->matrix,this->M,this->N, /*right hand side load vector: */ pf->vector,pf->M,parameters);
|
---|
| 47 |
|
---|
| 48 | uf=new IssmSeqVec<IssmDouble>(x,this->N); xDelete(x);
|
---|
| 49 | return uf;
|
---|
| 50 | - #else
|
---|
| 51 | - _error_("GSL support not compiled in!");
|
---|
| 52 | #endif
|
---|
| 53 |
|
---|
| 54 | + _error_("No solver available");
|
---|
| 55 | + return NULL;
|
---|
| 56 | +
|
---|
| 57 | }/*}}}*/
|
---|
| 58 | #endif
|
---|
| 59 | };
|
---|
| 60 | Index: ../trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp
|
---|
| 61 | ===================================================================
|
---|
| 62 | --- ../trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp (revision 23043)
|
---|
| 63 | +++ ../trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp (revision 23044)
|
---|
| 64 | @@ -26,7 +26,9 @@
|
---|
| 65 | void MumpsInit(DMUMPS_STRUC_C &theMumpsStruc){
|
---|
| 66 | theMumpsStruc.par = 1;
|
---|
| 67 | theMumpsStruc.sym = 0;
|
---|
| 68 | + #ifdef _HAVE_MPI_
|
---|
| 69 | theMumpsStruc.comm_fortran = MPI_Comm_c2f(IssmComm::GetComm());
|
---|
| 70 | + #endif
|
---|
| 71 | theMumpsStruc.job = -1;
|
---|
| 72 | dmumps_c(&theMumpsStruc);
|
---|
| 73 | }
|
---|
| 74 | @@ -34,7 +36,7 @@
|
---|
| 75 | // must be preceded by a call to MumpsInit
|
---|
| 76 | void MumpsSettings(DMUMPS_STRUC_C &theMumpsStruc) {
|
---|
| 77 | /*Control statements:{{{ */
|
---|
| 78 | - theMumpsStruc.icntl[1-1] = 6; //error verbose: default 6, 0 or negative -> suppressed
|
---|
| 79 | + theMumpsStruc.icntl[1-1] = 0; //error verbose: default 6, 0 or negative -> suppressed
|
---|
| 80 | theMumpsStruc.icntl[2-1] = 0; //std verbose: default 1, 0 or negative -> suppressed
|
---|
| 81 | theMumpsStruc.icntl[3-1] = 0; //global information verbose: default 6, 0 or negative -> suppressed
|
---|
| 82 | theMumpsStruc.icntl[4-1] = 0; //verbose everything: default is 4
|
---|
| 83 | @@ -107,6 +109,7 @@
|
---|
| 84 | Parameters* parameters);
|
---|
| 85 | #endif
|
---|
| 86 |
|
---|
| 87 | +#ifdef _HAVE_MPI_
|
---|
| 88 | void MpiDenseMumpsSolve( /*output: */ IssmDouble* uf, int uf_M, int uf_m, /*matrix input: */ IssmDouble* Kff, int Kff_M, int Kff_N, int Kff_m, /*right hand side vector: */ IssmDouble* pf, int pf_M, int pf_m, Parameters* parameters){ /*{{{*/
|
---|
| 89 |
|
---|
| 90 | /*Variables*/
|
---|
| 91 | @@ -200,7 +203,6 @@
|
---|
| 92 | xDelete<int>(recvcounts);
|
---|
| 93 | xDelete<int>(displs);
|
---|
| 94 | } /*}}}*/
|
---|
| 95 | -
|
---|
| 96 | void MpiSparseMumpsSolve( /*output: */ IssmDouble* uf, int uf_M, int uf_m, /*matrix input: */ SparseRow<IssmDouble>** Kff, int Kff_M, int Kff_N, int Kff_m, /*right hand side vector: */ IssmDouble* pf, int pf_M, int pf_m, Parameters* parameters){ /*{{{*/
|
---|
| 97 |
|
---|
| 98 | /*Variables*/
|
---|
| 99 | @@ -286,7 +288,72 @@
|
---|
| 100 | xDelete<int>(recvcounts);
|
---|
| 101 | xDelete<int>(displs);
|
---|
| 102 | } /*}}}*/
|
---|
| 103 | +#endif
|
---|
| 104 | +void SeqDenseMumpsSolve(IssmDouble* uf,int uf_M,int uf_m, IssmDouble* Kff,int Kff_M, int Kff_N, int Kff_m, IssmDouble* pf, int pf_M, int pf_m, Parameters* parameters){/*{{{*/
|
---|
| 105 |
|
---|
| 106 | + /*Variables*/
|
---|
| 107 | + int *irn_loc = NULL;
|
---|
| 108 | + int *jcn_loc = NULL;
|
---|
| 109 | + IssmDouble *a_loc = NULL;
|
---|
| 110 | + IssmDouble *rhs = NULL;
|
---|
| 111 | +
|
---|
| 112 | + /*First, some checks*/
|
---|
| 113 | + if (Kff_M!=Kff_N)_error_("stiffness matrix Kff should be square");
|
---|
| 114 | + if (Kff_M!=Kff_m)_error_("stiffness matrix Kff is not serial");
|
---|
| 115 | + if (uf_M!=Kff_M || uf_M!=pf_M)_error_("solution vector should be the same size as stiffness matrix Kff and load vector pf");
|
---|
| 116 | + if (uf_m!=Kff_m || uf_m!=pf_m)_error_("solution vector should be locally the same size as stiffness matrix Kff and load vector pf");
|
---|
| 117 | +
|
---|
| 118 | + /*Initialize matrix */
|
---|
| 119 | + /*figure out number of non-zero entries: */
|
---|
| 120 | + int nnz = 0;
|
---|
| 121 | + for(int i=0;i<Kff_M;i++){
|
---|
| 122 | + for(int j=0;j<Kff_N;j++){
|
---|
| 123 | + if(Kff[i*Kff_N+j]!=0)nnz++;
|
---|
| 124 | + }
|
---|
| 125 | + }
|
---|
| 126 | +
|
---|
| 127 | + /*Allocate: */
|
---|
| 128 | + if(nnz){
|
---|
| 129 | + irn_loc = xNew<int>(nnz);
|
---|
| 130 | + jcn_loc = xNew<int>(nnz);
|
---|
| 131 | + a_loc = xNew<IssmDouble>(nnz);
|
---|
| 132 | + }
|
---|
| 133 | +
|
---|
| 134 | + /*Populate the triplets: */
|
---|
| 135 | + int count=0;
|
---|
| 136 | + for(int i=0;i<Kff_M;i++){
|
---|
| 137 | + for(int j=0;j<Kff_N;j++){
|
---|
| 138 | + if(Kff[i*Kff_N+j]!=0){
|
---|
| 139 | + irn_loc[count] = i+1; //fortran indexing
|
---|
| 140 | + jcn_loc[count] = j+1; //fortran indexing
|
---|
| 141 | + a_loc[count] = Kff[i*Kff_N+j];
|
---|
| 142 | + count++;
|
---|
| 143 | + }
|
---|
| 144 | + }
|
---|
| 145 | + }
|
---|
| 146 | +
|
---|
| 147 | + /*Deal with right hand side. We need to ISSM_MPI_Gather it onto cpu 0: */
|
---|
| 148 | +// AD performance is sensitive to calls to ensurecontiguous.
|
---|
| 149 | +// Providing "t" will cause ensurecontiguous to be called.
|
---|
| 150 | +#ifdef _HAVE_AD_
|
---|
| 151 | + rhs=xNew<IssmDouble>(pf_M,"t");
|
---|
| 152 | +#else
|
---|
| 153 | + rhs=xNew<IssmDouble>(pf_M);
|
---|
| 154 | +#endif
|
---|
| 155 | + xMemCpy<IssmDouble>(rhs,pf,Kff_M);
|
---|
| 156 | +
|
---|
| 157 | + MumpsSolve(Kff_M,nnz,nnz,irn_loc,jcn_loc,a_loc,rhs,parameters);
|
---|
| 158 | +
|
---|
| 159 | + /*Now scatter from cpu 0 to all other cpus*/
|
---|
| 160 | + xMemCpy<IssmDouble>(uf,rhs,Kff_M);
|
---|
| 161 | +
|
---|
| 162 | + /*Cleanup*/
|
---|
| 163 | + xDelete<int>(irn_loc);
|
---|
| 164 | + xDelete<int>(jcn_loc);
|
---|
| 165 | + xDelete<IssmDouble>(a_loc);
|
---|
| 166 | + xDelete<IssmDouble>(rhs);
|
---|
| 167 | +}/*}}}*/
|
---|
| 168 | +
|
---|
| 169 | #ifdef _HAVE_ADOLC_
|
---|
| 170 |
|
---|
| 171 | int mumpsSolveEDF(int iArrLength, int* iArr, int /* ignored */, IssmPDouble* dp_x, int /* ignored */, IssmPDouble* dp_y) {
|
---|