Skip to content

Commit 01f502c

Browse files
BLAS/LAPACK interface for all of SuiteSparse
1 parent bdfdd74 commit 01f502c

File tree

153 files changed

+5396
-2516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+5396
-2516
lines changed

AMD/CMakeLists.txt

+8-17
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ include ( SuiteSparsePolicy )
4040

4141
project ( amd
4242
VERSION "${AMD_VERSION_MAJOR}.${AMD_VERSION_MINOR}.${AMD_VERSION_SUB}"
43-
LANGUAGES C ) # <-- add CXX here for packages that use C++
43+
LANGUAGES C )
4444

4545
#-------------------------------------------------------------------------------
4646
# find library dependencies
@@ -55,22 +55,6 @@ find_package ( SuiteSparse_config 6.0.0 REQUIRED )
5555
configure_file ( "Config/amd.h.in" "${PROJECT_SOURCE_DIR}/Include/amd.h")
5656
configure_file ( "Config/amd_version.tex.in" "${PROJECT_SOURCE_DIR}/Doc/amd_version.tex")
5757

58-
#-------------------------------------------------------------------------------
59-
# report status and set compile flags
60-
#-------------------------------------------------------------------------------
61-
62-
message ( STATUS "CMAKE C flags: ${CMAKE_C_FLAGS}" )
63-
# message ( STATUS "CMAKE C++ flags: ${CMAKE_CXX_FLAGS}" )
64-
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
65-
message ( STATUS "CMAKE C Flags debug: " ${CMAKE_C_FLAGS_DEBUG} )
66-
# message ( STATUS "CMAKE C++ Flags debug: " ${CMAKE_CXX_FLAGS_DEBUG} )
67-
else ( )
68-
message ( STATUS "CMAKE C Flags release: " ${CMAKE_C_FLAGS_RELEASE} )
69-
# message ( STATUS "CMAKE C++ Flags release: " ${CMAKE_CXX_FLAGS_RELEASE} )
70-
endif ( )
71-
message ( STATUS "CMAKE C compiler: " ${CMAKE_C_COMPILER_ID} )
72-
# message ( STATUS "CMAKE C++ compiler: " ${CMAKE_CXX_COMPILER_ID} )
73-
7458
#-------------------------------------------------------------------------------
7559
# include directories
7660
#-------------------------------------------------------------------------------
@@ -179,3 +163,10 @@ else ( )
179163
message ( STATUS "Skipping the demos in AMD/Demo" )
180164

181165
endif ( )
166+
167+
#-------------------------------------------------------------------------------
168+
# report status
169+
#-------------------------------------------------------------------------------
170+
171+
include ( SuiteSparseReport )
172+

BTF/CMakeLists.txt

+7-17
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ include ( SuiteSparsePolicy )
4040

4141
project ( btf
4242
VERSION "${BTF_VERSION_MAJOR}.${BTF_VERSION_MINOR}.${BTF_VERSION_SUB}"
43-
LANGUAGES C ) # <-- add CXX here for packages that use C++
43+
LANGUAGES C )
4444

4545
#-------------------------------------------------------------------------------
4646
# find library dependencies
@@ -54,22 +54,6 @@ find_package ( SuiteSparse_config 6.0.0 REQUIRED )
5454

5555
configure_file ( "Config/btf.h.in" "${PROJECT_SOURCE_DIR}/Include/btf.h")
5656

57-
#-------------------------------------------------------------------------------
58-
# report status and set compile flags
59-
#-------------------------------------------------------------------------------
60-
61-
message ( STATUS "CMAKE C flags: ${CMAKE_C_FLAGS}" )
62-
# message ( STATUS "CMAKE C++ flags: ${CMAKE_CXX_FLAGS}" )
63-
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
64-
message ( STATUS "CMAKE C Flags debug: " ${CMAKE_C_FLAGS_DEBUG} )
65-
# message ( STATUS "CMAKE C++ Flags debug: " ${CMAKE_CXX_FLAGS_DEBUG} )
66-
else ( )
67-
message ( STATUS "CMAKE C Flags release: " ${CMAKE_C_FLAGS_RELEASE} )
68-
# message ( STATUS "CMAKE C++ Flags release: " ${CMAKE_CXX_FLAGS_RELEASE} )
69-
endif ( )
70-
message ( STATUS "CMAKE C compiler: " ${CMAKE_C_COMPILER_ID} )
71-
# message ( STATUS "CMAKE C++ compiler: " ${CMAKE_CXX_COMPILER_ID} )
72-
7357
#-------------------------------------------------------------------------------
7458
# include directories
7559
#-------------------------------------------------------------------------------
@@ -146,3 +130,9 @@ if ( INSIDE_SUITESPARSE )
146130
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR} )
147131
endif ( )
148132

