Skip to content

Commit c6dfbd4

Browse files
committed
Complete CMake support for EXAMPLE/ and TESTING/
1 parent 3d80521 commit c6dfbd4

File tree

8 files changed

+445
-21
lines changed

8 files changed

+445
-21
lines changed

CMakeLists.txt

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,97 @@
11
cmake_minimum_required (VERSION 3.13)
22

3-
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
3+
# Project Version
4+
project(SuperLU_MT C)
5+
set(VERSION_MAJOR "4")
6+
set(VERSION_MINOR "0")
7+
set(VERSION_BugFix "0")
8+
set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BugFix})
9+
10+
# Compatiblitly to xSDK standard
11+
# (Extreme-scale Scientific Software Development Kit)
12+
set(USE_XSDK_DEFAULTS TRUE)
413

5-
project (superlu_mt C)
14+
# The XSDK standard does not allow using internally built BLAS
15+
if (NOT "${enable_internal_blaslib}" STREQUAL "")
16+
if (USE_XSDK_DEFAULTS)
17+
set(enable_blaslib_xSDK OFF)
18+
else()
19+
set(enable_blaslib_xSDK ON)
20+
endif()
21+
else()
22+
set(enable_blaslib_xSDK ${enable_internal_blaslib})
23+
endif()
624

25+
if (NOT "${enable_fortran}" STREQUAL "")
26+
if (XSDK_ENABLE_Fortran)
27+
set(enable_fortran_xSDK ON)
28+
else()
29+
set(enable_fortran_xSDK OFF)
30+
endif()
31+
else()
32+
set(enable_fortran_xSDK ${enable_fortran})
33+
endif()
34+
35+
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
36+
37+
# set up options
38+
option(enable_internal_blaslib "Build the CBLAS library" ${enable_blaslib_xSDK})
39+
option(enable_single "Enable single precision library" ON)
40+
option(enable_double "Enable double precision library" ON)
41+
option(enable_complex "Enable complex precision library" ON)
42+
option(enable_complex16 "Enable complex16 precision library" ON)
43+
option(enable_matlabmex "Build the Matlab mex library" OFF)
44+
option(enable_doc "Add target 'doc' to build Doxygen documentation" OFF)
45+
option(enable_examples "Build examples" ON)
46+
option(enable_fortran "Build Fortran interface" ${enable_fortran_xSDK})
47+
option(enable_tests "Build tests" ON)
748
option (BUILD_SHARED_LIBS "shared/static" OFF)
849

950
include (GNUInstallDirs)
1051
include (CheckLibraryExists)
1152
check_library_exists(m sin "" HAVE_LIB_M)
1253

13-
find_package (BLAS REQUIRED)
54+
######################################################################
55+
#
56+
# Find packages
57+
#
58+
######################################################################
59+
#
60+
###find_package (BLAS REQUIRED)
61+
#-- BLAS
62+
option(TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_internal_blaslib})
63+
option(TPL_BLAS_LIBRARIES "List of absolute paths to blas libraries [].")
64+
65+
if(NOT enable_internal_blaslib)
66+
if (TPL_BLAS_LIBRARIES)
67+
set(BLAS_FOUND TRUE)
68+
else()
69+
find_package(BLAS)
70+
if (BLAS_FOUND)
71+
set(TPL_BLAS_LIBRARIES "${BLAS_LIBRARIES}" CACHE FILEPATH
72+
"Set from FindBLAS.cmake BLAS_LIBRARIES." FORCE)
73+
endif()
74+
endif()
75+
endif()
76+
77+
if(BLAS_FOUND)
78+
message("-- Using TPL_BLAS_LIBRARIES='${TPL_BLAS_LIBRARIES}'")
79+
set(CMAKE_C_FLAGS "-DUSE_VENDOR_BLAS ${CMAKE_C_FLAGS}")
80+
set(BLAS_LIB ${TPL_BLAS_LIBRARIES})
81+
# fix up BLAS library name
82+
string (REPLACE ";" " " BLAS_LIB_STR "${BLAS_LIB}")
83+
set(BLAS_LIB_EXPORT ${BLAS_LIB_STR})
84+
else()
85+
message("-- Did not find or specify BLAS so configure to build internal CBLAS ...")
86+
add_subdirectory(CBLAS)
87+
set(BLAS_LIB blas)
88+
if (BUILD_SHARED_LIBS) # export to be referenced by downstream makefile
89+
set(BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX}/CBLAS/libblas.so)
90+
else()
91+
set(BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX}/CBLAS/libblas.a)
92+
endif()
93+
endif()
94+
1495

