Skip to content

Commit af2195f

Browse files
authored
Extensions (#27)
Introducd 1.9 extensions Also: * Let timing test always pass, issue a warning instead if it fails. Fixes problem with cases of CPU noise on CI.
1 parent bee8bb9 commit af2195f

14 files changed

+276
-98
lines changed

Project.toml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExtendableSparse"
22
uuid = "95c220a8-a1cf-11e9-0c77-dbfce5f500b3"
33
authors = ["Juergen Fuhrmann <[email protected]>"]
4-
version = "1.1.0"
4+
version = "1.2.0"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
@@ -11,16 +11,34 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1111
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1212
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1313
Sparspak = "e56a9233-b9d6-4f03-8d0f-1825330902ac"
14+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1415
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
1516
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1617

18+
[weakdeps]
19+
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"
20+
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
21+
Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2"
22+
23+
24+
25+
[extensions]
26+
ExtendableSparseAlgebraicMultigridExt = "AlgebraicMultigrid"
27+
ExtendableSparsePardisoExt = "Pardiso"
28+
ExtendableSparseIncompleteLUExt = "IncompleteLU"
29+
1730
[compat]
1831
DocStringExtensions = "0.8, 0.9"
1932
ILUZero = "0.2"
20-
Requires = "1.1.3"
33+
Requires ="1.1.3"
2134
Sparspak = "0.3.6"
2235
julia = "1.6"
36+
AlgebraicMultigrid = "0.4,0.5"
37+
IncompleteLU = "^0.2.1"
38+
Pardiso = "0.5.1"
39+
StaticArrays = "1.5.24"
2340

2441
[extras]
25-
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
26-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
42+
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"
43+
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
44+
Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2"

docs/Project.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2"
1313
Sparspak = "e56a9233-b9d6-4f03-8d0f-1825330902ac"
1414

1515
[compat]
16-
AlgebraicMultigrid = "0.4,0.5"
17-
IncompleteLU = "^0.2.1"
1816
IterativeSolvers = "0.9"
19-
Pardiso = "^0.5.1"

docs/src/iter.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ nm1, nm2
6666
```
6767

6868
### API
69-
69+
Available by default:
7070
```@autodocs
7171
Modules = [ExtendableSparse]
72-
Pages = ["umfpack_lu.jl", "pardiso_lu.jl", "sparspak.jl"]
72+
Pages = ["umfpack_lu.jl", "sparspak.jl"]
73+
```
74+
75+
Pardiso extension:
76+
```@docs
77+
PardisoLU
78+
MKLPardisoLU
7379
```
7480

81+
7582
## Preconditioners
7683

7784
The API is similar to that for LU factorizations.
@@ -123,14 +130,22 @@ nm1, nm2
123130
### API
124131

125132
#### Recommended
133+
Available by default:
126134
```@autodocs
127135
Modules = [ExtendableSparse]
128136
Pages = ["iluzero.jl","ilut.jl","amg.jl","blockpreconditioner.jl"]
129137
```
130138

139+
Extensions:
140+
```@docs
141+
ILUTPreconditioner
142+
AMGPreconditioner
143+
```
144+
131145

132146
#### Experimental
133147
```@autodocs
134148
Modules = [ExtendableSparse]
135149
Pages = ["jacobi.jl","parallel_jacobi.jl","ilu0.jl",]
136150
```
151+
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1+
module ExtendableSparseAlgebraicMultigridExt
2+
3+
using ExtendableSparse
4+
5+
isdefined(Base, :get_extension) ? using AlgebraicMultigrid : using ..AlgebraicMultigrid
6+
7+
import ExtendableSparse: @makefrommatrix, AbstractPreconditioner, update!
8+
19
mutable struct AMGPreconditioner <: AbstractPreconditioner
210
A::ExtendableSparseMatrix
311
factorization::AlgebraicMultigrid.Preconditioner
412
max_levels::Int
513
max_coarse::Int
6-
function AMGPreconditioner(; max_levels = 10, max_coarse = 10)
14+
function ExtendableSparse.AMGPreconditioner(; max_levels = 10, max_coarse = 10)
715
precon = new()
816
precon.max_levels = max_levels
917
precon.max_coarse = max_coarse
1018
precon
1119
end
1220
end
1321

14-
"""
15-
```
16-
AMGPreconditioner(;max_levels=10, max_coarse=10)
17-
AMGPreconditioner(matrix;max_levels=10, max_coarse=10)
18-
```
19-
20-
Create the [`AMGPreconditioner`](@ref) wrapping the Ruge-Stüben AMG preconditioner from [AlgebraicMultigrid.jl](https://github.com/JuliaLinearAlgebra/AlgebraicMultigrid.jl)
21-
"""
22-
function AMGPreconditioner end
2322

2423
@eval begin
25-
@makefrommatrix AMGPreconditioner
24+
@makefrommatrix ExtendableSparse.AMGPreconditioner
2625
end
2726

2827
function update!(precon::AMGPreconditioner)
@@ -32,3 +31,5 @@ end
3231

3332
allow_views(::AMGPreconditioner)=true
3433
allow_views(::Type{AMGPreconditioner})=true
34+
35+
end
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1+
module ExtendableSparseIncompleteLUExt
2+
3+
using ExtendableSparse
4+
5+
isdefined(Base, :get_extension) ? using IncompleteLU : using ..IncompleteLU
6+
7+
import ExtendableSparse: @makefrommatrix, AbstractPreconditioner, update!
8+
19
mutable struct ILUTPreconditioner <: AbstractPreconditioner
210
A::ExtendableSparseMatrix
311
factorization::IncompleteLU.ILUFactorization
412
droptol::Float64
5-
function ILUTPreconditioner(; droptol = 1.0e-3)
13+
function ExtendableSparse.ILUTPreconditioner(; droptol = 1.0e-3)
614
p = new()
715
p.droptol = droptol
816
p
917
end
1018
end
1119

12-
"""
13-
```
14-
ILUTPreconditioner(;droptol=1.0e-3)
15-
ILUTPreconditioner(matrix; droptol=1.0e-3)
16-
```
17-
18-
Create the [`ILUTPreconditioner`](@ref) wrapping the one
19-
from [IncompleteLU.jl](https://github.com/haampie/IncompleteLU.jl)
20-
For using this, you need to issue `using IncompleteLU`.
21-
"""
22-
function ILUTPreconditioner end
2320

2421
@eval begin
25-
@makefrommatrix ILUTPreconditioner
22+
@makefrommatrix ExtendableSparse.ILUTPreconditioner
2623
end
2724

2825
function update!(precon::ILUTPreconditioner)
2926
A = precon.A
3027
@inbounds flush!(A)
3128
precon.factorization = IncompleteLU.ilu(A.cscmatrix; τ = precon.droptol)
3229
end
30+
end
31+

src/factorizations/pardiso_lu.jl renamed to ext/ExtendableSparsePardisoExt.jl

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
module ExtendableSparsePardisoExt
2+
using ExtendableSparse
3+
using LinearAlgebra
4+
5+
isdefined(Base, :get_extension) ? using Pardiso : using ..Pardiso
6+
7+
import ExtendableSparse: @makefrommatrix, update!, AbstractLUFactorization
8+
19
abstract type AbstractPardisoLU <: AbstractLUFactorization end
210

311
mutable struct PardisoLU <: AbstractPardisoLU
@@ -9,34 +17,10 @@ mutable struct PardisoLU <: AbstractPardisoLU
917
mtype::Union{Int,Nothing}
1018
end
1119

12-
function PardisoLU(; iparm = nothing, dparm = nothing,mtype = nothing)
20+
function ExtendableSparse.PardisoLU(; iparm = nothing, dparm = nothing,mtype = nothing)
1321
fact = PardisoLU(nothing, Pardiso.PardisoSolver(), 0,iparm,dparm,mtype)
1422
end
1523

16-
"""
17-
```
18-
PardisoLU(;iparm::Vector,
19-
dparm::Vector,
20-
mtype::Int)
21-
22-
PardisoLU(matrix; iparm,dparm,mtype)
23-
```
24-
25-
LU factorization based on pardiso. For using this, you need to issue `using Pardiso`
26-
and have the pardiso library from [pardiso-project.org](https://pardiso-project.org)
27-
[installed](https://github.com/JuliaSparse/Pardiso.jl#pardiso-60).
28-
29-
The optional keyword arguments `mtype`, `iparm` and `dparm` are
30-
[Pardiso internal parameters](https://github.com/JuliaSparse/Pardiso.jl#readme).
31-
32-
Forsetting them, one can also access the `PardisoSolver` e.g. like
33-
```
34-
using Pardiso
35-
plu=PardisoLU()
36-
Pardiso.set_iparm!(plu.ps,5,13.0)
37-
```
38-
"""
39-
function PardisoLU end
4024

4125
#############################################################################################
4226
mutable struct MKLPardisoLU <: AbstractPardisoLU
@@ -48,31 +32,10 @@ mutable struct MKLPardisoLU <: AbstractPardisoLU
4832
mtype::Union{Int,Nothing}
4933
end
5034

51-
function MKLPardisoLU(; iparm = nothing, mtype = nothing)
35+
function ExtendableSparse.MKLPardisoLU(; iparm = nothing, mtype = nothing)
5236
fact = MKLPardisoLU(nothing, Pardiso.MKLPardisoSolver(), 0,iparm,nothing,mtype)
5337
end
5438

55-
"""
56-
```
57-
MKLPardisoLU(;iparm::Vector, mtype::Int)
58-
59-
MKLPardisoLU(matrix; iparm, mtype)
60-
```
61-
62-
LU factorization based on pardiso. For using this, you need to issue `using Pardiso`.
63-
This version uses the early 2000's fork in Intel's MKL library.
64-
65-
The optional keyword arguments `mtype` and `iparm` are
66-
[Pardiso internal parameters](https://github.com/JuliaSparse/Pardiso.jl#readme).
67-
68-
For setting them you can also access the `PardisoSolver` e.g. like
69-
```
70-
using Pardiso
71-
plu=MKLPardisoLU()
72-
Pardiso.set_iparm!(plu.ps,5,13.0)
73-
```
74-
"""
75-
function MKLPardisoLU end
7639

7740

7841
##########################################################################################
@@ -140,6 +103,9 @@ function LinearAlgebra.ldiv!(fact::AbstractPardisoLU, v::AbstractVector)
140103
end
141104

142105
@eval begin
143-
@makefrommatrix PardisoLU
144-
@makefrommatrix MKLPardisoLU
106+
@makefrommatrix ExtendableSparse.PardisoLU
107+
@makefrommatrix ExtendableSparse.MKLPardisoLU
145108
end
109+
110+
end
111+

0 commit comments

Comments
 (0)