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

Parallel #33

Closed
wants to merge 9 commits into from
Closed
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: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name = "ExtendableSparse"
uuid = "95c220a8-a1cf-11e9-0c77-dbfce5f500b3"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>"]
version = "1.4"
version = "1.4.0"

[deps]
AMGCLWrap = "4f76b812-4ba5-496d-b042-d70715554288"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
ExtendableGrids = "cfc395e8-590f-11e8-1f13-43a2532b2fa8"
ILUZero = "88f59080-6952-5380-9ea5-54057fb9a43f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Metis = "2679e427-3c69-5b7f-982b-ece356f1e94b"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand Down
40 changes: 30 additions & 10 deletions src/ExtendableSparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ using LinearAlgebra
using Sparspak
using ILUZero

using Metis
using Base.Threads
using ExtendableGrids

if !isdefined(Base, :get_extension)
using Requires
end
Expand All @@ -16,7 +20,6 @@ if USE_GPL_LIBS
using SuiteSparse
end


using DocStringExtensions

import SparseArrays: AbstractSparseMatrixCSC, rowvals, getcolptr, nonzeros
Expand All @@ -25,16 +28,40 @@ include("matrix/sparsematrixcsc.jl")
include("matrix/sparsematrixlnk.jl")
include("matrix/extendable.jl")

export SparseMatrixLNK,
ExtendableSparseMatrix, flush!, nnz, updateindex!, rawupdateindex!, colptrs, sparse
export SparseMatrixLNK, ExtendableSparseMatrix, flush!, nnz, updateindex!, rawupdateindex!, colptrs, sparse

export eliminate_dirichlet, eliminate_dirichlet!, mark_dirichlet


#@warn "ESMP!"
include("matrix/ExtendableSparseMatrixParallel/ExtendableSparseParallel.jl")



include("factorizations/ilu_Al-Kurdi_Mittal.jl")
#using .ILUAM
include("factorizations/pilu_Al-Kurdi_Mittal.jl")
#using .PILUAM
include("factorizations/factorizations.jl")

include("factorizations/simple_iteration.jl")
export simple, simple!

include("matrix/sprand.jl")
export sprand!, sprand_sdd!, fdrand, fdrand!, fdrand_coo, solverbenchmark




export ExtendableSparseMatrixParallel, SuperSparseMatrixLNK
export addtoentry!, reset!, dummy_assembly!, preparatory_multi_ps_less_reverse, fr, addtoentry!, rawupdateindex!, updateindex!, compare_matrices_light


export JacobiPreconditioner,
ILU0Preconditioner,
ILUZeroPreconditioner,
ILUAMPreconditioner,
PILUAMPreconditioner,
PointBlockILUZeroPreconditioner,
ParallelJacobiPreconditioner,
ParallelILU0Preconditioner,
Expand All @@ -45,13 +72,6 @@ export AbstractFactorization, LUFactorization, CholeskyFactorization, SparspakLU
export issolver
export factorize!, update!

include("factorizations/simple_iteration.jl")
export simple, simple!

include("matrix/sprand.jl")
export sprand!, sprand_sdd!, fdrand, fdrand!, fdrand_coo, solverbenchmark


@static if !isdefined(Base, :get_extension)
function __init__()
@require Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2" begin
Expand Down
117 changes: 78 additions & 39 deletions src/factorizations/factorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,52 @@ Determine if factorization is a solver or not
issolver(::AbstractLUFactorization) = true
issolver(::AbstractPreconditioner) = false



""""
@makefrommatrix(fact)

For an AbstractFactorization `MyFact`, provide methods
```
MyFact(A::ExtendableSparseMatrix; kwargs...)
MyFact(A::SparseMatrixCSC; kwargs...)
```
"""
macro makefrommatrix(fact)
return quote
function $(esc(fact))(A::ExtendableSparseMatrix; kwargs...)
factorize!($(esc(fact))(;kwargs...), A)
end
function $(esc(fact))(A::SparseMatrixCSC; kwargs...)
$(esc(fact))(ExtendableSparseMatrix(A); kwargs...)
end
end
end