1596
set (PLAT "_PTHREAD" CACHE STRING "threading flavor _PTHREAD/_OPENMP")
1697
if (PLAT STREQUAL "_PTHREAD")
@@ -21,6 +102,24 @@ else ()
21102
message (SEND_ERROR "invalid PLAT setting")
22103
endif ()
23104

105+
106+
enable_language(C)
107+
if (enable_fortran)
108+
enable_language(Fortran)
109+
endif()
110+
set(SUPERLU_MT_VERSION "${PROJECT_VERSION}")
111+
112+
24113
set (SUPERLUMT_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/superlu_mt CACHE STRING "include dir")
25114

26-
add_subdirectory (SRC)
115+
add_subdirectory(SRC)
116+
add_subdirectory(EXAMPLE)
117+
118+
if(enable_tests)
119+
enable_testing()
120+
add_subdirectory(TESTING)
121+
endif()
122+
123+
if (enable_doc)
124+
add_subdirectory(DOC)
125+
endif()

EXAMPLE/CMakeLists.txt

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
include_directories(${PROJECT_SOURCE_DIR}/SRC)
2+
3+
# build examples for target "all" only if enable_examples is set
4+
if(NOT enable_examples)
5+
set(_DEPENDENCY_ALL "EXCLUDE_FROM_ALL")
6+
endif()
7+
8+
# targets to build examples
9+
add_custom_target(examples_complex)
10+
add_dependencies(examples_complex
11+
pclinsol pclinsolx pclinsolx1 pclinsolx2 pcrepeat pcspmd)
12+
13+
add_custom_target(examples_double)
14+
add_dependencies(examples_double
15+
pdlinsol pdlinsolx pdlinsolx1 pdlinsolx2 pdrepeat pdspmd)
16+
17+
add_custom_target(examples_float)
18+
add_dependencies(examples_float
19+
pslinsol pslinsolx pslinsolx1 pslinsolx2 psrepeat psspmd)
20+
21+
add_custom_target(examples_doublecomplex)
22+
add_dependencies(examples_doublecomplex
23+
pzlinsol pzlinsolx pzlinsolx1 pzlinsolx2 pzrepeat pzspmd)
24+
25+
add_custom_target(examples)
26+
add_dependencies(examples
27+
examples_complex
28+
examples_double
29+
examples_float
30+
examples_doublecomplex)
31+
32+
33+
# examples for complex
34+
add_executable(pclinsol ${_DEPENDENCY_ALL} pclinsol.c)
35+
target_link_libraries(pclinsol superlu_mt${PLAT})
36+
37+
add_executable(pclinsolx ${_DEPENDENCY_ALL} pclinsolx.c)
38+
target_link_libraries(pclinsolx superlu_mt${PLAT})
39+
40+
add_executable(pclinsolx1 ${_DEPENDENCY_ALL} pclinsolx1.c)
41+
target_link_libraries(pclinsolx1 superlu_mt${PLAT})
42+
43+
add_executable(pclinsolx2 ${_DEPENDENCY_ALL} pclinsolx2.c)
44+
target_link_libraries(pclinsolx2 superlu_mt${PLAT})
45+
46+
add_executable(pcrepeat ${_DEPENDENCY_ALL} pcrepeat.c)
47+
target_link_libraries(pcrepeat superlu_mt${PLAT})
48+
49+
add_executable(pcspmd ${_DEPENDENCY_ALL} pcspmd.c)
50+
target_link_libraries(pcspmd superlu_mt${PLAT})
51+
52+
# examples for double
53+
add_executable(pdlinsol ${_DEPENDENCY_ALL} pdlinsol.c)
54+
target_link_libraries(pdlinsol superlu_mt${PLAT})
55+
56+
add_executable(pdlinsolx ${_DEPENDENCY_ALL} pdlinsolx.c)
57+
target_link_libraries(pdlinsolx superlu_mt${PLAT})
58+
59+
add_executable(pdlinsolx1 ${_DEPENDENCY_ALL} pdlinsolx1.c)
60+
target_link_libraries(pdlinsolx1 superlu_mt${PLAT})
61+
62+
add_executable(pdlinsolx2 ${_DEPENDENCY_ALL} pdlinsolx2.c)
63+
target_link_libraries(pdlinsolx2 superlu_mt${PLAT})
64+
65+
add_executable(pdrepeat ${_DEPENDENCY_ALL} pdrepeat.c)
66+
target_link_libraries(pdrepeat superlu_mt${PLAT})
67+
68+
add_executable(pdspmd ${_DEPENDENCY_ALL} pdspmd.c)
69+
target_link_libraries(pdspmd superlu_mt${PLAT})
70+
71+
# examples for float
72+
add_executable(pslinsol ${_DEPENDENCY_ALL} pslinsol.c)
73+
target_link_libraries(pslinsol superlu_mt${PLAT})
74+
75+
add_executable(pslinsolx ${_DEPENDENCY_ALL} pslinsolx.c)
76+
target_link_libraries(pslinsolx superlu_mt${PLAT})
77+
78+
add_executable(pslinsolx1 ${_DEPENDENCY_ALL} pslinsolx1.c)
79+
target_link_libraries(pslinsolx1 superlu_mt${PLAT})
80+
81+
add_executable(pslinsolx2 ${_DEPENDENCY_ALL} pslinsolx2.c)
82+
target_link_libraries(pslinsolx2 superlu_mt${PLAT})
83+
84+
add_executable(psrepeat ${_DEPENDENCY_ALL} psrepeat.c)
85+
target_link_libraries(psrepeat superlu_mt${PLAT})
86+
87+
add_executable(psspmd ${_DEPENDENCY_ALL} psspmd.c)
88+
target_link_libraries(psspmd superlu_mt${PLAT})
89+
90+
91+
# examples for double complex
92+
add_executable(pzlinsol ${_DEPENDENCY_ALL} pzlinsol.c)
93+
target_link_libraries(pzlinsol superlu_mt${PLAT})
94+
95+
add_executable(pzlinsolx ${_DEPENDENCY_ALL} pzlinsolx.c)
96+
target_link_libraries(pzlinsolx superlu_mt${PLAT})
97+
98+
add_executable(pzlinsolx1 ${_DEPENDENCY_ALL} pzlinsolx1.c)
99+
target_link_libraries(pzlinsolx1 superlu_mt${PLAT})
100+
101+
add_executable(pzlinsolx2 ${_DEPENDENCY_ALL} pzlinsolx2.c)
102+
target_link_libraries(pzlinsolx2 superlu_mt${PLAT})
103+
104+
add_executable(pzrepeat ${_DEPENDENCY_ALL} pzrepeat.c)
105+
target_link_libraries(pzrepeat superlu_mt${PLAT})
106+
107+
add_executable(pzspmd ${_DEPENDENCY_ALL} pzspmd.c)
108+
target_link_libraries(pzspmd superlu_mt${PLAT})
109+
110+
111+
if(MSVC AND WinGetOpt_FOUND)
112+
setx(NEEDS_GETOPT ${examples})
113+
114+
foreach(proj ${NEEDS_GETOPT})
115+
target_include_directories(${proj} PRIVATE ${WinGetOpt_INCLUDE_DIR})
116+
target_link_libraries(${proj} ${WinGetOpt_LIBRARY})
117+
endforeach(proj ${NEEDS_GETOPT})
118+
endif()