133+
#-------------------------------------------------------------------------------
134+
# report status
135+
#-------------------------------------------------------------------------------
136+
137+
include ( SuiteSparseReport )
138+

CAMD/CMakeLists.txt

+8-17
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ include ( SuiteSparsePolicy )
3939

4040
project ( camd
4141
VERSION "${CAMD_VERSION_MAJOR}.${CAMD_VERSION_MINOR}.${CAMD_VERSION_SUB}"
42-
LANGUAGES C ) # <-- add CXX here for packages that use C++
42+
LANGUAGES C )
4343

4444
#-------------------------------------------------------------------------------
4545
# find library dependencies
@@ -54,22 +54,6 @@ find_package ( SuiteSparse_config 6.0.0 REQUIRED )
5454
configure_file ( "Config/camd.h.in" "${PROJECT_SOURCE_DIR}/Include/camd.h" )
5555
configure_file ( "Config/camd_version.tex.in" "${PROJECT_SOURCE_DIR}/Doc/camd_version.tex" )
5656

57-
#-------------------------------------------------------------------------------
58-
# report status and set compile flags
59-
#-------------------------------------------------------------------------------
60-
61-
message ( STATUS "CMAKE C flags: ${CMAKE_C_FLAGS}" )
62-
# message ( STATUS "CMAKE C++ flags: ${CMAKE_CXX_FLAGS}" )
63-
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
64-
message ( STATUS "CMAKE C Flags debug: " ${CMAKE_C_FLAGS_DEBUG} )
65-
# message ( STATUS "CMAKE C++ Flags debug: " ${CMAKE_CXX_FLAGS_DEBUG} )
66-
else ( )
67-
message ( STATUS "CMAKE C Flags release: " ${CMAKE_C_FLAGS_RELEASE} )
68-
# message ( STATUS "CMAKE C++ Flags release: " ${CMAKE_CXX_FLAGS_RELEASE} )
69-
endif ( )
70-
message ( STATUS "CMAKE C compiler: " ${CMAKE_C_COMPILER_ID} )
71-
# message ( STATUS "CMAKE C++ compiler: " ${CMAKE_CXX_COMPILER_ID} )
72-
7357
#-------------------------------------------------------------------------------
7458
# include directories
7559
#-------------------------------------------------------------------------------
@@ -177,3 +161,10 @@ else ( )
177161
message ( STATUS "Skipping the demos in CAMD/Demo" )
178162

179163
endif ( )
164+
165+
#-------------------------------------------------------------------------------
166+
# report status
167+
#-------------------------------------------------------------------------------
168+
169+
include ( SuiteSparseReport )
170+

CCOLAMD/CMakeLists.txt

+10-18
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ include ( SuiteSparsePolicy )
3939

4040
project ( ccolamd
4141
VERSION "${CCOLAMD_VERSION_MAJOR}.${CCOLAMD_VERSION_MINOR}.${CCOLAMD_VERSION_SUB}"
42-
LANGUAGES C ) # <-- add CXX here for packages that use C++
42+
LANGUAGES C )
4343

4444
#-------------------------------------------------------------------------------
4545
# find library dependencies
@@ -51,23 +51,8 @@ find_package ( SuiteSparse_config 6.0.0 REQUIRED )
5151
# configure files
5252
#-------------------------------------------------------------------------------
5353

54-
configure_file ( "Config/ccolamd.h.in" "${PROJECT_SOURCE_DIR}/Include/ccolamd.h" )
55-
56-
#-------------------------------------------------------------------------------
57-
# report status and set compile flags
58-
#-------------------------------------------------------------------------------
59-
60-
message ( STATUS "CMAKE C flags: ${CMAKE_C_FLAGS}" )
61-
# message ( STATUS "CMAKE C++ flags: ${CMAKE_CXX_FLAGS}" )
62-
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
63-
message ( STATUS "CMAKE C Flags debug: " ${CMAKE_C_FLAGS_DEBUG} )
64-
# message ( STATUS "CMAKE C++ Flags debug: " ${CMAKE_CXX_FLAGS_DEBUG} )
65-
else ( )
66-
message ( STATUS "CMAKE C Flags release: " ${CMAKE_C_FLAGS_RELEASE} )
67-
# message ( STATUS "CMAKE C++ Flags release: " ${CMAKE_CXX_FLAGS_RELEASE} )
68-
endif ( )
69-
message ( STATUS "CMAKE C compiler: " ${CMAKE_C_COMPILER_ID} )
70-
# message ( STATUS "CMAKE C++ compiler: " ${CMAKE_CXX_COMPILER_ID} )
54+
configure_file ( "Config/ccolamd.h.in"
55+
"${PROJECT_SOURCE_DIR}/Include/ccolamd.h" )
7156