include("ilu0.jl")
include("iluzero.jl")
include("iluam.jl")
include("piluam.jl")
include("parallel_jacobi.jl")
include("parallel_ilu0.jl")
include("sparspak.jl")
include("blockpreconditioner.jl")
include("jacobi.jl")

@eval begin
@makefrommatrix ILU0Preconditioner
@makefrommatrix ILUZeroPreconditioner
@makefrommatrix ILUAMPreconditioner
@makefrommatrix PILUAMPreconditioner
@makefrommatrix PointBlockILUZeroPreconditioner
@makefrommatrix JacobiPreconditioner
@makefrommatrix ParallelJacobiPreconditioner
@makefrommatrix ParallelILU0Preconditioner
@makefrommatrix SparspakLU
@makefrommatrix UpdateteableBlockpreconditioner
@makefrommatrix BlockPreconditioner
end

"""
```
factorize!(factorization, matrix)
Expand All @@ -65,8 +111,40 @@ function factorize!(p::AbstractFactorization, A::ExtendableSparseMatrix)
p
end

function factorize!(p::PILUAMPreconditioner, A::ExtendableSparseMatrixParallel)
p.A = A
update!(p)
p
end

#function factorize!(p::AbstractFactorization, A::ExtendableSparseMatrixParallel)
# p.A = A
# update!(p)
# p
#end

#factorize!(p::AbstractFactorization, A::ExtendableSparseMatrixParallel)=factorize!(p,ExtendableSparseMatrix(A.cscmatrix))

#factorize!(p::PILUAMPrecon, A::ExtendableSparseMatrixParallel)=factorize!(p,ExtendableSparseMatrix(A.cscmatrix))

factorize!(p::AbstractFactorization, A::SparseMatrixCSC)=factorize!(p,ExtendableSparseMatrix(A))

#function factorize!(p::PILUAMPrecon, A::ExtendableSparseMatrixParallel)
# factorize!(p, A)
#end

#function factorize!(p::AbstractFactorization, A::ExtendableSparseMatrixParallel)
# factorize!(p, A.cscmatrix)
#end


#function factorize!(p::AbstractFactorization, A::ExtendableSparseMatrix)
# factorize!(p, A.cscmatrix)
#end


#factorize!(p::PILUAMPrecon, A::ExtendableSparseMatrixParallel)=factorize!(p,A)

"""
```
lu!(factorization, matrix)
Expand Down Expand Up @@ -134,45 +212,6 @@ LinearAlgebra.ldiv!(fact::AbstractFactorization, v) = ldiv!(fact.factorization,



""""
@makefrommatrix(fact)

For an AbstractFactorization `MyFact`, provide methods
```
MyFact(A::ExtendableSparseMatrix; kwargs...)
MyFact(A::SparseMatrixCSC; kwargs...)
```
"""
macro makefrommatrix(fact)
return quote
function $(esc(fact))(A::ExtendableSparseMatrix; kwargs...)
factorize!($(esc(fact))(;kwargs...), A)
end
function $(esc(fact))(A::SparseMatrixCSC; kwargs...)
$(esc(fact))(ExtendableSparseMatrix(A); kwargs...)
end
end
end

include("jacobi.jl")
include("ilu0.jl")
include("iluzero.jl")
include("parallel_jacobi.jl")
include("parallel_ilu0.jl")
include("sparspak.jl")
include("blockpreconditioner.jl")

@eval begin
@makefrommatrix ILU0Preconditioner
@makefrommatrix ILUZeroPreconditioner
@makefrommatrix PointBlockILUZeroPreconditioner
@makefrommatrix JacobiPreconditioner
@makefrommatrix ParallelJacobiPreconditioner
@makefrommatrix ParallelILU0Preconditioner
@makefrommatrix SparspakLU
@makefrommatrix UpdateteableBlockpreconditioner
@makefrommatrix BlockPreconditioner
end

if USE_GPL_LIBS
#requires SuiteSparse which is not available in non-GPL builds
Expand Down
Loading
Loading