Skip to content

Commit

Permalink
Fix new suitesparse version and Apple Clang compiling (#473)
Browse files Browse the repository at this point in the history
https://swift-nav.atlassian.net/browse/OC-729

Handle new Suitesparse version and dix Apple Clang compiling

Submodule links need to be corrected for Cmake and eigen after these PRs
are merged
swift-nav/cmake#171
swift-nav/eigen#4
  • Loading branch information
AlttiJokinen authored Jan 24, 2024
1 parent 95579dd commit c0e3b06
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmake/common
42 changes: 38 additions & 4 deletions include/albatross/src/cereal/suitesparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ inline void save(Archive &ar, cholmod_common const &cc,
// workspace, so we don't even do anything special when we
// deserialize.
ar(CEREAL_NVP(cc.itype));

#if CHOLMOD_VERSION < CHOLMOD_VER_CODE(5, 0)
ar(CEREAL_NVP(cc.dtype));
#endif

ar(CEREAL_NVP(cc.no_workspace_reallocate));
ar(CEREAL_NVP(cc.status));
ar(CEREAL_NVP(cc.fl));
Expand Down Expand Up @@ -177,8 +181,18 @@ inline void save(Archive &ar, cholmod_common const &cc,
ar(CEREAL_NVP(cc.SPQR_flopcount_bound));
ar(CEREAL_NVP(cc.SPQR_tol_used));
ar(CEREAL_NVP(cc.SPQR_norm_E_fro));
static_assert(sizeof(cc.SPQR_istat) == 10 * sizeof(SuiteSparse_long),
"cholmod_common.SPQR_istat expected to have 10 elements.");

// The number of elements was size 10 in CHOLMOD v4.2; reduced to 8 in CHOLMOD
// v5:
#if CHOLMOD_VERSION < CHOLMOD_VER_CODE(5, 0)
constexpr size_t cNumSPQRElements = 10;
#else
constexpr size_t cNumSPQRElements = 8;
#endif
static_assert(
sizeof(cc.SPQR_istat) == cNumSPQRElements * sizeof(SuiteSparse_long),
"cholmod_common.SPQR_istat expected to have certain number of elements.");

ar(::cereal::make_nvp("cc.SPQR_istat0", cc.SPQR_istat[0]));
ar(::cereal::make_nvp("cc.SPQR_istat1", cc.SPQR_istat[1]));
ar(::cereal::make_nvp("cc.SPQR_istat2", cc.SPQR_istat[2]));
Expand All @@ -187,8 +201,11 @@ inline void save(Archive &ar, cholmod_common const &cc,
ar(::cereal::make_nvp("cc.SPQR_istat5", cc.SPQR_istat[5]));
ar(::cereal::make_nvp("cc.SPQR_istat6", cc.SPQR_istat[6]));
ar(::cereal::make_nvp("cc.SPQR_istat7", cc.SPQR_istat[7]));

#if CHOLMOD_VERSION < CHOLMOD_VER_CODE(5, 0)
ar(::cereal::make_nvp("cc.SPQR_istat8", cc.SPQR_istat[8]));
ar(::cereal::make_nvp("cc.SPQR_istat9", cc.SPQR_istat[9]));
#endif

// Completely ignore all the GPU stuff.
#ifdef GPU_BLAS
Expand Down Expand Up @@ -261,7 +278,11 @@ inline void load(Archive &ar, cholmod_common &cc,
ar(CEREAL_NVP(cc.mark));
ALBATROSS_ASSERT(cholmod_l_free_work(&cc) == 1);
ar(CEREAL_NVP(cc.itype));

#if CHOLMOD_VERSION < CHOLMOD_VER_CODE(5, 0)
ar(CEREAL_NVP(cc.dtype));
#endif

ar(CEREAL_NVP(cc.no_workspace_reallocate));
ar(CEREAL_NVP(cc.status));
ar(CEREAL_NVP(cc.fl));
Expand Down Expand Up @@ -289,8 +310,18 @@ inline void load(Archive &ar, cholmod_common &cc,
ar(CEREAL_NVP(cc.SPQR_flopcount_bound));
ar(CEREAL_NVP(cc.SPQR_tol_used));
ar(CEREAL_NVP(cc.SPQR_norm_E_fro));
static_assert(sizeof(cc.SPQR_istat) == 10 * sizeof(SuiteSparse_long),
"cholmod_common.SPQR_istat expected to have 10 elements.");

// The number of elements was size 10 in CHOLMOD v4.2; reduced to 8 in CHOLMOD
// v5:
#if CHOLMOD_VERSION < CHOLMOD_VER_CODE(5, 0)
constexpr size_t cNumSPQRElements = 10;
#else
constexpr size_t cNumSPQRElements = 8;
#endif

static_assert(
sizeof(cc.SPQR_istat) == cNumSPQRElements * sizeof(SuiteSparse_long),
"cholmod_common.SPQR_istat expected to have certain number of elements.");
ar(::cereal::make_nvp("cc.SPQR_istat0", cc.SPQR_istat[0]));
ar(::cereal::make_nvp("cc.SPQR_istat1", cc.SPQR_istat[1]));
ar(::cereal::make_nvp("cc.SPQR_istat2", cc.SPQR_istat[2]));
Expand All @@ -299,8 +330,11 @@ inline void load(Archive &ar, cholmod_common &cc,
ar(::cereal::make_nvp("cc.SPQR_istat5", cc.SPQR_istat[5]));
ar(::cereal::make_nvp("cc.SPQR_istat6", cc.SPQR_istat[6]));
ar(::cereal::make_nvp("cc.SPQR_istat7", cc.SPQR_istat[7]));

#if CHOLMOD_VERSION < CHOLMOD_VER_CODE(5, 0)
ar(::cereal::make_nvp("cc.SPQR_istat8", cc.SPQR_istat[8]));
ar(::cereal::make_nvp("cc.SPQR_istat9", cc.SPQR_istat[9]));
#endif

// Completely ignore all the GPU stuff.
#ifdef GPU_BLAS
Expand Down
2 changes: 1 addition & 1 deletion third_party/eigen

0 comments on commit c0e3b06

Please sign in to comment.