7257
#-------------------------------------------------------------------------------
7358
# include directories
@@ -172,3 +157,10 @@ else ( )
172157
message ( STATUS "Skipping the demos in CCCOLAMD/Demo" )
173158

174159
endif ( )
160+
161+
#-------------------------------------------------------------------------------
162+
# report status
163+
#-------------------------------------------------------------------------------
164+
165+
include ( SuiteSparseReport )
166+

CHOLMOD/CMakeLists.txt

+7-18
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,6 @@ endif ( )
8484
configure_file ( "Config/cholmod.h.in" "${PROJECT_SOURCE_DIR}/Include/cholmod.h")
8585
configure_file ( "Config/cholmod_version.tex.in" "${PROJECT_SOURCE_DIR}/Doc/cholmod_version.tex")
8686

87-
#-------------------------------------------------------------------------------
88-
# report status and set compile flags
89-
#-------------------------------------------------------------------------------
90-
91-
message ( STATUS "CMAKE C flags: ${CMAKE_C_FLAGS}" )
92-
# message ( STATUS "CMAKE C++ flags: ${CMAKE_CXX_FLAGS}" )
93-
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
94-
message ( STATUS "CMAKE C Flags debug: " ${CMAKE_C_FLAGS_DEBUG} )
95-
# message ( STATUS "CMAKE C++ Flags debug: " ${CMAKE_CXX_FLAGS_DEBUG} )
96-
else ( )
97-
message ( STATUS "CMAKE C Flags release: " ${CMAKE_C_FLAGS_RELEASE} )
98-
# message ( STATUS "CMAKE C++ Flags release: " ${CMAKE_CXX_FLAGS_RELEASE} )
99-
endif ( )
100-
message ( STATUS "CMAKE C compiler: " ${CMAKE_C_COMPILER_ID} )
101-
# message ( STATUS "CMAKE C++ compiler: " ${CMAKE_CXX_COMPILER_ID} )
102-
10387
#-------------------------------------------------------------------------------
10488
# include directories
10589
#-------------------------------------------------------------------------------
@@ -199,6 +183,7 @@ message ( STATUS "BLAS libraries: ${BLAS_LIBRARIES} ")
199183
message ( STATUS "BLAS linker flags: ${BLAS_LINKER_FLAGS} ")
200184
target_link_libraries ( cholmod PUBLIC ${BLAS_LIBRARIES} )
201185
target_link_libraries ( cholmod_static PUBLIC ${BLAS_LIBRARIES} )
186+
include_directories ( ${BLAS_INCLUDE_DIRS} )
202187

203188
# LAPACK:
204189
message ( STATUS "LAPACK libraries: ${LAPACK_LIBRARIES} ")
@@ -299,6 +284,10 @@ else ( )
299284

300285
endif ( )
301286

302-
message ( STATUS "Final CMAKE C flags : ${CMAKE_C_FLAGS} ")
303-
message ( STATUS "Final CMAKE C++ flags : ${CMAKE_CXX_FLAGS} ")
287+
#-------------------------------------------------------------------------------
288+
# report status
289+
#-------------------------------------------------------------------------------
290+
291+
include ( SuiteSparseReport )
292+
304293

CHOLMOD/Check/cholmod_check.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ static int check_common
268268
P3 (" sizeof(void *): %d\n", (int) sizeof (void *)) ;
269269
P3 (" sizeof(double): %d\n", (int) sizeof (double)) ;
270270
P3 (" sizeof(Int): %d (CHOLMOD's basic integer)\n", (int) sizeof (Int)) ;
271-
P3 (" sizeof(BLAS_INT): %d (integer used in the BLAS)\n",
272-
(int) sizeof (BLAS_INT)) ;
271+
P3 (" sizeof(SUITESPARSE_BLAS_INT): %d (integer used in the BLAS)\n",
272+
(int) sizeof (SUITESPARSE_BLAS_INT)) ;
273273

