2
* -- SuperLU routine (version 3.0) --
3
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
4
* and Lawrence Berkeley National Lab.
9
Copyright (c) 1994 by Xerox Corporation. All rights reserved.
11
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
12
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
14
Permission is hereby granted to use or copy this program for any
15
purpose, provided the above notices are retained on all copies.
16
Permission to modify the code and to distribute modified code is
17
granted, provided the above notices are retained, and a notice that
18
the code was modified is included with the above copyright notice.
26
flops_t LUFactFlops(SuperLUStat_t *stat);
27
flops_t LUSolveFlops(SuperLUStat_t *stat);
28
float SpaSize(int n, int np, float sum_npw);
29
float DenseSize(int n, float sum_nw);
32
* Global statistics variale
35
void superlu_abort_and_exit(char* msg)
42
* Set the default values for the options argument.
44
void set_default_options(superlu_options_t *options)
46
options->Fact = DOFACT;
48
options->ColPerm = COLAMD;
49
options->DiagPivotThresh = 1.0;
50
options->Trans = NOTRANS;
51
options->IterRefine = NOREFINE;
52
options->SymmetricMode = NO;
53
options->PivotGrowth = NO;
54
options->ConditionNumber = NO;
55
options->PrintStat = YES;
58
/* Deallocate the structure pointing to the actual storage of the matrix. */
60
Destroy_SuperMatrix_Store(SuperMatrix *A)
62
SUPERLU_FREE ( A->Store );
66
Destroy_CompCol_Matrix(SuperMatrix *A)
68
SUPERLU_FREE( ((NCformat *)A->Store)->rowind );
69
SUPERLU_FREE( ((NCformat *)A->Store)->colptr );
70
SUPERLU_FREE( ((NCformat *)A->Store)->nzval );
71
SUPERLU_FREE( A->Store );
75
Destroy_CompRow_Matrix(SuperMatrix *A)
77
SUPERLU_FREE( ((NRformat *)A->Store)->colind );
78
SUPERLU_FREE( ((NRformat *)A->Store)->rowptr );
79
SUPERLU_FREE( ((NRformat *)A->Store)->nzval );
80
SUPERLU_FREE( A->Store );
84
Destroy_SuperNode_Matrix(SuperMatrix *A)
86
SUPERLU_FREE ( ((SCformat *)A->Store)->rowind );
87
SUPERLU_FREE ( ((SCformat *)A->Store)->rowind_colptr );
88
SUPERLU_FREE ( ((SCformat *)A->Store)->nzval );
89
SUPERLU_FREE ( ((SCformat *)A->Store)->nzval_colptr );
90
SUPERLU_FREE ( ((SCformat *)A->Store)->col_to_sup );
91
SUPERLU_FREE ( ((SCformat *)A->Store)->sup_to_col );
92
SUPERLU_FREE ( A->Store );
95
/* A is of type Stype==NCP */
97
Destroy_CompCol_Permuted(SuperMatrix *A)
99
SUPERLU_FREE ( ((NCPformat *)A->Store)->colbeg );
100
SUPERLU_FREE ( ((NCPformat *)A->Store)->colend );
101
SUPERLU_FREE ( A->Store );
104
/* A is of type Stype==DN */
106
Destroy_Dense_Matrix(SuperMatrix *A)
108
DNformat* Astore = A->Store;
109
SUPERLU_FREE (Astore->nzval);
110
SUPERLU_FREE ( A->Store );
114
* Reset repfnz[] for the current column
117
resetrep_col (const int nseg, const int *segrep, int *repfnz)
121
for (i = 0; i < nseg; i++) {
123
repfnz[irep] = EMPTY;
129
* Count the total number of nonzeros in factors L and U, and in the
130
* symmetrically reduced L.
133
countnz(const int n, int *xprune, int *nnzL, int *nnzU, GlobalLU_t *Glu)
135
int nsuper, fsupc, i, j;
136
int nnzL0, jlen, irep;
142
*nnzU = (Glu->xusub)[n];
144
nsuper = (Glu->supno)[n];
146
if ( n <= 0 ) return;
151
for (i = 0; i <= nsuper; i++) {
153
jlen = xlsub[fsupc+1] - xlsub[fsupc];
155
for (j = fsupc; j < xsup[i+1]; j++) {
157
*nnzU += j - fsupc + 1;
160
irep = xsup[i+1] - 1;
161
nnzL0 += xprune[irep] - xlsub[irep];
164
/* printf("\tNo of nonzeros in symm-reduced L = %d\n", nnzL0);*/
170
* Fix up the data storage lsub for L-subscripts. It removes the subscript
171
* sets for structural pruning, and applies permuation to the remaining
175
fixupL(const int n, const int *perm_r, GlobalLU_t *Glu)
177
register int nsuper, fsupc, nextl, i, j, k, jstrt;
178
int *xsup, *lsub, *xlsub;
180
if ( n <= 1 ) return;
186
nsuper = (Glu->supno)[n];
189
* For each supernode ...
191
for (i = 0; i <= nsuper; i++) {
193
jstrt = xlsub[fsupc];
194
xlsub[fsupc] = nextl;
195
for (j = jstrt; j < xlsub[fsupc+1]; j++) {
196
lsub[nextl] = perm_r[lsub[j]]; /* Now indexed into P*A */
199
for (k = fsupc+1; k < xsup[i+1]; k++)
200
xlsub[k] = nextl; /* Other columns in supernode i */
209
* Diagnostic print of segment info after panel_dfs().
211
void print_panel_seg(int n, int w, int jcol, int nseg,
212
int *segrep, int *repfnz)
216
for (j = jcol; j < jcol+w; j++) {
217
printf("\tcol %d:\n", j);
218
for (k = 0; k < nseg; k++)
219
printf("\t\tseg %d, segrep %d, repfnz %d\n", k,
220
segrep[k], repfnz[(j-jcol)*n + segrep[k]]);
227
StatInit(SuperLUStat_t *stat)
229
register int i, w, panel_size, relax;
231
panel_size = sp_ienv(1);
233
w = SUPERLU_MAX(panel_size, relax);
234
stat->panel_histo = intCalloc(w+1);
235
stat->utime = (double *) SUPERLU_MALLOC(NPHASES * sizeof(double));
236
if (!stat->utime) ABORT("SUPERLU_MALLOC fails for stat->utime");
237
stat->ops = (flops_t *) SUPERLU_MALLOC(NPHASES * sizeof(flops_t));
238
if (!stat->ops) ABORT("SUPERLU_MALLOC fails for stat->ops");
239
for (i = 0; i < NPHASES; ++i) {
247
StatPrint(SuperLUStat_t *stat)
254
printf("Factor time = %8.2f\n", utime[FACT]);
255
if ( utime[FACT] != 0.0 )
256
printf("Factor flops = %e\tMflops = %8.2f\n", ops[FACT],
257
ops[FACT]*1e-6/utime[FACT]);
259
printf("Solve time = %8.2f\n", utime[SOLVE]);
260
if ( utime[SOLVE] != 0.0 )
261
printf("Solve flops = %e\tMflops = %8.2f\n", ops[SOLVE],
262
ops[SOLVE]*1e-6/utime[SOLVE]);
268
StatFree(SuperLUStat_t *stat)
270
SUPERLU_FREE(stat->panel_histo);
271
SUPERLU_FREE(stat->utime);
272
SUPERLU_FREE(stat->ops);
277
LUFactFlops(SuperLUStat_t *stat)
279
return (stat->ops[FACT]);
283
LUSolveFlops(SuperLUStat_t *stat)
285
return (stat->ops[SOLVE]);
293
* Fills an integer array with a given value.
295
void ifill(int *a, int alen, int ival)
298
for (i = 0; i < alen; i++) a[i] = ival;
304
* Get the statistics of the supernodes
307
static int max_sup_size;
309
void super_stats(int nsuper, int *xsup)
311
register int nsup1 = 0;
312
int i, isize, whichb, bl, bh;
317
for (i = 0; i <= nsuper; i++) {
318
isize = xsup[i+1] - xsup[i];
319
if ( isize == 1 ) nsup1++;
320
if ( max_sup_size < isize ) max_sup_size = isize;
323
printf(" Supernode statistics:\n\tno of super = %d\n", nsuper+1);
324
printf("\tmax supernode size = %d\n", max_sup_size);
325
printf("\tno of size 1 supernodes = %d\n", nsup1);
327
/* Histogram of the supernode sizes */
328
ifill (bucket, NBUCKS, 0);
330
for (i = 0; i <= nsuper; i++) {
331
isize = xsup[i+1] - xsup[i];
332
whichb = (float) isize / max_sup_size * NBUCKS;
333
if (whichb >= NBUCKS) whichb = NBUCKS - 1;
337
printf("\tHistogram of supernode sizes:\n");
338
for (i = 0; i < NBUCKS; i++) {
339
bl = (float) i * max_sup_size / NBUCKS;
340
bh = (float) (i+1) * max_sup_size / NBUCKS;
341
printf("\tsnode: %d-%d\t\t%d\n", bl+1, bh, bucket[i]);
347
float SpaSize(int n, int np, float sum_npw)
349
return (sum_npw*8 + np*8 + n*4)/1024.;
352
float DenseSize(int n, float sum_nw)
354
return (sum_nw*8 + n*8)/1024.;;
360
* Check whether repfnz[] == EMPTY after reset.
362
void check_repfnz(int n, int w, int jcol, int *repfnz)
366
for (jj = jcol; jj < jcol+w; jj++)
367
for (k = 0; k < n; k++)
368
if ( repfnz[(jj-jcol)*n + k] != EMPTY ) {
369
fprintf(stderr, "col %d, repfnz_col[%d] = %d\n", jj,
370
k, repfnz[(jj-jcol)*n + k]);
371
ABORT("check_repfnz");
376
/* Print a summary of the testing results. */
378
PrintSumm(char *type, int nfail, int nrun, int nerrs)
381
printf("%3s driver: %d out of %d tests failed to pass the threshold\n",
384
printf("All tests for %3s driver passed the threshold (%6d tests run)\n", type, nrun);
387
printf("%6d error messages recorded\n", nerrs);
391
int print_int_vec(char *what, int n, int *vec)
394
printf("%s\n", what);
395
for (i = 0; i < n; ++i) printf("%d\t%d\n", i, vec[i]);