|
kusano |
7d535a |
/*! @file util.c
|
|
kusano |
7d535a |
* \brief Utility functions
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
* -- SuperLU routine (version 4.1) --
|
|
kusano |
7d535a |
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
|
|
kusano |
7d535a |
* and Lawrence Berkeley National Lab.
|
|
kusano |
7d535a |
* November, 2010
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
* Copyright (c) 1994 by Xerox Corporation. All rights reserved.
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
|
|
kusano |
7d535a |
* EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
* Permission is hereby granted to use or copy this program for any
|
|
kusano |
7d535a |
* purpose, provided the above notices are retained on all copies.
|
|
kusano |
7d535a |
* Permission to modify the code and to distribute modified code is
|
|
kusano |
7d535a |
* granted, provided the above notices are retained, and a notice that
|
|
kusano |
7d535a |
* the code was modified is included with the above copyright notice.
|
|
kusano |
7d535a |
*
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
#include <math.h></math.h>
|
|
kusano |
7d535a |
#include "slu_ddefs.h"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Global statistics variale
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void superlu_abort_and_exit(char* msg)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
fprintf(stderr, msg);
|
|
kusano |
7d535a |
exit (-1);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Set the default values for the options argument.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void set_default_options(superlu_options_t *options)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
options->Fact = DOFACT;
|
|
kusano |
7d535a |
options->Equil = YES;
|
|
kusano |
7d535a |
options->ColPerm = COLAMD;
|
|
kusano |
7d535a |
options->Trans = NOTRANS;
|
|
kusano |
7d535a |
options->IterRefine = NOREFINE;
|
|
kusano |
7d535a |
options->DiagPivotThresh = 1.0;
|
|
kusano |
7d535a |
options->SymmetricMode = NO;
|
|
kusano |
7d535a |
options->PivotGrowth = NO;
|
|
kusano |
7d535a |
options->ConditionNumber = NO;
|
|
kusano |
7d535a |
options->PrintStat = YES;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Set the default values for the options argument for ILU.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void ilu_set_default_options(superlu_options_t *options)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
set_default_options(options);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* further options for incomplete factorization */
|
|
kusano |
7d535a |
options->DiagPivotThresh = 0.1;
|
|
kusano |
7d535a |
options->RowPerm = LargeDiag;
|
|
kusano |
7d535a |
options->ILU_DropRule = DROP_BASIC | DROP_AREA;
|
|
kusano |
7d535a |
options->ILU_DropTol = 1e-4;
|
|
kusano |
7d535a |
options->ILU_FillFactor = 10.0;
|
|
kusano |
7d535a |
options->ILU_Norm = INF_NORM;
|
|
kusano |
7d535a |
options->ILU_MILU = SILU;
|
|
kusano |
7d535a |
options->ILU_MILU_Dim = 3.0; /* -log(n)/log(h) is perfect */
|
|
kusano |
7d535a |
options->ILU_FillTol = 1e-2;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Print the options setting.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void print_options(superlu_options_t *options)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
printf(".. options:\n");
|
|
kusano |
7d535a |
printf("\tFact\t %8d\n", options->Fact);
|
|
kusano |
7d535a |
printf("\tEquil\t %8d\n", options->Equil);
|
|
kusano |
7d535a |
printf("\tColPerm\t %8d\n", options->ColPerm);
|
|
kusano |
7d535a |
printf("\tDiagPivotThresh %8.4f\n", options->DiagPivotThresh);
|
|
kusano |
7d535a |
printf("\tTrans\t %8d\n", options->Trans);
|
|
kusano |
7d535a |
printf("\tIterRefine\t%4d\n", options->IterRefine);
|
|
kusano |
7d535a |
printf("\tSymmetricMode\t%4d\n", options->SymmetricMode);
|
|
kusano |
7d535a |
printf("\tPivotGrowth\t%4d\n", options->PivotGrowth);
|
|
kusano |
7d535a |
printf("\tConditionNumber\t%4d\n", options->ConditionNumber);
|
|
kusano |
7d535a |
printf("..\n");
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Print the options setting.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void print_ilu_options(superlu_options_t *options)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
printf(".. ILU options:\n");
|
|
kusano |
7d535a |
printf("\tDiagPivotThresh\t%6.2e\n", options->DiagPivotThresh);
|
|
kusano |
7d535a |
printf("\ttau\t%6.2e\n", options->ILU_DropTol);
|
|
kusano |
7d535a |
printf("\tgamma\t%6.2f\n", options->ILU_FillFactor);
|
|
kusano |
7d535a |
printf("\tDropRule\t%0x\n", options->ILU_DropRule);
|
|
kusano |
7d535a |
printf("\tMILU\t%d\n", options->ILU_MILU);
|
|
kusano |
7d535a |
printf("\tMILU_ALPHA\t%6.2e\n", MILU_ALPHA);
|
|
kusano |
7d535a |
printf("\tDiagFillTol\t%6.2e\n", options->ILU_FillTol);
|
|
kusano |
7d535a |
printf("..\n");
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Deallocate the structure pointing to the actual storage of the matrix. */
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
Destroy_SuperMatrix_Store(SuperMatrix *A)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
SUPERLU_FREE ( A->Store );
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
Destroy_CompCol_Matrix(SuperMatrix *A)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
SUPERLU_FREE( ((NCformat *)A->Store)->rowind );
|
|
kusano |
7d535a |
SUPERLU_FREE( ((NCformat *)A->Store)->colptr );
|
|
kusano |
7d535a |
SUPERLU_FREE( ((NCformat *)A->Store)->nzval );
|
|
kusano |
7d535a |
SUPERLU_FREE( A->Store );
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
Destroy_CompRow_Matrix(SuperMatrix *A)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
SUPERLU_FREE( ((NRformat *)A->Store)->colind );
|
|
kusano |
7d535a |
SUPERLU_FREE( ((NRformat *)A->Store)->rowptr );
|
|
kusano |
7d535a |
SUPERLU_FREE( ((NRformat *)A->Store)->nzval );
|
|
kusano |
7d535a |
SUPERLU_FREE( A->Store );
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
Destroy_SuperNode_Matrix(SuperMatrix *A)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((SCformat *)A->Store)->rowind );
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((SCformat *)A->Store)->rowind_colptr );
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((SCformat *)A->Store)->nzval );
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((SCformat *)A->Store)->nzval_colptr );
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((SCformat *)A->Store)->col_to_sup );
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((SCformat *)A->Store)->sup_to_col );
|
|
kusano |
7d535a |
SUPERLU_FREE ( A->Store );
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief A is of type Stype==NCP */
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
Destroy_CompCol_Permuted(SuperMatrix *A)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((NCPformat *)A->Store)->colbeg );
|
|
kusano |
7d535a |
SUPERLU_FREE ( ((NCPformat *)A->Store)->colend );
|
|
kusano |
7d535a |
SUPERLU_FREE ( A->Store );
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief A is of type Stype==DN */
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
Destroy_Dense_Matrix(SuperMatrix *A)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
DNformat* Astore = A->Store;
|
|
kusano |
7d535a |
SUPERLU_FREE (Astore->nzval);
|
|
kusano |
7d535a |
SUPERLU_FREE ( A->Store );
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Reset repfnz[] for the current column
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
resetrep_col (const int nseg, const int *segrep, int *repfnz)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
int i, irep;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (i = 0; i < nseg; i++) {
|
|
kusano |
7d535a |
irep = segrep[i];
|
|
kusano |
7d535a |
repfnz[irep] = EMPTY;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Count the total number of nonzeros in factors L and U, and in the symmetrically reduced L.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
countnz(const int n, int *xprune, int *nnzL, int *nnzU, GlobalLU_t *Glu)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
int nsuper, fsupc, i, j;
|
|
kusano |
7d535a |
int nnzL0, jlen, irep;
|
|
kusano |
7d535a |
int *xsup, *xlsub;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
xsup = Glu->xsup;
|
|
kusano |
7d535a |
xlsub = Glu->xlsub;
|
|
kusano |
7d535a |
*nnzL = 0;
|
|
kusano |
7d535a |
*nnzU = (Glu->xusub)[n];
|
|
kusano |
7d535a |
nnzL0 = 0;
|
|
kusano |
7d535a |
nsuper = (Glu->supno)[n];
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ( n <= 0 ) return;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*
|
|
kusano |
7d535a |
* For each supernode
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
for (i = 0; i <= nsuper; i++) {
|
|
kusano |
7d535a |
fsupc = xsup[i];
|
|
kusano |
7d535a |
jlen = xlsub[fsupc+1] - xlsub[fsupc];
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (j = fsupc; j < xsup[i+1]; j++) {
|
|
kusano |
7d535a |
*nnzL += jlen;
|
|
kusano |
7d535a |
*nnzU += j - fsupc + 1;
|
|
kusano |
7d535a |
jlen--;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
irep = xsup[i+1] - 1;
|
|
kusano |
7d535a |
nnzL0 += xprune[irep] - xlsub[irep];
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* printf("\tNo of nonzeros in symm-reduced L = %d\n", nnzL0);*/
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Count the total number of nonzeros in factors L and U.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
ilu_countnz(const int n, int *nnzL, int *nnzU, GlobalLU_t *Glu)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
int nsuper, fsupc, i, j;
|
|
kusano |
7d535a |
int jlen, irep;
|
|
kusano |
7d535a |
int *xsup, *xlsub;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
xsup = Glu->xsup;
|
|
kusano |
7d535a |
xlsub = Glu->xlsub;
|
|
kusano |
7d535a |
*nnzL = 0;
|
|
kusano |
7d535a |
*nnzU = (Glu->xusub)[n];
|
|
kusano |
7d535a |
nsuper = (Glu->supno)[n];
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ( n <= 0 ) return;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*
|
|
kusano |
7d535a |
* For each supernode
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
for (i = 0; i <= nsuper; i++) {
|
|
kusano |
7d535a |
fsupc = xsup[i];
|
|
kusano |
7d535a |
jlen = xlsub[fsupc+1] - xlsub[fsupc];
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (j = fsupc; j < xsup[i+1]; j++) {
|
|
kusano |
7d535a |
*nnzL += jlen;
|
|
kusano |
7d535a |
*nnzU += j - fsupc + 1;
|
|
kusano |
7d535a |
jlen--;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
irep = xsup[i+1] - 1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Fix up the data storage lsub for L-subscripts. It removes the subscript sets for structural pruning, and applies permuation to the remaining subscripts.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
fixupL(const int n, const int *perm_r, GlobalLU_t *Glu)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
register int nsuper, fsupc, nextl, i, j, k, jstrt;
|
|
kusano |
7d535a |
int *xsup, *lsub, *xlsub;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ( n <= 1 ) return;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
xsup = Glu->xsup;
|
|
kusano |
7d535a |
lsub = Glu->lsub;
|
|
kusano |
7d535a |
xlsub = Glu->xlsub;
|
|
kusano |
7d535a |
nextl = 0;
|
|
kusano |
7d535a |
nsuper = (Glu->supno)[n];
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*
|
|
kusano |
7d535a |
* For each supernode ...
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
for (i = 0; i <= nsuper; i++) {
|
|
kusano |
7d535a |
fsupc = xsup[i];
|
|
kusano |
7d535a |
jstrt = xlsub[fsupc];
|
|
kusano |
7d535a |
xlsub[fsupc] = nextl;
|
|
kusano |
7d535a |
for (j = jstrt; j < xlsub[fsupc+1]; j++) {
|
|
kusano |
7d535a |
lsub[nextl] = perm_r[lsub[j]]; /* Now indexed into P*A */
|
|
kusano |
7d535a |
nextl++;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
for (k = fsupc+1; k < xsup[i+1]; k++)
|
|
kusano |
7d535a |
xlsub[k] = nextl; /* Other columns in supernode i */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
xlsub[n] = nextl;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Diagnostic print of segment info after panel_dfs().
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void print_panel_seg(int n, int w, int jcol, int nseg,
|
|
kusano |
7d535a |
int *segrep, int *repfnz)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
int j, k;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (j = jcol; j < jcol+w; j++) {
|
|
kusano |
7d535a |
printf("\tcol %d:\n", j);
|
|
kusano |
7d535a |
for (k = 0; k < nseg; k++)
|
|
kusano |
7d535a |
printf("\t\tseg %d, segrep %d, repfnz %d\n", k,
|
|
kusano |
7d535a |
segrep[k], repfnz[(j-jcol)*n + segrep[k]]);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
StatInit(SuperLUStat_t *stat)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
register int i, w, panel_size, relax;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
panel_size = sp_ienv(1);
|
|
kusano |
7d535a |
relax = sp_ienv(2);
|
|
kusano |
7d535a |
w = SUPERLU_MAX(panel_size, relax);
|
|
kusano |
7d535a |
stat->panel_histo = intCalloc(w+1);
|
|
kusano |
7d535a |
stat->utime = (double *) SUPERLU_MALLOC(NPHASES * sizeof(double));
|
|
kusano |
7d535a |
if (!stat->utime) ABORT("SUPERLU_MALLOC fails for stat->utime");
|
|
kusano |
7d535a |
stat->ops = (flops_t *) SUPERLU_MALLOC(NPHASES * sizeof(flops_t));
|
|
kusano |
7d535a |
if (!stat->ops) ABORT("SUPERLU_MALLOC fails for stat->ops");
|
|
kusano |
7d535a |
for (i = 0; i < NPHASES; ++i) {
|
|
kusano |
7d535a |
stat->utime[i] = 0.;
|
|
kusano |
7d535a |
stat->ops[i] = 0.;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
stat->TinyPivots = 0;
|
|
kusano |
7d535a |
stat->RefineSteps = 0;
|
|
kusano |
7d535a |
stat->expansions = 0;
|
|
kusano |
7d535a |
#if ( PRNTlevel >= 1 )
|
|
kusano |
7d535a |
printf(".. parameters in sp_ienv():\n");
|
|
kusano |
7d535a |
printf("\t 1: panel size \t %4d \n"
|
|
kusano |
7d535a |
"\t 2: relax \t %4d \n"
|
|
kusano |
7d535a |
"\t 3: max. super \t %4d \n"
|
|
kusano |
7d535a |
"\t 4: row-dim 2D \t %4d \n"
|
|
kusano |
7d535a |
"\t 5: col-dim 2D \t %4d \n"
|
|
kusano |
7d535a |
"\t 6: fill ratio \t %4d \n",
|
|
kusano |
7d535a |
sp_ienv(1), sp_ienv(2), sp_ienv(3),
|
|
kusano |
7d535a |
sp_ienv(4), sp_ienv(5), sp_ienv(6));
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
StatPrint(SuperLUStat_t *stat)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
double *utime;
|
|
kusano |
7d535a |
flops_t *ops;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
utime = stat->utime;
|
|
kusano |
7d535a |
ops = stat->ops;
|
|
kusano |
7d535a |
printf("Factor time = %8.2f\n", utime[FACT]);
|
|
kusano |
7d535a |
if ( utime[FACT] != 0.0 )
|
|
kusano |
7d535a |
printf("Factor flops = %e\tMflops = %8.2f\n", ops[FACT],
|
|
kusano |
7d535a |
ops[FACT]*1e-6/utime[FACT]);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
printf("Solve time = %8.2f\n", utime[SOLVE]);
|
|
kusano |
7d535a |
if ( utime[SOLVE] != 0.0 )
|
|
kusano |
7d535a |
printf("Solve flops = %e\tMflops = %8.2f\n", ops[SOLVE],
|
|
kusano |
7d535a |
ops[SOLVE]*1e-6/utime[SOLVE]);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
printf("Number of memory expansions: %d\n", stat->expansions);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
StatFree(SuperLUStat_t *stat)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
SUPERLU_FREE(stat->panel_histo);
|
|
kusano |
7d535a |
SUPERLU_FREE(stat->utime);
|
|
kusano |
7d535a |
SUPERLU_FREE(stat->ops);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
flops_t
|
|
kusano |
7d535a |
LUFactFlops(SuperLUStat_t *stat)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
return (stat->ops[FACT]);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
flops_t
|
|
kusano |
7d535a |
LUSolveFlops(SuperLUStat_t *stat)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
return (stat->ops[SOLVE]);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Fills an integer array with a given value.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void ifill(int *a, int alen, int ival)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
register int i;
|
|
kusano |
7d535a |
for (i = 0; i < alen; i++) a[i] = ival;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Get the statistics of the supernodes
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
#define NBUCKS 10
|
|
kusano |
7d535a |
static int max_sup_size;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
void super_stats(int nsuper, int *xsup)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
register int nsup1 = 0;
|
|
kusano |
7d535a |
int i, isize, whichb, bl, bh;
|
|
kusano |
7d535a |
int bucket[NBUCKS];
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
max_sup_size = 0;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (i = 0; i <= nsuper; i++) {
|
|
kusano |
7d535a |
isize = xsup[i+1] - xsup[i];
|
|
kusano |
7d535a |
if ( isize == 1 ) nsup1++;
|
|
kusano |
7d535a |
if ( max_sup_size < isize ) max_sup_size = isize;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
printf(" Supernode statistics:\n\tno of super = %d\n", nsuper+1);
|
|
kusano |
7d535a |
printf("\tmax supernode size = %d\n", max_sup_size);
|
|
kusano |
7d535a |
printf("\tno of size 1 supernodes = %d\n", nsup1);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Histogram of the supernode sizes */
|
|
kusano |
7d535a |
ifill (bucket, NBUCKS, 0);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (i = 0; i <= nsuper; i++) {
|
|
kusano |
7d535a |
isize = xsup[i+1] - xsup[i];
|
|
kusano |
7d535a |
whichb = (float) isize / max_sup_size * NBUCKS;
|
|
kusano |
7d535a |
if (whichb >= NBUCKS) whichb = NBUCKS - 1;
|
|
kusano |
7d535a |
bucket[whichb]++;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
printf("\tHistogram of supernode sizes:\n");
|
|
kusano |
7d535a |
for (i = 0; i < NBUCKS; i++) {
|
|
kusano |
7d535a |
bl = (float) i * max_sup_size / NBUCKS;
|
|
kusano |
7d535a |
bh = (float) (i+1) * max_sup_size / NBUCKS;
|
|
kusano |
7d535a |
printf("\tsnode: %d-%d\t\t%d\n", bl+1, bh, bucket[i]);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
float SpaSize(int n, int np, float sum_npw)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
return (sum_npw*8 + np*8 + n*4)/1024.;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
float DenseSize(int n, float sum_nw)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
return (sum_nw*8 + n*8)/1024.;;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Check whether repfnz[] == EMPTY after reset.
|
|
kusano |
7d535a |
*/
|
|
kusano |
7d535a |
void check_repfnz(int n, int w, int jcol, int *repfnz)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
int jj, k;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
for (jj = jcol; jj < jcol+w; jj++)
|
|
kusano |
7d535a |
for (k = 0; k < n; k++)
|
|
kusano |
7d535a |
if ( repfnz[(jj-jcol)*n + k] != EMPTY ) {
|
|
kusano |
7d535a |
fprintf(stderr, "col %d, repfnz_col[%d] = %d\n", jj,
|
|
kusano |
7d535a |
k, repfnz[(jj-jcol)*n + k]);
|
|
kusano |
7d535a |
ABORT("check_repfnz");
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/*! \brief Print a summary of the testing results. */
|
|
kusano |
7d535a |
void
|
|
kusano |
7d535a |
PrintSumm(char *type, int nfail, int nrun, int nerrs)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
if ( nfail > 0 )
|
|
kusano |
7d535a |
printf("%3s driver: %d out of %d tests failed to pass the threshold\n",
|
|
kusano |
7d535a |
type, nfail, nrun);
|
|
kusano |
7d535a |
else
|
|
kusano |
7d535a |
printf("All tests for %3s driver passed the threshold (%6d tests run)\n", type, nrun);
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
if ( nerrs > 0 )
|
|
kusano |
7d535a |
printf("%6d error messages recorded\n", nerrs);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
int print_int_vec(char *what, int n, int *vec)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
int i;
|
|
kusano |
7d535a |
printf("%s\n", what);
|
|
kusano |
7d535a |
for (i = 0; i < n; ++i) printf("%d\t%d\n", i, vec[i]);
|
|
kusano |
7d535a |
return 0;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
int slu_PrintInt10(char *name, int len, int *x)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
register int i;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
printf("%10s:", name);
|
|
kusano |
7d535a |
for (i = 0; i < len; ++i)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
if ( i % 10 == 0 ) printf("\n\t[%2d-%2d]", i, i + 9);
|
|
kusano |
7d535a |
printf("%6d", x[i]);
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
printf("\n");
|
|
kusano |
7d535a |
return 0;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|