Skip to content

Commit 01ec12f

Browse files
committed
Update SCS to use LBT
1 parent e26dc34 commit 01ec12f

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

Project.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name = "SCS"
22
uuid = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
3-
repo = "https://github.com/jump-dev/SCS.jl"
43
version = "2.2.0"
4+
repo = "https://github.com/jump-dev/SCS.jl"
55

66
[deps]
7+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
78
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
89
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
10+
OpenBLAS32_jll = "656ef2d0-ae68-5445-9ca0-591084a874a2"
911
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1012
SCS_jll = "f4f2fc5b-1d94-523c-97ea-2ab488bedf4b"
1113
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -19,13 +21,15 @@ SCSSCS_GPU_jllExt = ["SCS_GPU_jll"]
1921
SCSSCS_MKL_jllExt = ["SCS_MKL_jll"]
2022

2123
[compat]
24+
LinearAlgebra = "1.10.0"
2225
MathOptInterface = "1.20"
2326
MutableArithmetics = "1"
27+
OpenBLAS32_jll = "0.3.29"
2428
Pkg = "1"
2529
PrecompileTools = "1"
26-
SCS_GPU_jll = "=3.2.8"
30+
SCS_GPU_jll = "=3.2.9"
2731
SCS_MKL_jll = "=3.2.8"
28-
SCS_jll = "=3.2.8"
32+
SCS_jll = "=3.2.9"
2933
SparseArrays = "1"
3034
Test = "1"
3135
julia = "1.10"

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,40 @@ true
192192

193193
The `GpuIndirectSolver` is available on `Linux x86_64` platform only.
194194

195+
## BLAS and LAPACK
196+
197+
With Julia v1.10 or later, SCS is compiled with
198+
[`libblastrampoline`](https://github.com/JuliaLinearAlgebra/libblastrampoline)
199+
(LBT), a library that can change between BLAS and LAPACK backends at runtime.
200+
201+
The default BLAS and LAPACK backend is [OpenBLAS](https://github.com/OpenMathLib/OpenBLAS),
202+
and we rely on the Julia artifact `OpenBLAS32_jll.jl` if no backend is loaded
203+
before `using SCS`.
204+
205+
Using LBT, we can also switch dynamically to other BLAS backends such as Intel
206+
MKL, BLIS, and Apple Accelerate. Because SCS relies heavily on BLAS and LAPACK
207+
routines, using an optimized backend for a particular platform can improve the
208+
performance.
209+
210+
### MKL
211+
212+
If you have [MKL.jl](https://github.com/JuliaLinearAlgebra/MKL.jl) installed,
213+
switch to MKL by adding `using MKL` to your code:
214+
215+
```julia
216+
using MKL
217+
using SCS
218+
```
219+
220+
### AppleAccelerate
221+
222+
If you are using macOS ≥ v13.4 and you have [AppleAccelerate.jl](https://github.com/JuliaLinearAlgebra/AppleAccelerate.jl) installed, add `using AppleAccelerate` to your code:
223+
224+
```julia
225+
using AppleAccelerate
226+
using SCS
227+
```
228+
195229
## Low-level wrapper
196230

197231
SCS.jl provides a low-level interface to solve a problem directly, without

src/SCS.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@
55

66
module SCS
77

8+
import LinearAlgebra
89
import MathOptInterface as MOI
910
import MutableArithmetics as MA
11+
import OpenBLAS32_jll
1012
import SCS_jll: libscsdir, libscsindir
1113
import SparseArrays
1214

15+
function __init__()
16+
config = LinearAlgebra.BLAS.lbt_get_config()
17+
if !any(lib -> lib.interface == :lp64, config.loaded_libs)
18+
LinearAlgebra.BLAS.lbt_forward(OpenBLAS32_jll.libopenblas_path)
19+
end
20+
return
21+
end
22+
1323
abstract type LinearSolver end
1424

1525
is_available(::Type{<:LinearSolver}) = false
@@ -30,6 +40,7 @@ export scs_solve
3040
import PrecompileTools
3141

3242
PrecompileTools.@setup_workload begin
43+
__init__()
3344
PrecompileTools.@compile_workload begin
3445
model = MOI.Utilities.CachingOptimizer(
3546
MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()),

0 commit comments

Comments
 (0)