README

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
SuperLU_MT (version 3.1)
2-
========================
1+
SuperLU_MT (version 4.0.0)
2+
==========================
33

44
SuperLU_MT contains a set of subroutines to solve a sparse linear system
55
A*X=B. It uses Gaussian elimination with partial pivoting (GEPP).
@@ -18,17 +18,17 @@ matrices, in both single and double precision.
1818

1919
The distribution contains the following directory structure:
2020

21-
SuperLU_MT_2.2/README instructions on installation
22-
SuperLU_MT_2.2/CBLAS/ BLAS routines in C, functional but not fast
23-
SuperLU_MT_2.2/DOC/ Users' Guide
24-
SuperLU_MT_2.2/EXAMPLE/ example programs
25-
SuperLU_MT_2.2/INSTALL/ test machine dependent parameters; the Users' Guide.
26-
SuperLU_MT_2.2/MAKE_INC/ sample machine-specific make.inc files
27-
SuperLU_MT_2.2/SRC/ C source code, to be compiled into libsuperlu_mt.a
28-
SuperLU_MT_2.2/TESTING/ driver routines to test correctness
29-
SuperLU_MT_2.2/lib/ SuperLU_MT library archive libsuperlu_mt.a
30-
SuperLU_MT_2.2/Makefile top level Makefile that does installation and testing
31-
SuperLU_MT_2.2/make.inc compiler, compile flags, library definitions and C
21+
superlu_mt/README instructions on installation
22+
superlu_mt/CBLAS/ BLAS routines in C, functional but not fast
23+
superlu_mt/DOC/ Users' Guide
24+
superlu_mt/EXAMPLE/ example programs
25+
superlu_mt/INSTALL/ test machine dependent parameters; the Users' Guide.
26+
superlu_mt/MAKE_INC/ sample machine-specific make.inc files
27+
superlu_mt/SRC/ C source code, to be compiled into libsuperlu_mt.a
28+
superlu_mt/TESTING/ driver routines to test correctness
29+
superlu_mt/lib/ SuperLU_MT library archive libsuperlu_mt.a
30+
superlu_mt/Makefile top level Makefile that does installation and testing
31+
superlu_mt/make.inc compiler, compile flags, library definitions and C
3232
preprocessor definitions, included in all Makefiles.
3333
(You may need to edit it to suit your system
3434
before compiling the whole package.)
@@ -143,5 +143,3 @@ REFERENCES
143143
Xiaoye S. Li, Lawrence Berkeley National Lab, [email protected]
144144
James Demmel, UC Berkeley, [email protected]
145145
John R. Gilbert, UC Santa Barbara, [email protected]
146-
147-

