Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sundials' KLU_INDEXTYPE match actual klu index type #1733

Merged
merged 7 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ThirdParty/SuiteSparse/AMD/Include/amd_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@
#define ID SuiteSparse_long_id
#define Int_MAX SuiteSparse_long_max

#define UnsignedInt SuiteSparse_unsigned_long

#define AMD_order amd_l_order
#define AMD_defaults amd_l_defaults
#define AMD_control amd_l_control
Expand All @@ -180,6 +182,8 @@
#define ID "%d"
#define Int_MAX INT_MAX

#define UnsignedInt unsigned int

#define AMD_order amd_order
#define AMD_defaults amd_defaults
#define AMD_control amd_control
Expand Down
2 changes: 1 addition & 1 deletion ThirdParty/SuiteSparse/AMD/Source/amd_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ GLOBAL void AMD_2
nvi, nvj, nvpiv, slenme, wbig, we, wflg, wnvi, ok, ndense, ncmpa,
dense, aggressive ;

unsigned Int hash ; /* unsigned, so that hash % n is well defined.*/
UnsignedInt hash ; /* unsigned, so that hash % n is well defined.*/

/*
* deg: the degree of a variable or element
Expand Down
4 changes: 4 additions & 0 deletions ThirdParty/SuiteSparse/CAMD/Include/camd_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
#define ID SuiteSparse_long_id
#define Int_MAX SuiteSparse_long_max

#define UnsignedInt SuiteSparse_unsigned_long

#define CAMD_order camd_l_order
#define CAMD_defaults camd_l_defaults
#define CAMD_control camd_l_control
Expand All @@ -182,6 +184,8 @@
#define ID "%d"
#define Int_MAX INT_MAX

#define UnsignedInt unsigned int

#define CAMD_order camd_order
#define CAMD_defaults camd_defaults
#define CAMD_control camd_control
Expand Down
2 changes: 1 addition & 1 deletion ThirdParty/SuiteSparse/CAMD/Source/camd_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ GLOBAL void CAMD_2
nvi, nvj, nvpiv, slenme, wbig, we, wflg, wnvi, ok, ndense, ncmpa, nnull,
dense, aggressive ;

unsigned Int hash ; /* unsigned, so that hash % n is well defined.*/
UnsignedInt hash ; /* unsigned, so that hash % n is well defined.*/

/*
* deg: the degree of a variable or element
Expand Down
6 changes: 5 additions & 1 deletion ThirdParty/SuiteSparse/COLAMD/Source/colamd.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@
#define ID SuiteSparse_long_id
#define Int_MAX SuiteSparse_long_max

#define UnsignedInt SuiteSparse_unsigned_long

#define COLAMD_recommended colamd_l_recommended
#define COLAMD_set_defaults colamd_l_set_defaults
#define COLAMD_MAIN colamd_l
Expand All @@ -676,6 +678,8 @@
#define ID "%d"
#define Int_MAX INT_MAX

#define UnsignedInt unsigned int

#define COLAMD_recommended colamd_recommended
#define COLAMD_set_defaults colamd_set_defaults
#define COLAMD_MAIN colamd
Expand Down Expand Up @@ -2193,7 +2197,7 @@ PRIVATE Int find_ordering /* return the number of garbage collections */
Int col ; /* a column index */
Int max_score ; /* maximum possible score */
Int cur_score ; /* score of current column */
unsigned Int hash ; /* hash value for supernode detection */
UnsignedInt hash ; /* hash value for supernode detection */
Int head_column ; /* head of hash bucket */
Int first_col ; /* first column in hash bucket */
Int tag_mark ; /* marker value for mark array */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern "C" {

#include <limits.h>
#include <stdlib.h>
#include <inttypes.h>

/* ========================================================================== */
/* === SuiteSparse_long ===================================================== */
Expand All @@ -59,12 +60,13 @@ extern "C" {

#else

#define SuiteSparse_long long
#define SuiteSparse_long_max LONG_MAX
#define SuiteSparse_long_idd "ld"
#define SuiteSparse_long int64_t
#define SuiteSparse_long_max INT64_MAX
#define SuiteSparse_long_idd PRId64

#endif
#define SuiteSparse_long_id "%" SuiteSparse_long_idd
#define SuiteSparse_unsigned_long uint64_t
#endif

/* ========================================================================== */
Expand Down
8 changes: 5 additions & 3 deletions ThirdParty/SuiteSparse/include/SuiteSparse_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern "C" {

#include <limits.h>
#include <stdlib.h>
#include <inttypes.h>

/* ========================================================================== */
/* === SuiteSparse_long ===================================================== */
Expand All @@ -59,12 +60,13 @@ extern "C" {

#else

#define SuiteSparse_long long
#define SuiteSparse_long_max LONG_MAX
#define SuiteSparse_long_idd "ld"
#define SuiteSparse_long int64_t
#define SuiteSparse_long_max INT64_MAX
#define SuiteSparse_long_idd PRId64

#endif
#define SuiteSparse_long_id "%" SuiteSparse_long_idd
#define SuiteSparse_unsigned_long uint64_t
#endif

/* ========================================================================== */
Expand Down
22 changes: 11 additions & 11 deletions ThirdParty/sundials/src/sunlinsol/klu/sunlinsol_klu.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
*/

#if defined(SUNDIALS_INT64_T)
#define KLU_INDEXTYPE long int
#define KLU_INDEXTYPE int64_t
#else
#define KLU_INDEXTYPE int
#define KLU_INDEXTYPE int32_t
#endif

/*
Expand Down Expand Up @@ -331,31 +331,31 @@ int SUNLinSolSetup_KLU(SUNLinearSolver S, SUNMatrix A)
if ( COMMON(S).rcond < uround_twothirds ) {

/* Condition number may be getting large.
Compute more accurate estimate */
Compute more accurate estimate */
retval = sun_klu_condest((KLU_INDEXTYPE*) SUNSparseMatrix_IndexPointers(A),
SUNSparseMatrix_Data(A),
SYMBOLIC(S),
NUMERIC(S),
&COMMON(S));
if (retval == 0) {
LASTFLAG(S) = SUNLS_PACKAGE_FAIL_REC;
LASTFLAG(S) = SUNLS_PACKAGE_FAIL_REC;
return(LASTFLAG(S));
}

if ( COMMON(S).condest > (ONE/uround_twothirds) ) {

/* More accurate estimate also says condition number is
large, so recompute the numeric factorization */
sun_klu_free_numeric(&NUMERIC(S), &COMMON(S));
NUMERIC(S) = sun_klu_factor((KLU_INDEXTYPE*) SUNSparseMatrix_IndexPointers(A),
/* More accurate estimate also says condition number is
large, so recompute the numeric factorization */
sun_klu_free_numeric(&NUMERIC(S), &COMMON(S));
NUMERIC(S) = sun_klu_factor((KLU_INDEXTYPE*) SUNSparseMatrix_IndexPointers(A),
(KLU_INDEXTYPE*) SUNSparseMatrix_IndexValues(A),
SUNSparseMatrix_Data(A),
SYMBOLIC(S),
&COMMON(S));
if (NUMERIC(S) == NULL) {
LASTFLAG(S) = SUNLS_PACKAGE_FAIL_UNREC;
if (NUMERIC(S) == NULL) {
LASTFLAG(S) = SUNLS_PACKAGE_FAIL_UNREC;
return(LASTFLAG(S));
}
}
}

}
Expand Down