From 2624582bb1cf68181c8c5212d2f248f863aca64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Mon, 9 Oct 2023 07:59:37 +0200 Subject: [PATCH 01/19] [example] Unify parse_command_line function parameter type --- EXAMPLE/clinsolx2.c | 2 +- EXAMPLE/clinsolx3.c | 2 +- EXAMPLE/slinsolx2.c | 2 +- EXAMPLE/slinsolx3.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/EXAMPLE/clinsolx2.c b/EXAMPLE/clinsolx2.c index 688e59aa..418327a4 100644 --- a/EXAMPLE/clinsolx2.c +++ b/EXAMPLE/clinsolx2.c @@ -274,7 +274,7 @@ int main(int argc, char *argv[]) */ void parse_command_line(int argc, char *argv[], int *lwork, - double *u, yes_no_t *equil, trans_t *trans ) + float *u, yes_no_t *equil, trans_t *trans ) { int c; extern char *optarg; diff --git a/EXAMPLE/clinsolx3.c b/EXAMPLE/clinsolx3.c index 315235a8..8e057bba 100644 --- a/EXAMPLE/clinsolx3.c +++ b/EXAMPLE/clinsolx3.c @@ -269,7 +269,7 @@ int main(int argc, char *argv[]) */ void parse_command_line(int argc, char *argv[], int *lwork, - double *u, yes_no_t *equil, trans_t *trans ) + float *u, yes_no_t *equil, trans_t *trans ) { int c; extern char *optarg; diff --git a/EXAMPLE/slinsolx2.c b/EXAMPLE/slinsolx2.c index 51d1ad8d..f7e557f7 100644 --- a/EXAMPLE/slinsolx2.c +++ b/EXAMPLE/slinsolx2.c @@ -274,7 +274,7 @@ int main(int argc, char *argv[]) */ void parse_command_line(int argc, char *argv[], int *lwork, - double *u, yes_no_t *equil, trans_t *trans ) + float *u, yes_no_t *equil, trans_t *trans ) { int c; extern char *optarg; diff --git a/EXAMPLE/slinsolx3.c b/EXAMPLE/slinsolx3.c index 92f7af2d..b2c95147 100644 --- a/EXAMPLE/slinsolx3.c +++ b/EXAMPLE/slinsolx3.c @@ -269,7 +269,7 @@ int main(int argc, char *argv[]) */ void parse_command_line(int argc, char *argv[], int *lwork, - double *u, yes_no_t *equil, trans_t *trans ) + float *u, yes_no_t *equil, trans_t *trans ) { int c; extern char *optarg; From 7b271d68857629b817d5a098152d89bc485a7de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Mon, 9 Oct 2023 08:01:25 +0200 Subject: [PATCH 02/19] [example] Correct function prototype for parse_command_line Clang 17 warns about the former, incorrect way. --- EXAMPLE/clinsolx.c | 5 +++-- EXAMPLE/clinsolx1.c | 5 +++-- EXAMPLE/clinsolx2.c | 5 +++-- EXAMPLE/clinsolx3.c | 5 +++-- EXAMPLE/dlinsolx.c | 5 +++-- EXAMPLE/dlinsolx1.c | 5 +++-- EXAMPLE/dlinsolx2.c | 5 +++-- EXAMPLE/dlinsolx3.c | 5 +++-- EXAMPLE/slinsolx.c | 5 +++-- EXAMPLE/slinsolx1.c | 5 +++-- EXAMPLE/slinsolx2.c | 5 +++-- EXAMPLE/slinsolx3.c | 5 +++-- EXAMPLE/zlinsolx.c | 5 +++-- EXAMPLE/zlinsolx1.c | 5 +++-- EXAMPLE/zlinsolx2.c | 5 +++-- EXAMPLE/zlinsolx3.c | 5 +++-- 16 files changed, 48 insertions(+), 32 deletions(-) diff --git a/EXAMPLE/clinsolx.c b/EXAMPLE/clinsolx.c index 2ada36cf..f5d1e0b7 100644 --- a/EXAMPLE/clinsolx.c +++ b/EXAMPLE/clinsolx.c @@ -26,6 +26,9 @@ at the top-level directory. #include #include "slu_cdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + int main(int argc, char *argv[]) { char equed[1]; @@ -56,8 +59,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/clinsolx1.c b/EXAMPLE/clinsolx1.c index 03a9d77e..48625368 100644 --- a/EXAMPLE/clinsolx1.c +++ b/EXAMPLE/clinsolx1.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_cdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + int main(int argc, char *argv[]) { /* @@ -70,8 +73,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/clinsolx2.c b/EXAMPLE/clinsolx2.c index 418327a4..a62d4656 100644 --- a/EXAMPLE/clinsolx2.c +++ b/EXAMPLE/clinsolx2.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_cdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + int main(int argc, char *argv[]) { /*! @@ -66,8 +69,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/clinsolx3.c b/EXAMPLE/clinsolx3.c index 8e057bba..51502669 100644 --- a/EXAMPLE/clinsolx3.c +++ b/EXAMPLE/clinsolx3.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_cdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program CLINSOLX2. * @@ -65,8 +68,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/dlinsolx.c b/EXAMPLE/dlinsolx.c index b6a2d097..c6e125ac 100644 --- a/EXAMPLE/dlinsolx.c +++ b/EXAMPLE/dlinsolx.c @@ -26,6 +26,9 @@ at the top-level directory. #include #include "slu_ddefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + int main(int argc, char *argv[]) { char equed[1]; @@ -56,8 +59,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/dlinsolx1.c b/EXAMPLE/dlinsolx1.c index 3f59dc25..168ec4a6 100644 --- a/EXAMPLE/dlinsolx1.c +++ b/EXAMPLE/dlinsolx1.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_ddefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program DLINSOLX1. * @@ -66,8 +69,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/dlinsolx2.c b/EXAMPLE/dlinsolx2.c index 2c833fdc..e4b3a07c 100644 --- a/EXAMPLE/dlinsolx2.c +++ b/EXAMPLE/dlinsolx2.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_ddefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program DLINSOLX2. * @@ -66,8 +69,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/dlinsolx3.c b/EXAMPLE/dlinsolx3.c index d168b7c7..64d5e0c0 100644 --- a/EXAMPLE/dlinsolx3.c +++ b/EXAMPLE/dlinsolx3.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_ddefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program DLINSOLX2. * @@ -65,8 +68,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/slinsolx.c b/EXAMPLE/slinsolx.c index 299f1a71..1f88a7a1 100644 --- a/EXAMPLE/slinsolx.c +++ b/EXAMPLE/slinsolx.c @@ -26,6 +26,9 @@ at the top-level directory. #include #include "slu_sdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + int main(int argc, char *argv[]) { char equed[1]; @@ -56,8 +59,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/slinsolx1.c b/EXAMPLE/slinsolx1.c index 312085a7..4739c228 100644 --- a/EXAMPLE/slinsolx1.c +++ b/EXAMPLE/slinsolx1.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_sdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + int main(int argc, char *argv[]) { /* @@ -70,8 +73,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/slinsolx2.c b/EXAMPLE/slinsolx2.c index f7e557f7..e7aa5045 100644 --- a/EXAMPLE/slinsolx2.c +++ b/EXAMPLE/slinsolx2.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_sdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program SLINSOLX2. * @@ -66,8 +69,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/slinsolx3.c b/EXAMPLE/slinsolx3.c index b2c95147..91461b5f 100644 --- a/EXAMPLE/slinsolx3.c +++ b/EXAMPLE/slinsolx3.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_sdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + float *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program SLINSOLX2. * @@ -65,8 +68,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/zlinsolx.c b/EXAMPLE/zlinsolx.c index 7c04ca70..949d94cd 100644 --- a/EXAMPLE/zlinsolx.c +++ b/EXAMPLE/zlinsolx.c @@ -26,6 +26,9 @@ at the top-level directory. #include #include "slu_zdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + int main(int argc, char *argv[]) { char equed[1]; @@ -56,8 +59,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/zlinsolx1.c b/EXAMPLE/zlinsolx1.c index a32f5ffd..d79500c1 100644 --- a/EXAMPLE/zlinsolx1.c +++ b/EXAMPLE/zlinsolx1.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_zdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program ZLINSOLX1. * @@ -66,8 +69,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/zlinsolx2.c b/EXAMPLE/zlinsolx2.c index a0232589..a18b2743 100644 --- a/EXAMPLE/zlinsolx2.c +++ b/EXAMPLE/zlinsolx2.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_zdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program ZLINSOLX2. * @@ -66,8 +69,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif diff --git a/EXAMPLE/zlinsolx3.c b/EXAMPLE/zlinsolx3.c index 82ead9ac..5e602c50 100644 --- a/EXAMPLE/zlinsolx3.c +++ b/EXAMPLE/zlinsolx3.c @@ -28,6 +28,9 @@ at the top-level directory. #include #include "slu_zdefs.h" +void parse_command_line(int argc, char *argv[], int *lwork, + double *u, yes_no_t *equil, trans_t *trans); + /*! * \brief The driver program ZLINSOLX2. * @@ -65,8 +68,6 @@ int main(int argc, char *argv[]) SuperLUStat_t stat; FILE *fp = stdin; - extern void parse_command_line(); - #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif From 955f58bd78a0db59e75ce6d46941e41c7df4c700 Mon Sep 17 00:00:00 2001 From: Adam Lugowski Date: Fri, 10 Nov 2023 19:31:16 -0800 Subject: [PATCH 03/19] Fix usage of uninitialized variable `value` --- SRC/clangs.c | 7 +------ SRC/dlangs.c | 7 +------ SRC/slangs.c | 7 +------ SRC/zlangs.c | 7 +------ 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/SRC/clangs.c b/SRC/clangs.c index 317a3e40..cb7e2dc2 100644 --- a/SRC/clangs.c +++ b/SRC/clangs.c @@ -75,25 +75,21 @@ float clangs(char *norm, SuperMatrix *A) NCformat *Astore; singlecomplex *Aval; int i, j, irow; - float value, sum; + float value = 0., sum; float *rwork; Astore = A->Store; Aval = Astore->nzval; if ( SUPERLU_MIN(A->nrow, A->ncol) == 0) { - value = 0.; - } else if (strncmp(norm, "M", 1)==0) { /* Find max(abs(A(i,j))). */ - value = 0.; for (j = 0; j < A->ncol; ++j) for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) value = SUPERLU_MAX( value, c_abs( &Aval[i]) ); } else if (strncmp(norm, "O", 1)==0 || *(unsigned char *)norm == '1') { /* Find norm1(A). */ - value = 0.; for (j = 0; j < A->ncol; ++j) { sum = 0.; for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) @@ -111,7 +107,6 @@ float clangs(char *norm, SuperMatrix *A) irow = Astore->rowind[i]; rwork[irow] += c_abs( &Aval[i] ); } - value = 0.; for (i = 0; i < A->nrow; ++i) value = SUPERLU_MAX(value, rwork[i]); diff --git a/SRC/dlangs.c b/SRC/dlangs.c index 013fde6a..995d8c09 100644 --- a/SRC/dlangs.c +++ b/SRC/dlangs.c @@ -75,25 +75,21 @@ double dlangs(char *norm, SuperMatrix *A) NCformat *Astore; double *Aval; int i, j, irow; - double value, sum; + double value = 0., sum; double *rwork; Astore = A->Store; Aval = Astore->nzval; if ( SUPERLU_MIN(A->nrow, A->ncol) == 0) { - value = 0.; - } else if (strncmp(norm, "M", 1)==0) { /* Find max(abs(A(i,j))). */ - value = 0.; for (j = 0; j < A->ncol; ++j) for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) value = SUPERLU_MAX( value, fabs( Aval[i]) ); } else if (strncmp(norm, "O", 1)==0 || *(unsigned char *)norm == '1') { /* Find norm1(A). */ - value = 0.; for (j = 0; j < A->ncol; ++j) { sum = 0.; for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) @@ -111,7 +107,6 @@ double dlangs(char *norm, SuperMatrix *A) irow = Astore->rowind[i]; rwork[irow] += fabs(Aval[i]); } - value = 0.; for (i = 0; i < A->nrow; ++i) value = SUPERLU_MAX(value, rwork[i]); diff --git a/SRC/slangs.c b/SRC/slangs.c index 9219082e..7d7999e2 100644 --- a/SRC/slangs.c +++ b/SRC/slangs.c @@ -75,25 +75,21 @@ float slangs(char *norm, SuperMatrix *A) NCformat *Astore; float *Aval; int i, j, irow; - float value, sum; + float value = 0., sum; float *rwork; Astore = A->Store; Aval = Astore->nzval; if ( SUPERLU_MIN(A->nrow, A->ncol) == 0) { - value = 0.; - } else if (strncmp(norm, "M", 1)==0) { /* Find max(abs(A(i,j))). */ - value = 0.; for (j = 0; j < A->ncol; ++j) for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) value = SUPERLU_MAX( value, fabs( Aval[i]) ); } else if (strncmp(norm, "O", 1)==0 || *(unsigned char *)norm == '1') { /* Find norm1(A). */ - value = 0.; for (j = 0; j < A->ncol; ++j) { sum = 0.; for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) @@ -111,7 +107,6 @@ float slangs(char *norm, SuperMatrix *A) irow = Astore->rowind[i]; rwork[irow] += fabs(Aval[i]); } - value = 0.; for (i = 0; i < A->nrow; ++i) value = SUPERLU_MAX(value, rwork[i]); diff --git a/SRC/zlangs.c b/SRC/zlangs.c index 595b9e98..7954c77b 100644 --- a/SRC/zlangs.c +++ b/SRC/zlangs.c @@ -75,25 +75,21 @@ double zlangs(char *norm, SuperMatrix *A) NCformat *Astore; doublecomplex *Aval; int i, j, irow; - double value, sum; + double value = 0., sum; double *rwork; Astore = A->Store; Aval = Astore->nzval; if ( SUPERLU_MIN(A->nrow, A->ncol) == 0) { - value = 0.; - } else if (strncmp(norm, "M", 1)==0) { /* Find max(abs(A(i,j))). */ - value = 0.; for (j = 0; j < A->ncol; ++j) for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) value = SUPERLU_MAX( value, z_abs( &Aval[i]) ); } else if (strncmp(norm, "O", 1)==0 || *(unsigned char *)norm == '1') { /* Find norm1(A). */ - value = 0.; for (j = 0; j < A->ncol; ++j) { sum = 0.; for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) @@ -111,7 +107,6 @@ double zlangs(char *norm, SuperMatrix *A) irow = Astore->rowind[i]; rwork[irow] += z_abs( &Aval[i] ); } - value = 0.; for (i = 0; i < A->nrow; ++i) value = SUPERLU_MAX(value, rwork[i]); From 57c2489c354ae90815edf5e7d57dc5739777dfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 12 Oct 2023 18:50:54 +0200 Subject: [PATCH 04/19] Adjust return type to void for functions that always return zero This changes the interface, but the expectation is that the result was never used. --- SRC/slu_util.h | 6 +++--- SRC/sp_preorder.c | 2 +- SRC/util.c | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/SRC/slu_util.h b/SRC/slu_util.h index cd4c2fa2..1afbdd0e 100644 --- a/SRC/slu_util.h +++ b/SRC/slu_util.h @@ -412,9 +412,9 @@ extern void StatInit(SuperLUStat_t *); extern void StatPrint (SuperLUStat_t *); extern void StatFree(SuperLUStat_t *); extern void print_panel_seg(int, int, int, int, int *, int *); -extern int print_int_vec(char *,int, int *); -extern int slu_PrintInt10(char *, int, int *); -extern int check_perm(char *what, int n, int *perm); +extern void print_int_vec(char *what, int n, int *vec); +extern void slu_PrintInt10(char *name, int len, int *x); +extern void check_perm(char *what, int n, int *perm); #ifdef __cplusplus } diff --git a/SRC/sp_preorder.c b/SRC/sp_preorder.c index 8da91b80..bd73f6b9 100644 --- a/SRC/sp_preorder.c +++ b/SRC/sp_preorder.c @@ -76,7 +76,7 @@ sp_preorder(superlu_options_t *options, SuperMatrix *A, int *perm_c, NCPformat *ACstore; int *iwork, *post; register int n, i; - extern int check_perm(char *what, int n, int *perm); + extern void check_perm(char *what, int n, int *perm); n = A->ncol; diff --git a/SRC/util.c b/SRC/util.c index 8da9fd1a..7bf41ed1 100644 --- a/SRC/util.c +++ b/SRC/util.c @@ -488,15 +488,14 @@ PrintSumm(char *type, int nfail, int nrun, int nerrs) } -int print_int_vec(char *what, int n, int *vec) +void print_int_vec(char *what, int n, int *vec) { int i; printf("%s\n", what); for (i = 0; i < n; ++i) printf("%d\t%d\n", i, vec[i]); - return 0; } -int slu_PrintInt10(char *name, int len, int *x) +void slu_PrintInt10(char *name, int len, int *x) { register int i; @@ -507,10 +506,9 @@ int slu_PrintInt10(char *name, int len, int *x) printf("%6d", x[i]); } printf("\n"); - return 0; } -int check_perm(char *what, int n, int *perm) +void check_perm(char *what, int n, int *perm) { register int i; int *marker; @@ -529,5 +527,4 @@ int check_perm(char *what, int n, int *perm) SUPERLU_FREE(marker); printf("check_perm: %s: n %d\n", what, n); - return 0; } From 9416dae145b9fe56eab5be20321d900404aa0522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 12 Oct 2023 18:52:33 +0200 Subject: [PATCH 05/19] [cleanup] Remove duplicate semicolon --- SRC/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SRC/util.c b/SRC/util.c index 7bf41ed1..26e32f38 100644 --- a/SRC/util.c +++ b/SRC/util.c @@ -452,7 +452,7 @@ float SpaSize(int n, int np, float sum_npw) float DenseSize(int n, float sum_nw) { - return (sum_nw*8 + n*8)/1024.;; + return (sum_nw*8 + n*8)/1024.; } From 1a1c704a41cfcd4186b39d1912938c7173dda3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 12 Oct 2023 19:29:20 +0200 Subject: [PATCH 06/19] [cmake] Don't add dmach.c and smach.c twice They are added later together with other single and double files --- SRC/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/SRC/CMakeLists.txt b/SRC/CMakeLists.txt index 34c4aa47..668ae790 100644 --- a/SRC/CMakeLists.txt +++ b/SRC/CMakeLists.txt @@ -26,8 +26,6 @@ set(sources mc64ad.c qselect.c input_error.c - dmach.c - smach.c ) set_source_files_properties(superlu_timer.c PROPERTIES COMPILE_FLAGS -O0) From e87529fd187937e43114fa2d3d15d74e24fe04c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 12 Oct 2023 19:35:38 +0200 Subject: [PATCH 07/19] Use const variable instead of local macro --- SRC/util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SRC/util.c b/SRC/util.c index 26e32f38..3358ecba 100644 --- a/SRC/util.c +++ b/SRC/util.c @@ -406,12 +406,11 @@ void ifill(int *a, int alen, int ival) /*! \brief Get the statistics of the supernodes */ -#define NBUCKS 10 - void super_stats(int nsuper, int *xsup) { register int nsup1 = 0; int i, isize, whichb, bl, bh; + const int NBUCKS = 10; int bucket[NBUCKS]; int max_sup_size = 0; From 371dcb4c0599432cbb9166adbd78c80a6a09c65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 12 Oct 2023 19:34:10 +0200 Subject: [PATCH 08/19] [doxygen] Introduce group Common and add files Provide brief purpose for every added file. Ensure that copyright statements are not part of the file description. --- DOC/modules.txt | 7 +++++++ SRC/colamd.c | 7 ++++++- SRC/get_perm_c.c | 13 +++++++------ SRC/heap_relax_snode.c | 13 +++++++------ SRC/ilu_relax_snode.c | 13 +++++++------ SRC/memory.c | 17 +++++++++-------- SRC/mmd.c | 7 ++++++- SRC/relax_snode.c | 13 +++++++------ SRC/sp_coletree.c | 13 +++++++------ SRC/sp_ienv.c | 13 +++++++------ SRC/sp_preorder.c | 8 +++++--- SRC/superlu_timer.c | 15 ++++++--------- SRC/util.c | 14 +++++++------- 13 files changed, 88 insertions(+), 65 deletions(-) diff --git a/DOC/modules.txt b/DOC/modules.txt index e955b01d..af111e50 100644 --- a/DOC/modules.txt +++ b/DOC/modules.txt @@ -2,6 +2,13 @@ \page modules Modules */ +/*! + \defgroup Common + \brief Common code shared within SuperLU. + + Type-independent code. + */ + /*! \defgroup Example \brief Examples of how to use SuperLU. diff --git a/SRC/colamd.c b/SRC/colamd.c index dceb4c1b..3e72b432 100644 --- a/SRC/colamd.c +++ b/SRC/colamd.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,6 +8,11 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ +/*! \file + * \brief Approximate minimum degree column ordering algorithm + * + * \ingroup Common + */ /* ========================================================================== */ /* === colamd/symamd - a sparse matrix column ordering algorithm ============ */ /* ========================================================================== */ diff --git a/SRC/get_perm_c.c b/SRC/get_perm_c.c index 56a29097..e8f898e9 100644 --- a/SRC/get_perm_c.c +++ b/SRC/get_perm_c.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,16 +8,17 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file get_perm_c.c - * \brief Matrix permutation operations - * - *
+/*
  * -- SuperLU routine (version 3.1) --
  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
  * and Lawrence Berkeley National Lab.
  * August 1, 2008
  * March 25, 2023  add METIS option
- * 
+ */ +/*! \file + * \brief Matrix permutation operations + * + * \ingroup Common */ #include "slu_ddefs.h" #include "colamd.h" diff --git a/SRC/heap_relax_snode.c b/SRC/heap_relax_snode.c index 54a68d26..def38d01 100644 --- a/SRC/heap_relax_snode.c +++ b/SRC/heap_relax_snode.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,10 +8,7 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file heap_relax_snode.c - * \brief Identify the initial relaxed supernodes - * - *
+/*
  * -- SuperLU routine (version 3.0) --
  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
  * and Lawrence Berkeley National Lab.
@@ -27,7 +24,11 @@ at the top-level directory.
  * Permission to modify the code and to distribute modified code is
  * granted, provided the above notices are retained, and a notice that
  * the code was modified is included with the above copyright notice.
- * 
+ */ +/*! \file + * \brief Identify the initial relaxed supernodes + * + * \ingroup Common */ #include "slu_ddefs.h" diff --git a/SRC/ilu_relax_snode.c b/SRC/ilu_relax_snode.c index 0cfd030c..0824e09e 100644 --- a/SRC/ilu_relax_snode.c +++ b/SRC/ilu_relax_snode.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,14 +8,15 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file ilu_relax_snode.c - * \brief Identify initial relaxed supernodes - * - *
+/*
  * -- SuperLU routine (version 4.0) --
  * Lawrence Berkeley National Laboratory
  * June 1, 2009
- * 
+ */ +/*! \file + * \brief Identify initial relaxed supernodes + * + * \ingroup Common */ #include "slu_ddefs.h" diff --git a/SRC/memory.c b/SRC/memory.c index fcd4134b..6d3ca8d3 100644 --- a/SRC/memory.c +++ b/SRC/memory.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,18 +8,19 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file memory.c - * \brief Precision-independent memory-related routines - * - *
+/*
  * -- SuperLU routine (version 2.0) --
  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
  * and Lawrence Berkeley National Lab.
  * November 15, 1997
- * 
*/ -/** Precision-independent memory-related routines. - (Shared by [sdcz]memory.c) **/ +/*! \file + * \brief Precision-independent memory-related routines + * + * Shared by [sdcz]memory.c) + * + * \ingroup Common + */ #include "slu_ddefs.h" diff --git a/SRC/mmd.c b/SRC/mmd.c index 25c7f22a..2fb19669 100644 --- a/SRC/mmd.c +++ b/SRC/mmd.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,6 +8,11 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ +/*! \file + * \brief Minimum degree algorithm + * + * \ingroup Common + */ #include "superlu_config.h" typedef int_t shortint; diff --git a/SRC/relax_snode.c b/SRC/relax_snode.c index 930e2b31..3054e85c 100644 --- a/SRC/relax_snode.c +++ b/SRC/relax_snode.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,10 +8,7 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file relax_snode.c - * \brief Identify initial relaxed supernodes - * - *
+/*
  * -- SuperLU routine (version 2.0) --
  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
  * and Lawrence Berkeley National Lab.
@@ -27,7 +24,11 @@ at the top-level directory.
  * Permission to modify the code and to distribute modified code is
  * granted, provided the above notices are retained, and a notice that
  * the code was modified is included with the above copyright notice.
- * 
+ */ +/*! \file + * \brief Identify initial relaxed supernodes + * + * \ingroup Common */ #include "slu_ddefs.h" diff --git a/SRC/sp_coletree.c b/SRC/sp_coletree.c index 55431b30..38b32597 100644 --- a/SRC/sp_coletree.c +++ b/SRC/sp_coletree.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,10 +8,7 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file sp_coletree.c - * \brief Tree layout and computation routines - * - *
+/*
  * -- SuperLU routine (version 3.1) --
  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
  * and Lawrence Berkeley National Lab.
@@ -27,8 +24,12 @@ at the top-level directory.
  * Permission to modify the code and to distribute modified code is
  * granted, provided the above notices are retained, and a notice that
  * the code was modified is included with the above copyright notice.
- * 
*/ +/*! \file + * \brief Tree layout and computation routines + * + * \ingroup Common + */ /* Elimination tree computation and layout routines */ diff --git a/SRC/sp_ienv.c b/SRC/sp_ienv.c index 804207c2..08edcbaa 100644 --- a/SRC/sp_ienv.c +++ b/SRC/sp_ienv.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,16 +8,17 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file SRC/sp_ienv.c - * \brief Chooses machine-dependent parameters for the local environment. - * - *
+/*
  * -- SuperLU routine (version 4.1) --
  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
  * and Lawrence Berkeley National Lab.
  * November, 2010
- * 
*/ +/*! \file + * \brief Chooses machine-dependent parameters for the local environment. + * + * \ingroup Common + */ /* * File name: sp_ienv.c diff --git a/SRC/sp_preorder.c b/SRC/sp_preorder.c index bd73f6b9..26a8df0e 100644 --- a/SRC/sp_preorder.c +++ b/SRC/sp_preorder.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,8 +8,10 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file sp_preorder.c - * \brief Permute and performs functions on columns of orginal matrix +/*! @file + * \brief Permute and performs functions on columns of original matrix + * + * \ingroup Common */ #include "slu_ddefs.h" diff --git a/SRC/superlu_timer.c b/SRC/superlu_timer.c index 1fed60d8..c03791f0 100644 --- a/SRC/superlu_timer.c +++ b/SRC/superlu_timer.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -9,18 +9,15 @@ The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file superlu_timer.c - * \brief Returns the time used +/*! \file + * \brief Timer functions to record the time used * - *
- * Purpose
- * ======= 
- * 
  * Returns the time in seconds used by the process.
  *
- * Note: the timer function call is machine dependent. Use conditional
+ * \note the timer function call is machine dependent. Use conditional
  *       compilation to choose the appropriate function.
- * 
+ * + * \ingroup Common */ #undef USE_TIMES diff --git a/SRC/util.c b/SRC/util.c index 3358ecba..436c5ec4 100644 --- a/SRC/util.c +++ b/SRC/util.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -8,10 +8,7 @@ All rights reserved. The source code is distributed under BSD license, see the file License.txt at the top-level directory. */ -/*! @file util.c - * \brief Utility functions - * - *
+/*
  * -- SuperLU routine (version 4.1) --
  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
  * and Lawrence Berkeley National Lab.
@@ -27,9 +24,12 @@ at the top-level directory.
  * Permission to modify the code and to distribute modified code is
  * granted, provided the above notices are retained, and a notice that
  * the code was modified is included with the above copyright notice.
- * 
*/ - +/*! \file + * \brief Utility functions + * + * \ingroup Common + */ #include #include "slu_ddefs.h" From fc28b9fbb1ae7407773d13b806df5500b4ff2456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 12 Oct 2023 19:36:16 +0200 Subject: [PATCH 09/19] [doxygen] Improve Doxygen comments for superlu_timer.c --- SRC/superlu_timer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SRC/superlu_timer.c b/SRC/superlu_timer.c index c03791f0..99381511 100644 --- a/SRC/superlu_timer.c +++ b/SRC/superlu_timer.c @@ -55,6 +55,8 @@ double SuperLU_timer_() #endif /*! \brief Timer function + * + * \return The time in seconds used by the process. */ double SuperLU_timer_() { @@ -80,6 +82,8 @@ double SuperLU_timer_() #include /*! \brief Timer function + * + * \return The time in seconds used by the process. */ double SuperLU_timer_(void) { @@ -91,4 +95,3 @@ double SuperLU_timer_(void) } #endif - From b58010ab8977986e024d262bc205c27545139c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Thu, 12 Oct 2023 19:38:23 +0200 Subject: [PATCH 10/19] [doxygen] Improve Doxygen comments for util.c --- SRC/util.c | 144 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 27 deletions(-) diff --git a/SRC/util.c b/SRC/util.c index 436c5ec4..3787fe32 100644 --- a/SRC/util.c +++ b/SRC/util.c @@ -34,9 +34,10 @@ at the top-level directory. #include #include "slu_ddefs.h" -/*! \brief Global statistics variale +/*! \brief Print message to error stream and exit program + * + * \param[in] mgs Message that is printed to error stream. */ - void superlu_abort_and_exit(char* msg) { fprintf(stderr, "%s", msg); @@ -44,6 +45,8 @@ void superlu_abort_and_exit(char* msg) } /*! \brief Set the default values for the options argument. + * + * \param[in,out] options Options struct that is filled with default values. */ void set_default_options(superlu_options_t *options) { @@ -60,6 +63,8 @@ void set_default_options(superlu_options_t *options) } /*! \brief Set the default values for the options argument for ILU. + * + * \param[out] options Options struct that is filled with default values. */ void ilu_set_default_options(superlu_options_t *options) { @@ -78,6 +83,8 @@ void ilu_set_default_options(superlu_options_t *options) } /*! \brief Print the options setting. + * + * \param[in] options Options struct that is printed. */ void print_options(superlu_options_t *options) { @@ -95,6 +102,8 @@ void print_options(superlu_options_t *options) } /*! \brief Print the options setting. + * + * \param[in] options Options struct that is printed. */ void print_ilu_options(superlu_options_t *options) { @@ -109,13 +118,24 @@ void print_ilu_options(superlu_options_t *options) printf("..\n"); } -/*! \brief Deallocate the structure pointing to the actual storage of the matrix. */ +/*! \brief Deallocate SuperMatrix + * + * Deallocate the structure pointing to the actual storage of the matrix. + * + * \param[in,out] A Deallocate all memory of this SuperMatrix. + */ void Destroy_SuperMatrix_Store(SuperMatrix *A) { SUPERLU_FREE ( A->Store ); } +/*! \brief Deallocate SuperMatrix of type NC + * + * Deallocate the structure pointing to the actual storage of the matrix. + * + * \param[in,out] A Deallocate all memory of this SuperMatrix of type NC. + */ void Destroy_CompCol_Matrix(SuperMatrix *A) { @@ -125,6 +145,12 @@ Destroy_CompCol_Matrix(SuperMatrix *A) SUPERLU_FREE( A->Store ); } +/*! \brief Deallocate SuperMatrix of type NR + * + * Deallocate the structure pointing to the actual storage of the matrix. + * + * \param[in,out] A Deallocate all memory of this SuperMatrix of type NR. + */ void Destroy_CompRow_Matrix(SuperMatrix *A) { @@ -134,6 +160,12 @@ Destroy_CompRow_Matrix(SuperMatrix *A) SUPERLU_FREE( A->Store ); } +/*! \brief Deallocate SuperMatrix of type SC + * + * Deallocate the structure pointing to the actual storage of the matrix. + * + * \param[in,out] A Deallocate all memory of this SuperMatrix of type SC. + */ void Destroy_SuperNode_Matrix(SuperMatrix *A) { @@ -146,7 +178,12 @@ Destroy_SuperNode_Matrix(SuperMatrix *A) SUPERLU_FREE ( A->Store ); } -/*! \brief A is of type Stype==NCP */ +/*! \brief Deallocate SuperMatrix of type NCP + * + * Deallocate the structure pointing to the actual storage of the matrix. + * + * \param[in,out] A Deallocate all memory of this SuperMatrix of type NCP. + */ void Destroy_CompCol_Permuted(SuperMatrix *A) { @@ -155,7 +192,12 @@ Destroy_CompCol_Permuted(SuperMatrix *A) SUPERLU_FREE ( A->Store ); } -/*! \brief A is of type Stype==DN */ +/*! \brief Deallocate SuperMatrix of type DN + * + * Deallocate the structure pointing to the actual storage of the matrix. + * + * \param[in,out] A Deallocate all memory of this SuperMatrix of type DN. + */ void Destroy_Dense_Matrix(SuperMatrix *A) { @@ -164,7 +206,7 @@ Destroy_Dense_Matrix(SuperMatrix *A) SUPERLU_FREE ( A->Store ); } -/*! \brief Reset repfnz[] for the current column +/*! \brief Reset repfnz[] for the current column */ void resetrep_col (const int nseg, const int *segrep, int *repfnz) @@ -177,8 +219,7 @@ resetrep_col (const int nseg, const int *segrep, int *repfnz) } } - -/*! \brief Count the total number of nonzeros in factors L and U, and in the symmetrically reduced L. +/*! \brief Count the total number of nonzeros in factors L and U, and in the symmetrically reduced L. */ void countnz(const int n, int_t *xprune, int_t *nnzL, int_t *nnzU, GlobalLU_t *Glu) @@ -256,8 +297,10 @@ ilu_countnz(const int n, int_t *nnzL, int_t *nnzU, GlobalLU_t *Glu) } } - -/*! \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. +/*! \brief Fix up the data storage lsub for L-subscripts. + * + * It removes the subscript sets for structural pruning, + * and applies permutation to the remaining subscripts. */ void fixupL(const int n, const int *perm_r, GlobalLU_t *Glu) @@ -294,7 +337,6 @@ fixupL(const int n, const int *perm_r, GlobalLU_t *Glu) xlsub[n] = nextl; } - /*! \brief Diagnostic print of segment info after panel_dfs(). */ void print_panel_seg(int n, int w, int jcol, int nseg, @@ -311,7 +353,10 @@ void print_panel_seg(int n, int w, int jcol, int nseg, } - +/*! \brief Initialize SuperLU stat + * + * \param[in,out] stat SuperLU stat that is initialized. + */ void StatInit(SuperLUStat_t *stat) { @@ -345,7 +390,12 @@ StatInit(SuperLUStat_t *stat) #endif } - +/*! \brief Display SuperLU stat + * + * Print content of SuperLU stat to output. + * + * \param[in] stat Display this SuperLU stat + */ void StatPrint(SuperLUStat_t *stat) { @@ -368,7 +418,12 @@ StatPrint(SuperLUStat_t *stat) } - +/*! \brief Deallocate SuperLU stat + * + * Deallocate the structure pointing to the actual storage of SuperLU stat. + * + * \param[in,out] stat Deallocate all memory of this SuperLU stat + */ void StatFree(SuperLUStat_t *stat) { @@ -377,24 +432,39 @@ StatFree(SuperLUStat_t *stat) SUPERLU_FREE(stat->ops); } - +/*! \brief Get operations for LU factorization + * + * Read out number of operations (ops) needed for LU factorization. + * + * \param[in] stat SuperLU stat used to read out the opts. + * + * \return Number of operations needed for LU factorization. + */ flops_t LUFactFlops(SuperLUStat_t *stat) { return (stat->ops[FACT]); } +/*! \brief Get operations for LU solve + * + * Read out number of operations (ops) needed for LU solve. + * + * \param[in] stat SuperLU stat used to read out the opts. + * + * \return Number of operations needed for LU solve. + */ flops_t LUSolveFlops(SuperLUStat_t *stat) { return (stat->ops[SOLVE]); } - - - - /*! \brief Fills an integer array with a given value. + * + * \param[in,out] a Integer array that is filled. + * \param[in] alen Length of integer array \a a. + * \param[in] ival Value to be filled in every element of \a a. */ void ifill(int *a, int alen, int ival) { @@ -402,8 +472,6 @@ void ifill(int *a, int alen, int ival) for (i = 0; i < alen; i++) a[i] = ival; } - - /*! \brief Get the statistics of the supernodes */ void super_stats(int nsuper, int *xsup) @@ -443,7 +511,6 @@ void super_stats(int nsuper, int *xsup) } - float SpaSize(int n, int np, float sum_npw) { return (sum_npw*8 + np*8 + n*4)/1024.; @@ -454,8 +521,6 @@ float DenseSize(int n, float sum_nw) return (sum_nw*8 + n*8)/1024.; } - - /*! \brief Check whether repfnz[] == EMPTY after reset. */ void check_repfnz(int n, int w, int jcol, int *repfnz) @@ -471,8 +536,13 @@ void check_repfnz(int n, int w, int jcol, int *repfnz) } } - -/*! \brief Print a summary of the testing results. */ +/*! \brief Print a summary of the testing results. + * + * \param[in] type Array with three chars indicating the type for that the tests were run like "CGE" or "DGE". + * \param[in] nfail Number of failed tests. + * \param[in] nrun Number of tests run. + * \param[in] nerrs Number of error messages recorded. + */ void PrintSumm(char *type, int nfail, int nrun, int nerrs) { @@ -486,7 +556,12 @@ PrintSumm(char *type, int nfail, int nrun, int nerrs) printf("%6d error messages recorded\n", nerrs); } - +/*! \brief Print content of int array + * + * \param[in] what Vector name that is printed first. + * \param[in] n Number of elements in array. + * \param[in] vec Array of ints to be printed + */ void print_int_vec(char *what, int n, int *vec) { int i; @@ -494,6 +569,15 @@ void print_int_vec(char *what, int n, int *vec) for (i = 0; i < n; ++i) printf("%d\t%d\n", i, vec[i]); } +/*! \brief Print content of int array with index numbers after every tenth row + * + * Print all elements of an int array. After ten rows the index is printed to + * make it more readable for humans. + * + * \param[in] name Vector name that is printed first. + * \param[in] len Number of elements in array. + * \param[in] x Array of ints to be printed. + */ void slu_PrintInt10(char *name, int len, int *x) { register int i; @@ -507,6 +591,12 @@ void slu_PrintInt10(char *name, int len, int *x) printf("\n"); } +/*! \brief Validity check of a permutation + * + * \param[in] what String to be printed as part of displayed text for success or error. + * \param[in] n Number of elements in permutation \a perm. + * \param[in] perm Array describing the permutation. + */ void check_perm(char *what, int n, int *perm) { register int i; From 1a9b3935e2cd82f17cce0546325a79128846582c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Wed, 18 Oct 2023 23:09:33 +0200 Subject: [PATCH 11/19] [doxygen] Improve Doxygen comments for get_perm_c.c --- SRC/get_perm_c.c | 153 ++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 82 deletions(-) diff --git a/SRC/get_perm_c.c b/SRC/get_perm_c.c index e8f898e9..1438687e 100644 --- a/SRC/get_perm_c.c +++ b/SRC/get_perm_c.c @@ -29,15 +29,18 @@ extern int genmmd_(int *neqns, int_t *xadj, int_t *adjncy, int_t *qsize, int_t *llist, int_t *marker, int_t *maxint, int_t *nofsub); -void -get_colamd( - const int m, /* number of rows in matrix A. */ - const int n, /* number of columns in matrix A. */ - const int_t nnz,/* number of nonzeros in matrix A. */ - int_t *colptr, /* column pointer of size n+1 for matrix A. */ - int_t *rowind, /* row indices of size nz for matrix A. */ - int *perm_c /* out - the column permutation vector. */ - ) +/*! + * \brief Get COLAMD's permutation for matrix A + * + * \param[in] m Number of rows in matrix A. + * \param[in] n Number of columns in matrix A. + * \param[in] nnz Number of nonzeros in matrix A. + * \param[in] colptr Column pointer of size n+1 for matrix A. + * \param[in] rowind Row indices of size nnz for matrix A. + * \param[out] perm_c Column permutation vector. + */ +void get_colamd(const int m, const int n, const int_t nnz, + int_t *colptr, int_t *rowind, int *perm_c) { size_t Alen; int_t *A, i, *p; @@ -63,16 +66,19 @@ get_colamd( SUPERLU_FREE(A); SUPERLU_FREE(p); -} /* end get_colamd */ +} -void -get_metis( - int n, /* dimension of matrix B */ - int_t bnz, /* number of nonzeros in matrix A. */ - int_t *b_colptr, /* column pointer of size n+1 for matrix B. */ - int_t *b_rowind, /* row indices of size bnz for matrix B. */ - int *perm_c /* out - the column permutation vector. */ - ) +/*! + * \brief Get METIS' permutation for matrix B + * + * \param[in] n Number of columns in matrix B. + * \param[in] bnz Number of nonzeros in matrix B. + * \param[in] b_colptr Column pointer of size n+1 for matrix B. + * \param[in] b_rowind Row indices of size bnz for matrix B. + * \param[out] perm_c Column permutation vector. + */ +void get_metis(int n, int_t bnz, int_t *b_colptr, + int_t *b_rowind, int *perm_c) { #ifdef HAVE_METIS /*#define METISOPTIONS 8*/ @@ -118,13 +124,10 @@ get_metis( #endif /* HAVE_METIS */ } -/*! \brief +/*! + * \brief Form the structure of A'*A. * - *
- * Purpose
- * =======
- *
- * Form the structure of A'*A. A is an m-by-n matrix in column oriented
+ * A is an m-by-n matrix in column oriented
  * format represented by (colptr, rowind). The output A'*A is in column
  * oriented format (symmetrically, also row oriented), represented by
  * (ata_colptr, ata_rowind).
@@ -133,24 +136,23 @@ get_metis(
  * The complexity of this algorithm is: SUM_{i=1,m} r(i)^2,
  * i.e., the sum of the square of the row counts.
  *
- * Questions
- * =========
- *     o  Do I need to withhold the *dense* rows?
- *     o  How do I know the number of nonzeros in A'*A?
- * 
+ * Questions
+ *
    + *
  • Do I need to withhold the *dense* rows? + *
  • How do I know the number of nonzeros in A'*A? + *
+ * + * \param[in] m number of rows in matrix A. + * \param[in] n number of columns in matrix A. + * \param[in] nz number of nonzeros in matrix A + * \param[in] colptr column pointer of size n+1 for matrix A. + * \param[in] rowind row indices of size nz for matrix A. + * \param[out] atanz on exit, returns the actual number of nonzeros in matrix A'*A. + * \param[out] ata_colptr column pointer of size n+1 for matrix A'*A. + * \param[out] ata_rowind row indices of size atanz for matrix A'*A. */ -void -getata( - const int m, /* number of rows in matrix A. */ - const int n, /* number of columns in matrix A. */ - const int_t nz, /* number of nonzeros in matrix A */ - int_t *colptr, /* column pointer of size n+1 for matrix A. */ - int_t *rowind, /* row indices of size nz for matrix A. */ - int_t *atanz, /* out - on exit, returns the actual number of - nonzeros in matrix A'*A. */ - int_t **ata_colptr, /* out - size n+1 */ - int_t **ata_rowind /* out - size *atanz */ - ) +void getata(const int m, const int n, const int_t nz, int_t *colptr, int_t *rowind, + int_t *atanz, int_t **ata_colptr, int_t **ata_rowind) { register int_t i, j, k, col, num_nz, ti, trow; int_t *marker, *b_colptr, *b_rowind; @@ -259,32 +261,27 @@ getata( SUPERLU_FREE(marker); SUPERLU_FREE(t_colptr); SUPERLU_FREE(t_rowind); -} /* end getata */ +} -/*! \brief - * - *
- * Purpose
- * =======
+/*!
+ * \brief Form the structure of A'+A.
  *
- * Form the structure of A'+A. A is an n-by-n matrix in column oriented
+ * A is an n-by-n matrix in column oriented
  * format represented by (colptr, rowind). The output A'+A is in column
  * oriented format (symmetrically, also row oriented), represented by
  * (b_colptr, b_rowind).
- * 
+ * + * \param[in] n number of columns in matrix A. + * \param[in] nz number of nonzeros in matrix A + * \param[in] colptr column pointer of size n+1 for matrix A. + * \param[in] rowind row indices of size nz for matrix A. + * \param[out] bnz on exit, returns the actual number of nonzeros in matrix A'*A. + * \param[out] b_colptr column pointer of size n+1 for matrix A'+A. + * \param[out] b_rowind row indices of size bnz for matrix A'+A. */ -void -at_plus_a( - const int n, /* number of columns in matrix A. */ - const int_t nz, /* number of nonzeros in matrix A */ - int_t *colptr, /* column pointer of size n+1 for matrix A. */ - int_t *rowind, /* row indices of size nz for matrix A. */ - int_t *bnz, /* out - on exit, returns the actual number of - nonzeros in matrix A'*A. */ - int_t **b_colptr, /* out - size n+1 */ - int_t **b_rowind /* out - size *bnz */ - ) +void at_plus_a(const int n, const int_t nz, int_t *colptr, int_t *rowind, + int_t *bnz, int_t **b_colptr, int_t **b_rowind) { register int_t i, j, k, col, num_nz; int_t *t_colptr, *t_rowind; /* a column oriented form of T = A' */ @@ -398,41 +395,33 @@ at_plus_a( SUPERLU_FREE(marker); SUPERLU_FREE(t_colptr); SUPERLU_FREE(t_rowind); -} /* end at_plus_a */ +} -/*! \brief - * - *
- * Purpose
- * =======
+/*!
+ * \brief Obtains a permutation matrix by applying the multiple
+ * minimum degree ordering code
  *
- * GET_PERM_C obtains a permutation matrix Pc, by applying the multiple
- * minimum degree ordering code by Joseph Liu to matrix A'*A or A+A'.
+ * Obtains a permutation matrix Pc by applying the multiple
+ * minimum degree ordering code by Joseph Liu to matrix A'*A or A+A'
  * or using approximate minimum degree column ordering by Davis et. al.
  * The LU factorization of A*Pc tends to have less fill than the LU 
  * factorization of A.
  *
- * Arguments
- * =========
- *
- * ispec   (input) int
- *         Specifies the type of column ordering to reduce fill:
- *         = 1: minimum degree on the structure of A^T * A
- *         = 2: minimum degree on the structure of A^T + A
- *         = 3: approximate minimum degree for unsymmetric matrices
+ * \param[in] ispec
+ *         Specifies the type of column ordering to reduce fill:
+ * = 1: minimum degree on the structure of A^T * A
+ * = 2: minimum degree on the structure of A^T + A
+ * = 3: approximate minimum degree for unsymmetric matrices
* If ispec == 0, the natural ordering (i.e., Pc = I) is returned. - * - * A (input) SuperMatrix* + * \param[in] A * Matrix A in A*X=B, of dimension (A->nrow, A->ncol). The number * of the linear equations is A->nrow. Currently, the type of A * can be: Stype = NC; Dtype = _D; Mtype = GE. In the future, * more general A can be handled. - * - * perm_c (output) int* - * Column permutation vector of size A->ncol, which defines the + * \param[out] perm_c + * Column permutation vector of size A->ncol, which defines the * permutation matrix Pc; perm_c[i] = j means column i of A is * in position j in A*Pc. - *
*/ void get_perm_c(int ispec, SuperMatrix *A, int *perm_c) From 8ea96c3ff574d189c8cf4151b75e5eca5e9704db Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 8 Aug 2023 12:18:12 +0200 Subject: [PATCH 12/19] Replace tab stops by spaces in TESTING/CMakeLists.txt --- TESTING/CMakeLists.txt | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 82c8e46c..66decf60 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -31,14 +31,14 @@ function(add_superlu_test output input target) foreach (s ${NRHS}) foreach(l ${LWORK}) set(testName "${target}_${n}_${s}_${l}") - set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out) + set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out) add_test( ${testName}_LA "${CMAKE_COMMAND}" - -DTEST=${TEST_LOC} -t "LA" -n ${n} -s ${s} -l ${l} - -DOUTPUT=${SINGLE_OUTPUT} - -DALL_OUTPUT=${TEST_OUTPUT} - -DHEADING=Dense\ matrix\ --\ n=${n},\ s=${s},\ lwork=${l} - -P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake" - ) + -DTEST=${TEST_LOC} -t "LA" -n ${n} -s ${s} -l ${l} + -DOUTPUT=${SINGLE_OUTPUT} + -DALL_OUTPUT=${TEST_OUTPUT} + -DHEADING=Dense\ matrix\ --\ n=${n},\ s=${s},\ lwork=${l} + -P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake" + ) endforeach() endforeach() endforeach() @@ -46,16 +46,16 @@ function(add_superlu_test output input target) # file(APPEND ${TEST_OUTPUT} "== sparse matrix\n") foreach (s ${NRHS}) - foreach(l ${LWORK}) - set(testName "${target}_${s}_${l}") - set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out) - add_test( ${testName}_SP "${CMAKE_COMMAND}" - -DTEST=${TEST_LOC} -t "SP" -s ${s} -l ${l} -f ${TEST_INPUT} - -DOUTPUT=${SINGLE_OUTPUT} - -DALL_OUTPUT=${TEST_OUTPUT} - -DHEADING=Sparse\ matrix\ ${TEST_INPUT}\ --\ s=${s},\ lwork=${l} - -P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake") - endforeach() + foreach(l ${LWORK}) + set(testName "${target}_${s}_${l}") + set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out) + add_test( ${testName}_SP "${CMAKE_COMMAND}" + -DTEST=${TEST_LOC} -t "SP" -s ${s} -l ${l} -f ${TEST_INPUT} + -DOUTPUT=${SINGLE_OUTPUT} + -DALL_OUTPUT=${TEST_OUTPUT} + -DHEADING=Sparse\ matrix\ ${TEST_INPUT}\ --\ s=${s},\ lwork=${l} + -P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake") + endforeach() endforeach() endfunction(add_superlu_test) From 497cb412bacb21aec8e35c4a0250b9142cc8e6d4 Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 8 Aug 2023 12:18:12 +0200 Subject: [PATCH 13/19] Remove variable ALINTST from TESTING The variable only containts a single C file, it does not simplify the code, but make it more complicated without any benefit. --- TESTING/CMakeLists.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 66decf60..fa7398fa 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -5,7 +5,6 @@ set(test_link_libs matgen) add_subdirectory(MATGEN) -set(ALINTST sp_ienv.c) set(NVAL 9 19) set(NRHS 2) set(LWORK 0 10000000) @@ -62,9 +61,9 @@ endfunction(add_superlu_test) if(enable_single) - set(SLINTST sdrive.c sp_sconvert.c sgst01.c sgst02.c sgst04.c sgst07.c) + set(SLINTST sdrive.c sp_ienv.c sp_sconvert.c sgst01.c sgst02.c sgst04.c sgst07.c) - add_executable(s_test ${ALINTST} ${SLINTST}) + add_executable(s_test ${SLINTST}) target_link_libraries(s_test ${test_link_libs}) if(MSVC) @@ -78,9 +77,9 @@ endif() if(enable_double) - set(DLINTST ddrive.c sp_dconvert.c dgst01.c dgst02.c dgst04.c dgst07.c) + set(DLINTST ddrive.c sp_ienv.c sp_dconvert.c dgst01.c dgst02.c dgst04.c dgst07.c) - add_executable(d_test ${ALINTST} ${DLINTST}) + add_executable(d_test ${DLINTST}) target_link_libraries(d_test ${test_link_libs}) if(MSVC) @@ -92,9 +91,9 @@ if(enable_double) endif() if(enable_complex) - set(CLINTST cdrive.c sp_cconvert.c cgst01.c cgst02.c cgst04.c cgst07.c) + set(CLINTST cdrive.c sp_ienv.c sp_cconvert.c cgst01.c cgst02.c cgst04.c cgst07.c) - add_executable(c_test ${ALINTST} ${CLINTST}) + add_executable(c_test ${CLINTST}) target_link_libraries(c_test ${test_link_libs}) if(MSVC) @@ -107,9 +106,9 @@ endif() if(enable_complex16) - set(ZLINTST zdrive.c sp_zconvert.c zgst01.c zgst02.c zgst04.c zgst07.c) + set(ZLINTST zdrive.c sp_ienv.c sp_zconvert.c zgst01.c zgst02.c zgst04.c zgst07.c) - add_executable(z_test ${ALINTST} ${ZLINTST}) + add_executable(z_test ${ZLINTST}) target_link_libraries(z_test ${test_link_libs}) if(MSVC) From 44548be464c1d1f5b213d338173761f0efad7214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sat, 12 Aug 2023 22:21:39 +0200 Subject: [PATCH 14/19] Add source files to tests directly without variable The varialbes (C|D|S|Z)LINTST only added an indirectection without any benefit. --- TESTING/CMakeLists.txt | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index fa7398fa..55643c69 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -61,9 +61,9 @@ endfunction(add_superlu_test) if(enable_single) - set(SLINTST sdrive.c sp_ienv.c sp_sconvert.c sgst01.c sgst02.c sgst04.c sgst07.c) - - add_executable(s_test ${SLINTST}) + add_executable(s_test + sdrive.c sgst01.c sgst02.c sgst04.c sgst07.c + sp_ienv.c sp_sconvert.c) target_link_libraries(s_test ${test_link_libs}) if(MSVC) @@ -72,14 +72,13 @@ if(enable_single) endif() add_superlu_test(s_test.out g20.rua s_test) - endif() if(enable_double) - set(DLINTST ddrive.c sp_ienv.c sp_dconvert.c dgst01.c dgst02.c dgst04.c dgst07.c) - - add_executable(d_test ${DLINTST}) + add_executable(d_test + ddrive.c dgst01.c dgst02.c dgst04.c dgst07.c + sp_ienv.c sp_dconvert.c) target_link_libraries(d_test ${test_link_libs}) if(MSVC) @@ -91,9 +90,9 @@ if(enable_double) endif() if(enable_complex) - set(CLINTST cdrive.c sp_ienv.c sp_cconvert.c cgst01.c cgst02.c cgst04.c cgst07.c) - - add_executable(c_test ${CLINTST}) + add_executable(c_test + cdrive.c cgst01.c cgst02.c cgst04.c cgst07.c + sp_ienv.c sp_cconvert.c) target_link_libraries(c_test ${test_link_libs}) if(MSVC) @@ -106,9 +105,9 @@ endif() if(enable_complex16) - set(ZLINTST zdrive.c sp_ienv.c sp_zconvert.c zgst01.c zgst02.c zgst04.c zgst07.c) - - add_executable(z_test ${ZLINTST}) + add_executable(z_test + zdrive.c zgst01.c zgst02.c zgst04.c zgst07.c + sp_ienv.c sp_zconvert.c) target_link_libraries(z_test ${test_link_libs}) if(MSVC) From 54803a7276526a3a1825e10e6f84e49b9787c559 Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 8 Aug 2023 12:18:12 +0200 Subject: [PATCH 15/19] Remove unused function cat from TESTING/CMakeLists.txt --- TESTING/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 55643c69..57782357 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -9,12 +9,6 @@ set(NVAL 9 19) set(NRHS 2) set(LWORK 0 10000000) -function(cat IN_FILE OUT_FILE) - file(READ ${IN_FILE} CONTENTS) - file(APPEND ${OUT_FILE} "${CONTENTS}") -endfunction() - - function(add_superlu_test output input target) set(TEST_INPUT "${SuperLU_SOURCE_DIR}/EXAMPLE/${input}") set(TEST_OUTPUT "${SuperLU_BINARY_DIR}/TESTING/${output}") From c2775ebff82ed148476b746ec12af06aa3212d4b Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 8 Aug 2023 12:18:12 +0200 Subject: [PATCH 16/19] Simplify add_superlu_test Drop handling of output, ctest offers everything needed, everything else should not be part of tests. Remove runtest.cmake, as it is no longer needed. --- TESTING/CMakeLists.txt | 53 +++++++++++++----------------------------- TESTING/runtest.cmake | 9 ------- 2 files changed, 16 insertions(+), 46 deletions(-) delete mode 100644 TESTING/runtest.cmake diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 57782357..2d2d6c69 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -11,43 +11,22 @@ set(LWORK 0 10000000) function(add_superlu_test output input target) set(TEST_INPUT "${SuperLU_SOURCE_DIR}/EXAMPLE/${input}") - set(TEST_OUTPUT "${SuperLU_BINARY_DIR}/TESTING/${output}") - - # Prepare a temporary file to "cat" to: - # "== LAPACK test matrices" - file(WRITE ${TEST_OUTPUT} "") - -## get_target_property(TEST_LOC ${target} LOCATION) - set(TEST_LOC ${CMAKE_CURRENT_BINARY_DIR}) - - foreach (n ${NVAL}) - foreach (s ${NRHS}) - foreach(l ${LWORK}) - set(testName "${target}_${n}_${s}_${l}") - set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out) - add_test( ${testName}_LA "${CMAKE_COMMAND}" - -DTEST=${TEST_LOC} -t "LA" -n ${n} -s ${s} -l ${l} - -DOUTPUT=${SINGLE_OUTPUT} - -DALL_OUTPUT=${TEST_OUTPUT} - -DHEADING=Dense\ matrix\ --\ n=${n},\ s=${s},\ lwork=${l} - -P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake" - ) - endforeach() - endforeach() - endforeach() - -# file(APPEND ${TEST_OUTPUT} "== sparse matrix\n") foreach (s ${NRHS}) foreach(l ${LWORK}) + # LA tests + foreach (n ${NVAL}) + set(testName "${target}_${n}_${s}_${l}") + add_test( + NAME ${testName}_LA + COMMAND ${target} -t "LA" -n ${n} -s ${s} -l ${l}) + endforeach() + + # SP tests set(testName "${target}_${s}_${l}") - set(SINGLE_OUTPUT ${SuperLU_BINARY_DIR}/TESTING/${testName}.out) - add_test( ${testName}_SP "${CMAKE_COMMAND}" - -DTEST=${TEST_LOC} -t "SP" -s ${s} -l ${l} -f ${TEST_INPUT} - -DOUTPUT=${SINGLE_OUTPUT} - -DALL_OUTPUT=${TEST_OUTPUT} - -DHEADING=Sparse\ matrix\ ${TEST_INPUT}\ --\ s=${s},\ lwork=${l} - -P "${SuperLU_SOURCE_DIR}/TESTING/runtest.cmake") + add_test( + NAME ${testName}_SP + COMMAND ${target} -t "SP" -s ${s} -l ${l} -f "${TEST_INPUT}") endforeach() endforeach() @@ -65,7 +44,7 @@ if(enable_single) target_link_libraries(s_test ${WinGetOpt_LIBRARY}) endif() - add_superlu_test(s_test.out g20.rua s_test) + add_superlu_test(s_test g20.rua) endif() @@ -80,7 +59,7 @@ if(enable_double) target_link_libraries(d_test ${WinGetOpt_LIBRARY}) endif() - add_superlu_test(d_test.out g20.rua d_test) + add_superlu_test(d_test g20.rua) endif() if(enable_complex) @@ -94,7 +73,7 @@ if(enable_complex) target_link_libraries(c_test ${WinGetOpt_LIBRARY}) endif() - add_superlu_test(c_test.out cg20.cua c_test) + add_superlu_test(c_test cg20.cua) endif() @@ -109,5 +88,5 @@ if(enable_complex16) target_link_libraries(z_test ${WinGetOpt_LIBRARY}) endif() - add_superlu_test(z_test.out cg20.cua z_test) + add_superlu_test(z_test cg20.cua) endif() diff --git a/TESTING/runtest.cmake b/TESTING/runtest.cmake deleted file mode 100644 index 1ab16a2f..00000000 --- a/TESTING/runtest.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# execute the test command that was added earlier. -execute_process( COMMAND "${TEST}" - OUTPUT_FILE "${OUTPUT}" - RESULT_VARIABLE RET ) -file(APPEND ${ALL_OUTPUT} ${HEADING}) -file(APPEND ${ALL_OUTPUT} "\n") -file(READ "${OUTPUT}" SINGLE_OUTPUT) -file(APPEND ${ALL_OUTPUT} "${SINGLE_OUTPUT}\n") -file(REMOVE ${OUTPUT}) # remove the individual output file. From 38deb3fa3b0af801e6066fda180708fe96c47078 Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 8 Aug 2023 12:18:12 +0200 Subject: [PATCH 17/19] Move getopt dependency for MSVC compiler into test setup --- TESTING/CMakeLists.txt | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 2d2d6c69..9e9106e9 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -30,6 +30,12 @@ function(add_superlu_test output input target) endforeach() endforeach() + # Add getopt dependency to target in case of MSVC + if(MSVC) + target_include_directories(${target} PRIVATE ${WinGetOpt_INCLUDE_DIR}) + target_link_libraries(${target} ${WinGetOpt_LIBRARY}) + endif() + endfunction(add_superlu_test) @@ -38,12 +44,6 @@ if(enable_single) sdrive.c sgst01.c sgst02.c sgst04.c sgst07.c sp_ienv.c sp_sconvert.c) target_link_libraries(s_test ${test_link_libs}) - - if(MSVC) - target_include_directories(s_test PRIVATE ${WinGetOpt_INCLUDE_DIR}) - target_link_libraries(s_test ${WinGetOpt_LIBRARY}) - endif() - add_superlu_test(s_test g20.rua) endif() @@ -53,12 +53,6 @@ if(enable_double) ddrive.c dgst01.c dgst02.c dgst04.c dgst07.c sp_ienv.c sp_dconvert.c) target_link_libraries(d_test ${test_link_libs}) - - if(MSVC) - target_include_directories(d_test PRIVATE ${WinGetOpt_INCLUDE_DIR}) - target_link_libraries(d_test ${WinGetOpt_LIBRARY}) - endif() - add_superlu_test(d_test g20.rua) endif() @@ -67,12 +61,6 @@ if(enable_complex) cdrive.c cgst01.c cgst02.c cgst04.c cgst07.c sp_ienv.c sp_cconvert.c) target_link_libraries(c_test ${test_link_libs}) - - if(MSVC) - target_include_directories(c_test PRIVATE ${WinGetOpt_INCLUDE_DIR}) - target_link_libraries(c_test ${WinGetOpt_LIBRARY}) - endif() - add_superlu_test(c_test cg20.cua) endif() @@ -82,11 +70,5 @@ if(enable_complex16) zdrive.c zgst01.c zgst02.c zgst04.c zgst07.c sp_ienv.c sp_zconvert.c) target_link_libraries(z_test ${test_link_libs}) - - if(MSVC) - target_include_directories(z_test PRIVATE ${WinGetOpt_INCLUDE_DIR}) - target_link_libraries(z_test ${WinGetOpt_LIBRARY}) - endif() - add_superlu_test(z_test cg20.cua) endif() From 3e344c65e3a90c8e1d0fc448935a4e1d1c51173b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sat, 12 Aug 2023 23:30:03 +0200 Subject: [PATCH 18/19] [readme] Remove description of output files for tests At least when using CMake this is gone. --- README | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README b/README index 720c1109..9011d8df 100644 --- a/README +++ b/README @@ -79,15 +79,9 @@ are described below. To install the library, type: make install - To run the installation test, type: + To run the regression tests, type: make test (or: ctest) - The test results are in the files below: - build/TESTING/s_test.out # single precision, real - build/TESTING/d_test.out # double precision, real - build/TESTING/c_test.out # single precision, complex - build/TESTING/z_test.out # double precision, complex - 2. Manual installation with makefile. Before installing the package, please examine the three things dependent From 92b94b92cc789e3053f5dcfdc5db7c6c4bbad946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Tue, 21 Nov 2023 21:49:57 +0100 Subject: [PATCH 19/19] [cmake] fix arguments for add_superlu_test Fixes #129 --- TESTING/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index 9e9106e9..3658e5c4 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -9,7 +9,7 @@ set(NVAL 9 19) set(NRHS 2) set(LWORK 0 10000000) -function(add_superlu_test output input target) +function(add_superlu_test target input) set(TEST_INPUT "${SuperLU_SOURCE_DIR}/EXAMPLE/${input}") foreach (s ${NRHS})