Skip to content

Commit 3e40c7a

Browse files
committed
C/C++ side implementation of user-defined termination callbacks
1 parent 0acd2af commit 3e40c7a

9 files changed

Lines changed: 62 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ set_property(CACHE CLARABEL_FEATURE_SDP PROPERTY STRINGS
3232

3333
option(CLARABEL_FEATURE_SERDE "Enable clarabel `serde` option " OFF)
3434
option(CLARABEL_FEATURE_FAER_SPARSE "Enable `faer-sparse` option" OFF)
35-
option(CLARABEL_FEATURE_SERDE "Enable `faer-sparse` option" OFF)
35+
option(CLARABEL_FEATURE_PARDISO_MKL "Enable `pardiso-mkl` option" OFF)
36+
option(CLARABEL_FEATURE_PARDISO_PANUA "Enable `pardiso-panua` option" OFF)
3637

3738

3839
#----------------------------------------------

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,19 @@ When reporting issues with the solver, it can be helpful to provide a JSON file
104104

105105
### Alternative linear algebra libraries
106106

107-
To enable the use of the [faer-rs](https://faer-rs.github.io/) sparse linear algebra library as an additional solver option, set `-DCLARABEL_FEATURE_FAER_SPARSE=true`.
107+
To enable the [faer-rs](https://faer-rs.github.io/) sparse linear algebra library as an additional solver option, set `-DCLARABEL_FEATURE_FAER_SPARSE=true`.
108+
109+
To enable the [`MKL Pardiso`](https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/) sparse linear algebra library as an additional solver option, set `-DCLARABEL_FEATURE_PARDISO_MKL=true`.
110+
111+
The solver will dynamically link to the MKL library, which must be accessible via the system library path (e.g. on `LD_LIBRARY_PATH` on Linux).
112+
113+
Alternatively, set the `MKLROOT` environment variable to the root of the MKL installation or `MKL_PARDISO_PATH` to the location of the MKL Pardiso library (e.g. the location of `libmkl_rt.so` in Linux).
114+
115+
To enable the [`Panua Pardiso`](https://panua.ch/pardiso/) sparse linear algebra library as an additional solver option, set `-DCLARABEL_FEATURE_PARDISO_PANUA=true`. This library is not open source and requires a license.
116+
117+
The solver will dynamically link to the Panua Pardiso library, which must be accessible via the system library path (e.g. on `LD_LIBRARY_PATH` on Linux).
118+
119+
Alternatively, set the `PARDISO_PATH` environment variable to the location of the Panua Pardiso library (e.g. the location of `libpardiso.so` in Linux).
108120

109121
### Unit tests
110122

include/c/DefaultSettings.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ typedef enum ClarabelDirectSolveMethods
1212
{
1313
AUTO,
1414
QDLDL,
15-
#ifdef FEATURE_FAER_SPARSE
15+
#ifdef FEATURE_FAER_SPARSE
1616
FAER,
17-
#endif
18-
// MKL, (not supported in Rust yet)
19-
// CHOLMOD, (not supported in Rust yet)
17+
#endif
18+
#ifdef FEATURE_PARDISO_MKL
19+
PARDISO_MKL,
20+
#endif
21+
#ifdef FEATURE_PARDISO_PANUA
22+
PARDISO_PANUA,
23+
#endif
2024
} ClarabelDirectSolveMethods;
2125

2226
#ifdef FEATURE_SDP

include/cpp/DefaultSettings.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ enum class ClarabelDirectSolveMethods
1010
{
1111
AUTO,
1212
QDLDL,
13-
#ifdef FEATURE_FAER_SPARSE
13+
#ifdef FEATURE_FAER_SPARSE
1414
FAER,
15-
#endif
16-
// MKL, (not supported in Rust yet)
17-
// CHOLMOD, (not supported in Rust yet)
15+
#endif
16+
#ifdef FEATURE_PARDISO_MKL
17+
PARDISO_MKL,
18+
#endif
19+
#ifdef FEATURE_PARDISO_PANUA
20+
PARDISO_PANUA,
21+
#endif
1822
};
1923

2024
#ifdef FEATURE_SDP

rust_wrapper/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,29 @@ if(CLARABEL_FEATURE_FAER_SPARSE)
4848
target_compile_definitions(libclarabel_c_shared INTERFACE FEATURE_FAER_SPARSE)
4949
endif()
5050

51+
# PARDISO_MKL feature flag
52+
if(CLARABEL_FEATURE_PARDISO_MKL)
53+
54+
# Set the Rust feature flag
55+
set(CLARABEL_BUILD_FEATURES "${CLARABEL_BUILD_FEATURES},pardiso-mkl")
56+
57+
# Define the FEATURE_PARDISO_MKL flag for all targets that link against clarabel_c
58+
target_compile_definitions(libclarabel_c_static INTERFACE FEATURE_PARDISO_MKL)
59+
target_compile_definitions(libclarabel_c_shared INTERFACE FEATURE_PARDISO_MKL)
60+
endif()
61+
62+
# PARDISO_PANUA feature flag
63+
if(CLARABEL_FEATURE_PARDISO_PANUA)
64+
65+
# Set the Rust feature flag
66+
set(CLARABEL_BUILD_FEATURES "${CLARABEL_BUILD_FEATURES},pardiso-panua")
67+
68+
# Define the FEATURE_PARDISO_PANUA flag for all targets that link against clarabel_c
69+
target_compile_definitions(libclarabel_c_static INTERFACE FEATURE_PARDISO_PANUA)
70+
target_compile_definitions(libclarabel_c_shared INTERFACE FEATURE_PARDISO_PANUA)
71+
endif()
72+
73+
5174
# SERDE feature flag
5275
if(CLARABEL_FEATURE_SERDE)
5376

rust_wrapper/src/solver/implementations/default/callbacks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(non_snake_case)]
2+
#![allow(non_camel_case_types)]
23

34
use super::solver::*;
45
use crate::solver::implementations::default::info::ClarabelDefaultInfo;

rust_wrapper/src/solver/implementations/default/info.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(non_snake_case)]
2+
#![allow(non_camel_case_types)]
3+
#![allow(dead_code)]
24

35
pub type ClarabelDefaultInfo<T> =
46
clarabel::solver::implementations::default::ffi::DefaultInfoFFI<T>;

rust_wrapper/src/solver/implementations/default/settings.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#![allow(non_snake_case)]
2+
#![allow(non_camel_case_types)]
3+
#![allow(dead_code)]
4+
15
use clarabel::algebra::FloatT;
26

37
pub type ClarabelDirectSolveMethods = clarabel::solver::ffi::DirectSolveMethodsFFI;

rust_wrapper/src/solver/implementations/default/solver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::utils;
1010

1111
use clarabel::algebra::FloatT;
1212
use clarabel::io::ConfigurablePrintTarget;
13-
use clarabel::solver::implementations::default::ffi::*;
1413
use clarabel::solver::{self as lib, IPSolver};
14+
1515
use std::ffi::c_char;
1616
use std::slice;
1717
use std::{ffi::c_void, mem::forget};

0 commit comments

Comments
 (0)