274274
if (Common->fl != EMPTY)
275275
{

CHOLMOD/Cholesky/cholmod_solve.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -1575,15 +1575,13 @@ int CHOLMOD(solve2) /* returns TRUE on success, FALSE on failure */
15751575

15761576
iperm (Y, Perm, 0, nrhs, X) ; /* X = P'*Y */
15771577

1578-
if (CHECK_BLAS_INT && !Common->blas_ok)
1578+
if (sizeof (SUITESPARSE_BLAS_INT) < sizeof (Int) && !Common->blas_ok)
15791579
{
15801580
/* Integer overflow in the BLAS. This is probably impossible,
15811581
* since the BLAS were used to create the supernodal factorization.
15821582
* It might be possible for the calls to the BLAS to differ between
15831583
* factorization and forward/backsolves, however. This statement
1584-
* is untested; it does not appear in the compiled code if
1585-
* CHECK_BLAS_INT is true (when the same integer is used in
1586-
* CHOLMOD and the BLAS. */
1584+
* cannot be tested. */
15871585
return (FALSE) ;
15881586
}
15891587

CHOLMOD/Config/cholmod.h.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,8 @@ typedef struct cholmod_common_struct
10871087

10881088
int called_nd ; /* TRUE if the last call to
10891089
* cholmod_analyze called NESDIS or METIS. */
1090-
int blas_ok ; /* FALSE if BLAS int overflow; TRUE otherwise */
1090+
int blas_ok ; /* FALSE if SUITESPARSE_BLAS_INT overflow;
1091+
TRUE otherwise */
10911092

10921093
/* ---------------------------------------------------------------------- */
10931094
/* SuiteSparseQR control parameters: */

CHOLMOD/Core/cholmod_common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int CHOLMOD(start)
143143
/* Common->called_nd is TRUE if cholmod_analyze called or NESDIS */
144144
Common->called_nd = FALSE ;
145145

146-
Common->blas_ok = TRUE ; /* false if BLAS int overflow occurs */
146+
Common->blas_ok = TRUE ; /* false if SUITESPARSE_BLAS_INT overflows */
147147

148148
/* ---------------------------------------------------------------------- */
149149
/* default SuiteSparseQR knobs and statististics */

CHOLMOD/Demo/cholmod_demo.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,18 @@ int main (int argc, char **argv)
520520
{
521521
cholmod_dense *R2 ;
522522

523+
// x = A\b
524+
cholmod_free_dense (&X, cm) ;
525+
X = cholmod_solve (CHOLMOD_A, L, B, cm) ;
526+
527+
// R = B-A*X
528+
cholmod_free_dense (&R, cm) ;
529+
R = cholmod_copy_dense (B, cm) ;
530+
cholmod_sdmult (A, 0, minusone, one, X, R, cm) ;
531+
523532
/* R2 = A\(B-A*X) */
524533
R2 = cholmod_solve (CHOLMOD_A, L, R, cm) ;
534+
525535
/* compute X = X + A\(B-A*X) */
526536
Xx = X->x ;
527537
Rx = R2->x ;
@@ -530,7 +540,6 @@ int main (int argc, char **argv)
530540
Xx [i] = Xx [i] + Rx [i] ;
531541
}
532542
cholmod_free_dense (&R2, cm) ;
533-
cholmod_free_dense (&R, cm) ;
534543

535544
/* compute the new residual, R = B-A*X */
536545
cholmod_free_dense (&R, cm) ;

CHOLMOD/Demo/cholmod_l_demo.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,15 @@ int main (int argc, char **argv)
609609
{
610610
cholmod_dense *R2 ;
611611

612+
// x = A\b
613+
cholmod_l_free_dense (&X, cm) ;
614+
X = cholmod_l_solve (CHOLMOD_A, L, B, cm) ;
615+
616+
// R = B-A*X
617+
cholmod_l_free_dense (&R, cm) ;
618+
R = cholmod_l_copy_dense (B, cm) ;
619+
cholmod_l_sdmult (A, 0, minusone, one, X, R, cm) ;
620+
612621
/* R2 = A\(B-A*X) */
613622
R2 = cholmod_l_solve (CHOLMOD_A, L, R, cm) ;
614623
/* compute X = X + A\(B-A*X) */
@@ -619,7 +628,6 @@ int main (int argc, char **argv)
619628
Xx [i] = Xx [i] + Rx [i] ;
620629
}
621630
cholmod_l_free_dense (&R2, cm) ;
622-
cholmod_l_free_dense (&R, cm) ;
623631

624632
/* compute the new residual, R = B-A*X */
625633
cholmod_l_free_dense (&R, cm) ;

CHOLMOD/Doc/ChangeLog

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Oct FIXME, 2022: version 4.0.0
44
* integers: int (32-bit) and SuiteSparse_long (nominally 64-bit) replaced
55
with int32_t and int64_t.
66
* cholmod.h: single include file for all Modules
7+
* BLAS/LAPACK: relying on SuiteSparse_config and CMake to find and link
8+
with the BLAS and LAPACK libraries
79

810
June 30, 2020: no change to version number
911

CHOLMOD/Include/cholmod.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,8 @@ typedef struct cholmod_common_struct
10871087

10881088
int called_nd ; /* TRUE if the last call to
10891089
* cholmod_analyze called NESDIS or METIS. */
1090-
int blas_ok ; /* FALSE if BLAS int overflow; TRUE otherwise */
1090+
int blas_ok ; /* FALSE if SUITESPARSE_BLAS_INT overflow;
1091+
TRUE otherwise */
10911092

10921093
/* ---------------------------------------------------------------------- */
10931094
/* SuiteSparseQR control parameters: */

0 commit comments

Comments
 (0)