41 #include "SUPERLU_MT/include/slu_mt_ddefs.h" 86 yes_no_t refact, usepr;
93 superlumt_options_t superlumt_options;
94 int_t info, lwork, nrhs, panel_size, relax;
95 int_t m, n, nnz, permc_spec;
99 double drop_tol, rpg, rcond;
100 superlu_memusage_t superlu_memusage;
101 void parse_command_line();
104 nprocs = omp_get_max_threads();
105 printf(
"Use number of LU threads: %u\n", nprocs);
110 panel_size = sp_ienv(1);
130 work = SUPERLU_MALLOC(lwork);
131 printf(
"Use work space of size LWORK = " IFMT
" bytes\n", lwork);
133 SUPERLU_ABORT(
"cannot allocate work[]");
139 #if ( PRNTlevel == 1 ) 141 printf(
"int_t %d bytes\n",
sizeof( int_t ) );
151 dCreate_CompCol_Matrix(& A, m, n, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE);
154 if ( !( rhsb = doubleMalloc(m * nrhs) ) ) {
155 SUPERLU_ABORT(
"Malloc fails for rhsb[].");
157 if ( !( rhsx = doubleMalloc(m * nrhs) ) ) {
158 SUPERLU_ABORT(
"Malloc fails for rhsx[].");
160 dCreate_Dense_Matrix(& B, m, nrhs, b.
givePointer(), m, SLU_DN, SLU_D, SLU_GE);
161 dCreate_Dense_Matrix(& X, m, nrhs, rhsx, m, SLU_DN, SLU_D, SLU_GE);
165 if ( !( perm_r = intMalloc(m) ) ) {
166 SUPERLU_ABORT(
"Malloc fails for perm_r[].");
168 if ( !( perm_c = intMalloc(n) ) ) {
169 SUPERLU_ABORT(
"Malloc fails for perm_c[].");
171 if ( !( R = (
double * ) SUPERLU_MALLOC( A.nrow *
sizeof(
double ) ) ) ) {
172 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for R[].");
174 if ( !( C = (
double * ) SUPERLU_MALLOC( A.ncol *
sizeof(
double ) ) ) ) {
175 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for C[].");
177 if ( !( ferr = (
double * ) SUPERLU_MALLOC( nrhs *
sizeof(
double ) ) ) ) {
178 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for ferr[].");
180 if ( !( berr = (
double * ) SUPERLU_MALLOC( nrhs *
sizeof(
double ) ) ) ) {
181 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for berr[].");
193 get_perm_c(permc_spec, & A, perm_c);
195 superlumt_options.SymmetricMode = YES;
196 superlumt_options.diag_pivot_thresh = 0.0;
198 superlumt_options.nprocs = nprocs;
199 superlumt_options.fact = fact;
200 superlumt_options.trans = trans;
201 superlumt_options.refact = refact;
202 superlumt_options.panel_size = panel_size;
203 superlumt_options.relax = relax;
204 superlumt_options.usepr = usepr;
205 superlumt_options.drop_tol = drop_tol;
206 superlumt_options.PrintStat = NO;
207 superlumt_options.perm_c = perm_c;
208 superlumt_options.perm_r = perm_r;
210 superlumt_options.lwork = lwork;
211 if ( !( superlumt_options.etree = intMalloc(n) ) ) {
212 SUPERLU_ABORT(
"Malloc fails for etree[].");
214 if ( !( superlumt_options.colcnt_h = intMalloc(n) ) ) {
215 SUPERLU_ABORT(
"Malloc fails for colcnt_h[].");
217 if ( !( superlumt_options.part_super_h = intMalloc(n) ) ) {
218 SUPERLU_ABORT(
"Malloc fails for colcnt_h[].");
221 printf(
"sym_mode %d\tdiag_pivot_thresh %.4e\n",
222 superlumt_options.SymmetricMode,
223 superlumt_options.diag_pivot_thresh);
229 pdgssvx(nprocs, & superlumt_options, & A, perm_c, perm_r, & equed, R, C, & L, & U, & B, & X, & rpg, & rcond, ferr, berr, & superlu_memusage, & info);
235 printf(
"psgssvx(): info " IFMT
"\n", info);
237 if ( info == 0 || info == n + 1 ) {
241 printf(
"Recip. pivot growth = %e\n", rpg);
242 printf(
"Recip. condition number = %e\n", rcond);
243 printf(
"%8s%16s%16s\n",
"rhs",
"FERR",
"BERR");
244 for (
int i = 0; i < nrhs; ++i ) {
245 printf(IFMT
"%16e%16e\n", i + 1, ferr [ i ], berr [ i ]);
248 Lstore = ( SCPformat * ) L.Store;
249 Ustore = ( NCPformat * ) U.Store;
250 printf(
"No of nonzeros in factor L = " IFMT
"\n", Lstore->nnz);
251 printf(
"No of nonzeros in factor U = " IFMT
"\n", Ustore->nnz);
252 printf(
"No of nonzeros in L+U = " IFMT
"\n", Lstore->nnz + Ustore->nnz - n);
253 printf(
"L\\U MB %.3f\ttotal MB needed %.3f\texpansions " IFMT
"\n",
254 superlu_memusage.for_lu / 1e6, superlu_memusage.total_needed / 1e6,
255 superlu_memusage.expansions);
258 }
else if ( info > 0 && lwork == -1 ) {
259 printf(
"** Estimated memory: " IFMT
" bytes\n", info - n);
262 if ( info > 0 && lwork == -1 ) {
263 printf(
"** Estimated memory: " IFMT
" bytes\n", info - n);
274 SUPERLU_FREE(perm_r);
275 SUPERLU_FREE(perm_c);
280 Destroy_SuperMatrix_Store(& A);
281 Destroy_SuperMatrix_Store(& B);
282 Destroy_SuperMatrix_Store(& X);
287 Destroy_SuperNode_SCP(& L);
288 Destroy_CompCol_NCP(& U);
289 }
else if ( lwork > 0 ) {
299 OOFEM_ERROR(
"Incompatible sparse storage encountered");
326 if ( ( X->Stype == SLU_DN ) && ( X->Dtype == SLU_D ) ) {
329 DNformat *data = ( ( DNformat * ) ( X->Store ) );
333 #pragma omp parallel for 334 for (
int r = 0; r <= data->lda - 1; r++ ) {
336 x.
at(r + 1) = ( (
double * ) data->nzval ) [ r ];
340 OOFEM_ERROR(
"convertRhs: unsupported matrix storage type or data type");
351 printf(
"\nCompCol matrix: ");
352 printf(
"Stype %d, Dtype %d, Mtype %d\n", A->Stype, A->Dtype, A->Mtype);
353 Astore = ( NCformat * ) A->Store;
354 dp = (
double * ) Astore->nzval;
355 printf(
"nrow " IFMT
", ncol " IFMT
", nnz " IFMT
"\n", A->nrow, A->ncol, Astore->nnz);
357 for ( i = 0; i < Astore->nnz; ++i ) {
358 printf(
"%f ", dp [ i ]);
360 printf(
"\nrowind: ");
361 for ( i = 0; i < Astore->nnz; ++i ) {
362 printf(IFMT, Astore->rowind [ i ]);
364 printf(
"\ncolptr: ");
365 for ( i = 0; i <= A->ncol; ++i ) {
366 printf(IFMT, Astore->colptr [ i ]);
368 printf(
"\nend CompCol matrix.\n");
379 printf(
"\nDense matrix: ");
380 printf(
"Stype %d , Dtype %d , Mtype %d\n", A->Stype, A->Dtype, A->Mtype);
381 Astore = ( DNformat * ) A->Store;
382 dp = (
double * ) Astore->nzval;
383 printf(
"nrow " IFMT
", ncol " IFMT
", lda " IFMT
"\n",
384 A->nrow, A->ncol, Astore->lda);
386 for ( i = 0; i < A->nrow; ++i ) {
387 printf(
"%f ", dp [ i ]);
389 printf(
"\nend Dense matrix.\n");
396 int_t *colend, int_t *perm)
398 register int_t i, j, nzd, nd = 0;
400 for ( j = 0; j < n; ++j ) {
402 for ( i = colbeg [ j ]; i < colend [ j ]; ++i ) {
403 if ( perm [ rowind [ i ] ] == j ) {
410 printf(
"Zero diagonal at column " IFMT
"\n", j);
414 printf(
".. dCheckZeroDiagonal() -- # diagonals " IFMT
"\n", nd);
IntArray & giveRowIndex()
#define NM_Success
Numerical method exited with success.
Base class for all matrices stored in sparse format.
double & at(int i)
Coefficient access function.
This base class is an abstraction for all numerical methods solving sparse linear system of equations...
const int * givePointer() const
Breaks encapsulation.
int_t dPrint_Dense_Matrix(SuperMatrix *A)
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
FloatArray & giveValues()
virtual NM_Status solve(SparseMtrx &A, FloatArray &b, FloatArray &x)
Solves the given linear system iteratively by method described by SuperLU SolverType.
int giveNumberOfRows() const
Returns number of rows of receiver.
#define OOFEM_LOG_INFO(...)
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
Class representing vector of real numbers.
Class implementig interface to SuperLU_MT solver.
IRResultType
Type defining the return values of InputRecord reading operations.
void zero()
Zeroes all coefficients of receiver.
REGISTER_SparseLinSolver(IMLSolver, ST_IML)
Class implementing single timer, providing wall clock and user time capabilities. ...
const double * givePointer() const
Gives the pointer to the raw data, breaking encapsulation.
virtual ~SuperLUSolver()
Destructor.
int giveNumberOfColumns() const
Returns number of columns of receiver.
int_t dCheckZeroDiagonal(int_t n, int_t *rowind, int_t *colbeg, int_t *colend, int_t *perm)
Abstract base class representing the "problem" under consideration.
double getWtime()
Returns total elapsed wall clock time in seconds.
int giveSize() const
Returns the size of receiver.
the oofem namespace is to define a context or scope in which all oofem names are defined.
void convertRhs(SuperMatrix *A, FloatArray &x)
const int giveNumberOfNonzeros()
double getUtime()
Returns total user time elapsed in seconds.
int_t dPrint_CompCol_Matrix(SuperMatrix *A)
void resize(int s)
Resizes receiver towards requested size.