SRC/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (HAVE_LIB_M)
99
target_link_libraries (superlu_mt${PLAT} PRIVATE m)
1010
endif ()
1111

12-
target_link_libraries (superlu_mt${PLAT} PRIVATE ${BLAS_LIBRARIES})
12+
target_link_libraries (superlu_mt${PLAT} PRIVATE ${BLAS_LIB})
1313
target_compile_definitions (superlu_mt${PLAT} PRIVATE Add_)
1414

1515
if (PLAT STREQUAL "_PTHREAD")

SRC/slu_mt_util.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,26 @@ at the top-level directory.
2222
#include <stdio.h>
2323
#include <stdlib.h>
2424
#include <string.h>
25+
#include <getopt.h>
2526
#include "slu_mt_machines.h"
2627

27-
/* Macros */
28+
/***********************************************************************
29+
* Macros
30+
***********************************************************************/
31+
/*
32+
* You can support older version of SuperLU_MT
33+
* At compile-time, you can catch the new release as:
34+
* #ifdef SUPERLU_MT_MAJOR_VERSION == 4
35+
* use the new interface
36+
* #else
37+
* use the old interface
38+
* #endif
39+
* Versions 3.x and earlier do not include a #define'd version numbers.
40+
*/
41+
#define SUPERLU_MT_MAJOR_VERSION 4
42+
#define SUPERLU_MT_MINOR_VERSION 0
43+
#define SUPERLU_MT_PATCH_VERSION 0
44+
2845
#ifndef USER_ABORT
2946
#define USER_ABORT(msg) superlu_abort_and_exit(msg)
3047
#endif

0 commit comments

Comments
 (0)