From c9301a2e3385a5fc35232265245b7b636f4c9e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sun, 16 Apr 2023 15:09:37 +0200 Subject: [PATCH 1/5] [examples] slinsol gets matrix path as first argument, not stdin Add handling of arguments. This simplifies testing with CMake. --- EXAMPLE/slinsol.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/EXAMPLE/slinsol.c b/EXAMPLE/slinsol.c index 1d8808f1..c4a13538 100644 --- a/EXAMPLE/slinsol.c +++ b/EXAMPLE/slinsol.c @@ -16,11 +16,27 @@ at the top-level directory. * October 15, 2003 * */ +#include +#include +#include #include #include "slu_sdefs.h" int main(int argc, char *argv[]) { + // ensure right number of arguments are passed + if (argc != 2) { + printf("slinsol requires one additional argument, the path to the matrix file %i\n", argc); + return EXIT_FAILURE; + } + + // print out help + if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { + printf("use simple driver DGSSV to solve a linear system one time\n"); + printf("requires one additional argument, the path to the matrix file\n"); + return EXIT_SUCCESS; + } + SuperMatrix A; NCformat *Astore; float *a; @@ -38,7 +54,7 @@ int main(int argc, char *argv[]) mem_usage_t mem_usage; superlu_options_t options; SuperLUStat_t stat; - FILE *fp = stdin; + FILE *fp = fopen(argv[1], "r"); #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); From 1b6029471f5fe1e08a380698dc01a671b06d7b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sun, 16 Apr 2023 15:11:18 +0200 Subject: [PATCH 2/5] [cmake] Build first example file and add to automated testing --- CMakeLists.txt | 2 +- EXAMPLE/CMakeLists.txt | 8 ++++++++ EXAMPLE/README | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 EXAMPLE/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index e9546d56..5154bd76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ option(enable_single "Enable single precision library" ON) option(enable_double "Enable double precision library" ON) option(enable_complex "Enable complex precision library" ON) option(enable_complex16 "Enable complex16 precision library" ON) -# option(enable_examples "Build examples" ON) +option(enable_examples "Build examples" ON) #-- BLAS option(TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_blaslib_DEFAULT}) diff --git a/EXAMPLE/CMakeLists.txt b/EXAMPLE/CMakeLists.txt new file mode 100644 index 00000000..cf857b53 --- /dev/null +++ b/EXAMPLE/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${SuperLU_SOURCE_DIR}/SRC) + +add_executable(slinsol + EXCLUDE_FROM_ALL + slinsol.c) +target_link_libraries(slinsol superlu) +add_test(NAME slinsol + COMMAND slinsol "${CMAKE_CURRENT_SOURCE_DIR}/g20.rua") diff --git a/EXAMPLE/README b/EXAMPLE/README index 8330d0ef..2e1915ae 100644 --- a/EXAMPLE/README +++ b/EXAMPLE/README @@ -35,7 +35,7 @@ To run the small 5x5 sample program in Section 1 of the Users' Guide, type: % superlu To run the real version examples, type: - % dlinsol < g20.rua (or, % slinsol < g20.rua) + % dlinsol < g20.rua (or, % slinsol g20.rua) % dlinsolx < g20.rua (or, % slinsolx < g20.rua) % dlinsolx1 < g20.rua (or, % slinsolx1 < g20.rua) % dlinsolx2 < g20.rua (or, % slinsolx2 < g20.rua) From 5e027092b8235d13bb46d6906e775daa5df66225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sun, 16 Apr 2023 15:11:49 +0200 Subject: [PATCH 3/5] [cmake] Clean up some code in comments --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5154bd76..31715ba7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,11 +219,12 @@ if(enable_doc) add_subdirectory(DOC) endif() +###################################################################### +# # Generate various configure files with proper definitions +# +###################################################################### -# file(WRITE "make.defs" "# can be exposed to users" -# ${CMAKE_C_COMPILER} ) -# configure_file(${CMAKE_SOURCE_DIR}/make.inc.in ${CMAKE_SOURCE_DIR}/make.inc) configure_file(${SuperLU_SOURCE_DIR}/make.inc.in ${SuperLU_SOURCE_DIR}/make.inc) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/superlu.pc.in ${CMAKE_CURRENT_BINARY_DIR}/superlu.pc @ONLY) From c3ddb30f50433e9be8d7db1f6c9b7d8cf8bdcc44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sun, 16 Apr 2023 15:13:31 +0200 Subject: [PATCH 4/5] [example] Add Doxygen description to slinsol --- EXAMPLE/slinsol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EXAMPLE/slinsol.c b/EXAMPLE/slinsol.c index c4a13538..19fbaba4 100644 --- a/EXAMPLE/slinsol.c +++ b/EXAMPLE/slinsol.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) @@ -16,6 +16,10 @@ at the top-level directory. * October 15, 2003 * */ + +/*! \file + * Example: use simple driver DGSSV to solve a linear system one time + */ #include #include #include From cf443c7bc7aaa0d36e32e6bb548f2070461694f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sun, 16 Apr 2023 15:13:46 +0200 Subject: [PATCH 5/5] [example] Minor cleanups to slinsol --- EXAMPLE/slinsol.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/EXAMPLE/slinsol.c b/EXAMPLE/slinsol.c index 19fbaba4..449c8444 100644 --- a/EXAMPLE/slinsol.c +++ b/EXAMPLE/slinsol.c @@ -129,9 +129,10 @@ int main(int argc, char *argv[]) } } - if ( options.PrintStat ) StatPrint(&stat); - StatFree(&stat); + if (options.PrintStat) + StatPrint(&stat); + StatFree(&stat); SUPERLU_FREE (rhs); SUPERLU_FREE (xact); SUPERLU_FREE (perm_r); @@ -144,5 +145,6 @@ int main(int argc, char *argv[]) #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Exit main()"); #endif -} + return EXIT_SUCCESS; +}