110 yes_no_t refact, usepr;
115 superlumt_options_t superlumt_options;
116 int_t info, lwork, nrhs, panel_size, relax;
118 double *rhsb, *rhsx ;
121 double drop_tol, rpg,
rcond;
122 superlu_memusage_t superlu_memusage;
123 void parse_command_line();
127 nprocs = omp_get_max_threads();
128 printf(
"Use number of LU threads: %u\n", nprocs);
133 panel_size = sp_ienv(1);
149 dCreate_CompCol_Matrix(& this->
A, m, n, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE);
150 if ( !( this->
perm_r = intMalloc(m) ) ) {
151 SUPERLU_ABORT(
"Malloc fails for perm_r[].");
153 if ( !( this->
perm_c = intMalloc(n) ) ) {
154 SUPERLU_ABORT(
"Malloc fails for perm_c[].");
156 dCreate_Dense_Matrix(& B, m, nrhs, b.
givePointer(), m, SLU_DN, SLU_D, SLU_GE);
160 pdgssv(nprocs, &this->
A, this->
perm_c, this->
perm_r, &this->
L, &this->
U, &B, &info);
164 Destroy_SuperMatrix_Store(& this->
A);
165 Destroy_SuperMatrix_Store(& B);
166 Destroy_SuperNode_SCP(& this->
L);
167 Destroy_CompCol_NCP(& this->
U);
168 SUPERLU_FREE(this->
perm_r);
169 SUPERLU_FREE(this->
perm_c);
177 work = SUPERLU_MALLOC(lwork);
178 OOFEM_LOG_DEBUG(
"Use work space of size LWORK = " IFMT
" bytes\n", lwork);
180 SUPERLU_ABORT(
"cannot allocate work[]");
186#if ( PRNTlevel == 1 )
188 printf(
"int_t %d bytes\n",
sizeof( int_t ) );
198 if (this->
AAllocated) Destroy_SuperMatrix_Store(& this->
A);
199 dCreate_CompCol_Matrix(& this->
A, m, n, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE);
205 if ( !( this->
perm_r = intMalloc(m) ) ) {
206 SUPERLU_ABORT(
"Malloc fails for perm_r[].");
208 if ( !( this->
perm_c = intMalloc(n) ) ) {
209 SUPERLU_ABORT(
"Malloc fails for perm_c[].");
215 if ( !( rhsb = doubleMalloc(m * nrhs) ) ) {
216 SUPERLU_ABORT(
"Malloc fails for rhsb[].");
218 if ( !( rhsx = doubleMalloc(m * nrhs) ) ) {
219 SUPERLU_ABORT(
"Malloc fails for rhsx[].");
221 dCreate_Dense_Matrix(& B, m, nrhs, b.
givePointer(), m, SLU_DN, SLU_D, SLU_GE);
222 dCreate_Dense_Matrix(& X, m, nrhs, rhsx, m, SLU_DN, SLU_D, SLU_GE);
226 if ( !( R = (
double * ) SUPERLU_MALLOC( this->
A.nrow *
sizeof(
double ) ) ) ) {
227 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for R[].");
229 if ( !( C = (
double * ) SUPERLU_MALLOC( this->
A.ncol *
sizeof(
double ) ) ) ) {
230 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for C[].");
232 if ( !( ferr = (
double * ) SUPERLU_MALLOC( nrhs *
sizeof(
double ) ) ) ) {
233 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for ferr[].");
235 if ( !( berr = (
double * ) SUPERLU_MALLOC( nrhs *
sizeof(
double ) ) ) ) {
236 SUPERLU_ABORT(
"SUPERLU_MALLOC fails for berr[].");
241 superlumt_options.SymmetricMode = YES;
242 superlumt_options.diag_pivot_thresh = 0.0;
244 superlumt_options.nprocs = nprocs;
245 superlumt_options.fact = fact;
246 superlumt_options.trans = trans;
247 superlumt_options.refact = refact;
248 superlumt_options.panel_size = panel_size;
249 superlumt_options.relax = relax;
250 superlumt_options.usepr = usepr;
251 superlumt_options.drop_tol = drop_tol;
252 superlumt_options.PrintStat = NO;
253 superlumt_options.perm_c =
perm_c;
254 superlumt_options.perm_r =
perm_r;
256 superlumt_options.lwork = lwork;
257 if ( !( superlumt_options.etree = intMalloc(n) ) ) {
258 SUPERLU_ABORT(
"Malloc fails for etree[].");
260 if ( !( superlumt_options.colcnt_h = intMalloc(n) ) ) {
261 SUPERLU_ABORT(
"Malloc fails for colcnt_h[].");
263 if ( !( superlumt_options.part_super_h = intMalloc(n) ) ) {
264 SUPERLU_ABORT(
"Malloc fails for colcnt_h[].");
268 superlumt_options.SymmetricMode,
269 superlumt_options.diag_pivot_thresh);
275 pdgssvx(nprocs, & superlumt_options, & this->
A, this->
perm_c, this->
perm_r, & equed, R, C, & this->
L, & this->
U, & B, & X, & rpg, &
rcond, ferr, berr, & superlu_memusage, & info);
280 printf(
"psgssvx(): info " IFMT
"\n", info);
282 if ( info == 0 || info == n + 1 ) {
286 printf(
"Recip. pivot growth = %e\n", rpg);
287 printf(
"Recip. condition number = %e\n",
rcond);
288 printf(
"%8s%16s%16s\n",
"rhs",
"FERR",
"BERR");
289 for (
int i = 0; i < nrhs; ++i ) {
290 printf(IFMT
"%16e%16e\n", i + 1, ferr [ i ], berr [ i ]);
293 Lstore = ( SCPformat * )
L.Store;
294 Ustore = ( NCPformat * )
U.Store;
295 printf(
"No of nonzeros in factor L = " IFMT
"\n", Lstore->nnz);
296 printf(
"No of nonzeros in factor U = " IFMT
"\n", Ustore->nnz);
297 printf(
"No of nonzeros in L+U = " IFMT
"\n", Lstore->nnz + Ustore->nnz - n);
298 printf(
"L\\U MB %.3f\ttotal MB needed %.3f\texpansions " IFMT
"\n",
299 superlu_memusage.for_lu / 1e6, superlu_memusage.total_needed / 1e6,
300 superlu_memusage.expansions);
303 }
else if ( info > 0 && lwork == -1 ) {
304 printf(
"** Estimated memory: " IFMT
" bytes\n", info - n);
307 if ( info > 0 && lwork == -1 ) {
308 printf(
"** Estimated memory: " IFMT
" bytes\n", info - n);
320 Destroy_SuperMatrix_Store(& B);
321 Destroy_SuperMatrix_Store(& X);
328 }
else if ( lwork > 0 ) {
339 OOFEM_ERROR(
"Incompatible sparse storage encountered");