From c173a6642c1dbb726c58777145396be3b194c747 Mon Sep 17 00:00:00 2001 From: Sherry Li Date: Sun, 31 Dec 2023 09:25:36 -0800 Subject: [PATCH] Fix TESTING driver: when calling xgst01(), only compute the leading nonzero columns of L*U(:, 1:izero) --- TESTING/cdrive.c | 52 ++++++++++++++++++++++++++++-------------------- TESTING/ddrive.c | 43 +++++++++++++++++++++++---------------- TESTING/sdrive.c | 44 +++++++++++++++++++++++----------------- TESTING/zdrive.c | 43 +++++++++++++++++++++++---------------- make.inc.in | 6 ++++-- 5 files changed, 112 insertions(+), 76 deletions(-) diff --git a/TESTING/cdrive.c b/TESTING/cdrive.c index 6df0634c..07d96188 100644 --- a/TESTING/cdrive.c +++ b/TESTING/cdrive.c @@ -18,15 +18,14 @@ at the top-level directory. */ /*! \file - * CDRIVE is the main test program for the COMPLEX linear + * CDRIVE is the main test program for the SINGLE COMPLEX linear * equation driver routines CGSSV and CGSSVX. - * + * * The program is invoked by a shell script file -- ctest.csh. * The output from the tests are written into a file -- ctest.out. * * \ingroup TestingC */ - #include #include #include "slu_cdefs.h" @@ -79,8 +78,9 @@ int main(int argc, char *argv[]) int prefact, equil, iequed; int nt, nrun, nfail, nerrs, imat, fimat, nimat; int nfact, ifact, itran; - int kl, ku, mode, lda; - int zerot, izero, ioff; + int kl, ku, mode, lda, ioff; + int zerot; /* indicate whether the matrix is singular */ + int izero; /* incidate the first column that is entirely zero */ double u; float anorm, cndnum; singlecomplex *Afull; @@ -110,6 +110,11 @@ int main(int argc, char *argv[]) extern int cgst07(trans_t, int, int, SuperMatrix *, singlecomplex *, int, singlecomplex *, int, singlecomplex *, int, float *, float *, float *); + extern int clatb4_slu(char *, int *, int *, int *, char *, int *, int *, + float *, int *, float *, char *); + extern int clatms_slu(int *, int *, char *, int *, char *, float *d, + int *, float *, float *, int *, int *, + char *, singlecomplex *, int *, singlecomplex *, int *); extern int sp_cconvert(int, int, singlecomplex *, int, int, int, singlecomplex *a, int_t *, int_t *, int_t *); @@ -155,7 +160,7 @@ int main(int argc, char *argv[]) nnz = n * n; /* upper bound */ fimat = 1; nimat = NTYPES; - Afull = complexCalloc(lda * n); + Afull = (singlecomplex *) complexCalloc(lda * n); callocateA(n, nnz, &a, &asub, &xa); } else { /* Read a sparse matrix */ @@ -164,14 +169,16 @@ int main(int argc, char *argv[]) } callocateA(n, nnz, &a_save, &asub_save, &xa_save); - rhsb = complexMalloc(m * nrhs); - bsav = complexMalloc(m * nrhs); - solx = complexMalloc(n * nrhs); + rhsb = (singlecomplex *) complexMalloc(m * nrhs); + bsav = (singlecomplex *) complexMalloc(m * nrhs); + solx = (singlecomplex *) complexMalloc(n * nrhs); + xact = (singlecomplex *) complexMalloc(n * nrhs); + wwork = (singlecomplex *) complexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); + ldb = m; ldx = n; cCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_C, SLU_GE); cCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_C, SLU_GE); - xact = complexMalloc(n * nrhs); etree = int32Malloc(n); perm_r = int32Malloc(n); perm_c = int32Malloc(n); @@ -188,7 +195,6 @@ int main(int argc, char *argv[]) if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr"); if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr"); if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork"); - wwork = complexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i; options.ColPerm = MY_PERMC; @@ -231,14 +237,14 @@ int main(int argc, char *argv[]) Afull[ioff + i + j*lda] = zero; } } else { - izero = 0; + izero = n+1; /* none of the column is zero */ } /* Convert to sparse representation. */ sp_cconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz); } else { - izero = 0; + izero = n+1; /* none of the column is zero */ zerot = 0; } @@ -354,12 +360,13 @@ int main(int argc, char *argv[]) printf(FMT3, "cgssv", (int) info, izero, n, nrhs, imat, nfail); } else { - /* Reconstruct matrix from factors and - compute residual. */ - cgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + cgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); nt = 1; - if ( izero == 0 ) { + if ( izero == (n+1) ) { /* Compute residual of the computed solution. */ cCopy_Dense_Matrix(m, nrhs, rhsb, ldb, @@ -418,9 +425,10 @@ int main(int argc, char *argv[]) } } else { if ( !prefact ) { - /* Reconstruct matrix from factors and - compute residual. */ - cgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + cgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); k1 = 0; } else { @@ -513,8 +521,8 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -} + return (nfail == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} /* end main */ /*! * Parse command line options to get relaxed snode size, panel size, etc. diff --git a/TESTING/ddrive.c b/TESTING/ddrive.c index 116d2310..ab7bf783 100644 --- a/TESTING/ddrive.c +++ b/TESTING/ddrive.c @@ -18,9 +18,9 @@ at the top-level directory. */ /*! \file - * DDRIVE is the main test program for the DOUBLE linear + * DDRIVE is the main test program for the DOUBLE linear * equation driver routines DGSSV and DGSSVX. - * + * * The program is invoked by a shell script file -- dtest.csh. * The output from the tests are written into a file -- dtest.out. * @@ -78,8 +78,9 @@ int main(int argc, char *argv[]) int prefact, equil, iequed; int nt, nrun, nfail, nerrs, imat, fimat, nimat; int nfact, ifact, itran; - int kl, ku, mode, lda; - int zerot, izero, ioff; + int kl, ku, mode, lda, ioff; + int zerot; /* indicate whether the matrix is singular */ + int izero; /* incidate the first column that is entirely zero */ double u; double anorm, cndnum; double *Afull; @@ -109,6 +110,11 @@ int main(int argc, char *argv[]) extern int dgst07(trans_t, int, int, SuperMatrix *, double *, int, double *, int, double *, int, double *, double *, double *); + extern int dlatb4_slu(char *, int *, int *, int *, char *, int *, int *, + double *, int *, double *, char *); + extern int dlatms_slu(int *, int *, char *, int *, char *, double *d, + int *, double *, double *, int *, int *, + char *, double *, int *, double *, int *); extern int sp_dconvert(int, int, double *, int, int, int, double *a, int_t *, int_t *, int_t *); @@ -166,11 +172,13 @@ int main(int argc, char *argv[]) rhsb = doubleMalloc(m * nrhs); bsav = doubleMalloc(m * nrhs); solx = doubleMalloc(n * nrhs); + xact = doubleMalloc(n * nrhs); + wwork = doubleCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); + ldb = m; ldx = n; dCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_D, SLU_GE); dCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_D, SLU_GE); - xact = doubleMalloc(n * nrhs); etree = int32Malloc(n); perm_r = int32Malloc(n); perm_c = int32Malloc(n); @@ -187,7 +195,6 @@ int main(int argc, char *argv[]) if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr"); if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr"); if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork"); - wwork = doubleCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i; options.ColPerm = MY_PERMC; @@ -230,14 +237,14 @@ int main(int argc, char *argv[]) Afull[ioff + i + j*lda] = zero; } } else { - izero = 0; + izero = n+1; /* none of the column is zero */ } /* Convert to sparse representation. */ sp_dconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz); } else { - izero = 0; + izero = n+1; /* none of the column is zero */ zerot = 0; } @@ -353,12 +360,13 @@ int main(int argc, char *argv[]) printf(FMT3, "dgssv", (int) info, izero, n, nrhs, imat, nfail); } else { - /* Reconstruct matrix from factors and - compute residual. */ - dgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + dgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); nt = 1; - if ( izero == 0 ) { + if ( izero == (n+1) ) { /* Compute residual of the computed solution. */ dCopy_Dense_Matrix(m, nrhs, rhsb, ldb, @@ -417,9 +425,10 @@ int main(int argc, char *argv[]) } } else { if ( !prefact ) { - /* Reconstruct matrix from factors and - compute residual. */ - dgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + dgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); k1 = 0; } else { @@ -512,8 +521,8 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -} + return (nfail == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} /* end main */ /*! * Parse command line options to get relaxed snode size, panel size, etc. diff --git a/TESTING/sdrive.c b/TESTING/sdrive.c index c267a528..60c33e93 100644 --- a/TESTING/sdrive.c +++ b/TESTING/sdrive.c @@ -18,15 +18,14 @@ at the top-level directory. */ /*! \file - * SDRIVE is the main test program for the FLOAT linear + * SDRIVE is the main test program for the FLOAT linear * equation driver routines SGSSV and SGSSVX. - * + * * The program is invoked by a shell script file -- stest.csh. * The output from the tests are written into a file -- stest.out. * * \ingroup TestingS */ - #include #include #include "slu_sdefs.h" @@ -79,8 +78,9 @@ int main(int argc, char *argv[]) int prefact, equil, iequed; int nt, nrun, nfail, nerrs, imat, fimat, nimat; int nfact, ifact, itran; - int kl, ku, mode, lda; - int zerot, izero, ioff; + int kl, ku, mode, lda, ioff; + int zerot; /* indicate whether the matrix is singular */ + int izero; /* incidate the first column that is entirely zero */ double u; float anorm, cndnum; float *Afull; @@ -110,6 +110,11 @@ int main(int argc, char *argv[]) extern int sgst07(trans_t, int, int, SuperMatrix *, float *, int, float *, int, float *, int, float *, float *, float *); + extern int slatb4_slu(char *, int *, int *, int *, char *, int *, int *, + float *, int *, float *, char *); + extern int slatms_slu(int *, int *, char *, int *, char *, float *d, + int *, float *, float *, int *, int *, + char *, float *, int *, float *, int *); extern int sp_sconvert(int, int, float *, int, int, int, float *a, int_t *, int_t *, int_t *); @@ -167,11 +172,13 @@ int main(int argc, char *argv[]) rhsb = floatMalloc(m * nrhs); bsav = floatMalloc(m * nrhs); solx = floatMalloc(n * nrhs); + xact = floatMalloc(n * nrhs); + wwork = floatCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); + ldb = m; ldx = n; sCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_S, SLU_GE); sCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_S, SLU_GE); - xact = floatMalloc(n * nrhs); etree = int32Malloc(n); perm_r = int32Malloc(n); perm_c = int32Malloc(n); @@ -188,7 +195,6 @@ int main(int argc, char *argv[]) if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr"); if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr"); if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork"); - wwork = floatCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i; options.ColPerm = MY_PERMC; @@ -231,14 +237,14 @@ int main(int argc, char *argv[]) Afull[ioff + i + j*lda] = zero; } } else { - izero = 0; + izero = n+1; /* none of the column is zero */ } /* Convert to sparse representation. */ sp_sconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz); } else { - izero = 0; + izero = n+1; /* none of the column is zero */ zerot = 0; } @@ -354,12 +360,13 @@ int main(int argc, char *argv[]) printf(FMT3, "sgssv", (int) info, izero, n, nrhs, imat, nfail); } else { - /* Reconstruct matrix from factors and - compute residual. */ - sgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + sgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); nt = 1; - if ( izero == 0 ) { + if ( izero == (n+1) ) { /* Compute residual of the computed solution. */ sCopy_Dense_Matrix(m, nrhs, rhsb, ldb, @@ -418,9 +425,10 @@ int main(int argc, char *argv[]) } } else { if ( !prefact ) { - /* Reconstruct matrix from factors and - compute residual. */ - sgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + sgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); k1 = 0; } else { @@ -513,8 +521,8 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -} + return (nfail == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} /* end main */ /*! * Parse command line options to get relaxed snode size, panel size, etc. diff --git a/TESTING/zdrive.c b/TESTING/zdrive.c index c361004e..2ad69820 100644 --- a/TESTING/zdrive.c +++ b/TESTING/zdrive.c @@ -18,9 +18,9 @@ at the top-level directory. */ /*! \file - * ZDRIVE is the main test program for the DOUBLE COMPLEX linear + * ZDRIVE is the main test program for the DOUBLE COMPLEX linear * equation driver routines ZGSSV and ZGSSVX. - * + * * The program is invoked by a shell script file -- ztest.csh. * The output from the tests are written into a file -- ztest.out. * @@ -78,8 +78,9 @@ int main(int argc, char *argv[]) int prefact, equil, iequed; int nt, nrun, nfail, nerrs, imat, fimat, nimat; int nfact, ifact, itran; - int kl, ku, mode, lda; - int zerot, izero, ioff; + int kl, ku, mode, lda, ioff; + int zerot; /* indicate whether the matrix is singular */ + int izero; /* incidate the first column that is entirely zero */ double u; double anorm, cndnum; doublecomplex *Afull; @@ -109,6 +110,11 @@ int main(int argc, char *argv[]) extern int zgst07(trans_t, int, int, SuperMatrix *, doublecomplex *, int, doublecomplex *, int, doublecomplex *, int, double *, double *, double *); + extern int zlatb4_slu(char *, int *, int *, int *, char *, int *, int *, + double *, int *, double *, char *); + extern int zlatms_slu(int *, int *, char *, int *, char *, double *d, + int *, double *, double *, int *, int *, + char *, doublecomplex *, int *, doublecomplex *, int *); extern int sp_zconvert(int, int, doublecomplex *, int, int, int, doublecomplex *a, int_t *, int_t *, int_t *); @@ -166,11 +172,13 @@ int main(int argc, char *argv[]) rhsb = doublecomplexMalloc(m * nrhs); bsav = doublecomplexMalloc(m * nrhs); solx = doublecomplexMalloc(n * nrhs); + xact = doublecomplexMalloc(n * nrhs); + wwork = doublecomplexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); + ldb = m; ldx = n; zCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_Z, SLU_GE); zCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_Z, SLU_GE); - xact = doublecomplexMalloc(n * nrhs); etree = int32Malloc(n); perm_r = int32Malloc(n); perm_c = int32Malloc(n); @@ -187,7 +195,6 @@ int main(int argc, char *argv[]) if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr"); if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr"); if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork"); - wwork = doublecomplexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i; options.ColPerm = MY_PERMC; @@ -230,14 +237,14 @@ int main(int argc, char *argv[]) Afull[ioff + i + j*lda] = zero; } } else { - izero = 0; + izero = n+1; /* none of the column is zero */ } /* Convert to sparse representation. */ sp_zconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz); } else { - izero = 0; + izero = n+1; /* none of the column is zero */ zerot = 0; } @@ -353,12 +360,13 @@ int main(int argc, char *argv[]) printf(FMT3, "zgssv", (int) info, izero, n, nrhs, imat, nfail); } else { - /* Reconstruct matrix from factors and - compute residual. */ - zgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + zgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); nt = 1; - if ( izero == 0 ) { + if ( izero == (n+1) ) { /* Compute residual of the computed solution. */ zCopy_Dense_Matrix(m, nrhs, rhsb, ldb, @@ -417,9 +425,10 @@ int main(int argc, char *argv[]) } } else { if ( !prefact ) { - /* Reconstruct matrix from factors and - compute residual. */ - zgst01(m, n, &A, &L, &U, perm_c, perm_r, + /* Reconstruct matrix from factors and compute residual. + * Only compute the leading 'izero' nonzero columns. + */ + zgst01(m, izero-1, &A, &L, &U, perm_c, perm_r, &result[0]); k1 = 0; } else { @@ -512,8 +521,8 @@ int main(int argc, char *argv[]) Destroy_SuperMatrix_Store(&U); } - return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -} + return (nfail == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} /* end main */ /*! * Parse command line options to get relaxed snode size, panel size, etc. diff --git a/make.inc.in b/make.inc.in index c5566e9b..06340786 100644 --- a/make.inc.in +++ b/make.inc.in @@ -1,3 +1,4 @@ + ############################################################################ # # Program: SuperLU @@ -20,14 +21,15 @@ SuperLUroot = ${CMAKE_INSTALL_PREFIX} SUPERLULIB = $(SuperLUroot)/SRC/${PROJECT_NAME_LIB_EXPORT} -TMGLIB = libtmglib.a +#TMGLIB = libtmglib.a +MATGENLIB = $(SuperLUroot)/TESTING/MATGEN/libmatgen.a XSDK_INDEX_SIZE = @XSDK_INDEX_SIZE@ HAVE_METIS = @HAVE_METIS@ # BLASDEF = -DUSE_VENDOR_BLAS BLASLIB = ${BLAS_LIB_EXPORT} -LIBS = $(SUPERLULIB) ${BLAS_LIB_EXPORT} +LIBS = $(SUPERLULIB) ${BLAS_LIB_EXPORT} ${MATGENLIB} LIBS += ${METIS_LIB_EXPORT} #