Skip to content

Commit

Permalink
Update to latest SuiteSparse and auto-generate wrappers (#18)
Browse files Browse the repository at this point in the history
* Update clang generator
* Remove klu_lib.jl and use auto-generated wrappers.jl
* Only works on 1.10 - since it has to be synced with SuiteSparse
* Update docs/make.jl
* Update CI matrix to test only on 1.10 and introduce all platforms
  • Loading branch information
ViralBShah authored Feb 9, 2024
1 parent aee5644 commit 5162d1f
Show file tree
Hide file tree
Showing 23 changed files with 937 additions and 6,504 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- '1.10'
os:
- ubuntu-latest
- windows-latest
- macos-latest
arch:
- x64
include:
- os: ubuntu-latest
- x86
exclude:
- os: macos-latest
arch: x86
version: 1
- os: windows-latest
arch: x86
version: 1
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "KLU"
uuid = "ef3ab10e-7fda-4108-b977-705223b18434"
authors = ["Wimmerer <[email protected]> and contributors"]
version = "0.4.1"
version = "0.5.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SuiteSparse_jll = "bea87d4a-7f5b-5778-9afe-8cc45184846c"

[compat]
julia = "1.6"
julia = "1.10"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
5 changes: 3 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ using KLU
makedocs(
sitename = "KLU",
format = Documenter.HTML(),
modules = [KLU]
modules = [KLU];
warnonly = [:missing_docs, :cross_references],
)

# Documenter can also automatically deploy documentation to gh-pages.
# See "Hosting Documentation" and deploydocs() in the Documenter manual
# for more information.
deploydocs(
repo = "github.com/Wimmerer/KLU.jl.git",
repo = "github.com/JuliaSparse/KLU.jl.git",
devbranch="main"
)
6 changes: 5 additions & 1 deletion gen/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
SuiteSparse_jll = "bea87d4a-7f5b-5778-9afe-8cc45184846c"

[compat]
Clang = "0.17"
38 changes: 7 additions & 31 deletions gen/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,13 @@ klu_h = joinpath(include_dir, "klu.h")
# load common option
options = load_options(joinpath(@__DIR__, "generator.toml"))

# run generator for all platforms
for target in JLLEnvs.JLL_ENV_TRIPLES
@info "processing $target"
# run generator. Header files are not platform specific so we have only one.
options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "src", "wrappers.jl")
args = get_default_args()
push!(args, "-I$include_dir")

options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "lib", "$target.jl")
header_files = [klu_h]

args = get_default_args(target)
push!(args, "-I$include_dir")
if startswith(target, "x86_64") || startswith(target, "powerpc64le") || startswith(target, "aarch64")
push!(args, "-DSUN64 -DLONGBLAS='long long'")
end
ctx = create_context(header_files, args, options)

header_files = [klu_h]

ctx = create_context(header_files, args, options)

build!(ctx, BUILDSTAGE_NO_PRINTING)

# custom rewriter
function rewrite!(dag::ExprDAG)
replace!(get_nodes(dag)) do node
filename = normpath(Clang.get_filename(node.cursor))
if !contains(filename, "klu")
return ExprNode(node.id, Generators.Skip(), node.cursor, Expr[], node.adj)
end
return node
end
end

rewrite!(ctx.dag)

# print
build!(ctx, BUILDSTAGE_PRINTING_ONLY)
end
build!(ctx)
70 changes: 64 additions & 6 deletions gen/generator.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,80 @@
[general]
library_name = "libklu"
library_names = {"SuiteSparse_config.h" = "libsuitesparseconfig", "klu.h" = "libklu", "amd.h" = "libamd", "btf.h" = "libbtf"}

use_julia_native_enum_type = true
use_deterministic_symbol = true
auto_mutability = true

printer_blacklist = [
output_ignorelist = [
# Clang.jl cannot handle these macro correctly, skip for now.
"SuiteSparse_long_id"
"UMFPACK_COPYRIGHT",
"UMFPACK_LICENSE_PART1",
"UMFPACK_LICENSE_PART2",
"UMFPACK_LICENSE_PART3",
"SuiteSparse_long",
"SuiteSparse_long_max",
"SuiteSparse_long_id",
"CHOLMOD_CUBLAS_HANDLE",
"CHOLMOD_CUDASTREAM",
"CHOLMOD_CUDAEVENT",
# useless macros
"CHOLMOD_CPU_GEMM_CALLS",
"CHOLMOD_CPU_SYRK_CALLS",
"CHOLMOD_CPU_TRSM_CALLS",
"CHOLMOD_CPU_POTRF_CALLS",
"CHOLMOD_GPU_GEMM_CALLS",
"CHOLMOD_GPU_SYRK_CALLS",
"CHOLMOD_GPU_TRSM_CALLS",
"CHOLMOD_GPU_POTRF_CALLS",
"CHOLMOD_CPU_GEMM_TIME",
"CHOLMOD_CPU_SYRK_TIME",
"CHOLMOD_CPU_TRSM_TIME",
"CHOLMOD_CPU_POTRF_TIME",
"CHOLMOD_GPU_GEMM_TIME",
"CHOLMOD_GPU_SYRK_TIME",
"CHOLMOD_GPU_TRSM_TIME",
"CHOLMOD_GPU_POTRF_TIME",
"CHOLMOD_ASSEMBLE_TIME",
"CHOLMOD_ASSEMBLE_TIME2",
"SuiteSparse_long_idd",
"SUITESPARSE_COMPILER_MAJOR",
"SUITESPARSE_COMPILER_MINOR",
"SUITESPARSE_COMPILER_SUB",
"SUITESPARSE_COMPILER_NAME",
"SUITESPARSE_STDC_VERSION",
"SUITESPARSE_RESTRICT",
"SUITESPARSE_LAPACK_[A-Z0-9]+",
"SUITESPARSE_BLAS_[A-Z0-9]+",
"SUITESPARSE_BLAS_DNRM2",
"SUITESPARSE_BLAS_DZNRM2",
"UMFPACK_VERSION",
]

[codegen]
use_ccall_macro = true
use_ccall_macro = false

[codegen.macro]
macro_mode = "basic"

functionlike_macro_whitelist = [
functionlike_macro_includelist = [
"SUITESPARSE_VER_CODE",
"KLU_VERSION_CODE"
"SUITESPARSE__VERCODE",
"CHOLMOD_VER_CODE",
"CHOLMOD__VERCODE",
"SPQR_VER_CODE",
"SPQR__VERCODE",
"AMD_VERSION_CODE",
"AMD__VERCODE",
"UMFPACK_VER_CODE",
"UMFPACK__VERCODE",
"COLAMD_VERSION_CODE",
"COLAMD__VERCODE",
"KLU_VERSION_CODE",
"KLU__VERCODE",
"BTF_VERSION_CODE",
"BTF__VERCODE",
"CCOLAMD_VERSION_CODE",
"CCOLAMD__VERCODE",
"KLU_VERSION_CODE",
"KLU__VERCODE",
]
Loading

0 comments on commit 5162d1f

Please sign in to comment.