Skip to content

Commit

Permalink
Merge SuiteSparse into SparseArrays to prepare for excision from base (
Browse files Browse the repository at this point in the history
…JuliaSparse#95)

* simple copy of SuiteSparse

* fix uuid

* fix project.toml

* remove one level of modules

* fix tests

* fix doctests
  • Loading branch information
rayegun authored May 30, 2022
1 parent 60d701c commit a15fe4b
Show file tree
Hide file tree
Showing 33 changed files with 47,039 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ name = "SparseArrays"
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
SuiteSparse_jll = "bea87d4a-7f5b-5778-9afe-8cc45184846c"

[extras]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
180 changes: 180 additions & 0 deletions gen/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.8.0-beta3"
manifest_format = "2.0"
project_hash = "61c6ad9feab9227ef7d89383b05c518b03764044"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.1"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.BinaryProvider]]
deps = ["Libdl", "Logging", "SHA"]
git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.10"

[[deps.CEnum]]
git-tree-sha1 = "62847acab40e6855a9b5905ccb99c2b5cf6b3ebb"
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
version = "0.2.0"

[[deps.Clang]]
deps = ["BinaryProvider", "CEnum", "DataStructures", "Libdl"]
git-tree-sha1 = "461757522a8e312a2394efbf83668cef58469ca4"
uuid = "40e3b903-d033-50b4-a0cc-940c62c95e31"
version = "0.9.2"

[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "0.5.2+0"

[[deps.DataStructures]]
deps = ["InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "88d48e133e6d3dd68183309877eac74393daa7eb"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.17.20"

[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
version = "1.6.0"

[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.3"

[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "7.81.0+0"

[[deps.LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.10.2+0"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[deps.Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.0+0"

[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2022.2.1"

[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.20+0"

[[deps.OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.8.0"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[deps.Random]]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[deps.SuiteSparse_jll]]
deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"]
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
version = "5.10.1+0"

[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.0"

[[deps.Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.10.0"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.12+1"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl", "OpenBLAS_jll"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.1.0+0"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.41.0+1"

[[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "16.2.1+1"
3 changes: 3 additions & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
SuiteSparse_jll = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
9 changes: 9 additions & 0 deletions gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# How to auto-generate the wrappers

1. `cd` to this directory
2. run `julia --project generator.jl`, then you could find the updated wrappers in the `lib` folder

## How to upgrade Clang.jl

1. `cd` to this directory
2. run `julia --project` and then in the Julia REPL, run `pkg> up`
56 changes: 56 additions & 0 deletions gen/generator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#! /bin/bash julia --project generator.jl
using Pkg
using Pkg.Artifacts
using Clang.Generators
using Clang.Generators.JLLEnvs
using SuiteSparse_jll

cd(@__DIR__)

# headers
SuiteSparse_toml = joinpath(dirname(pathof(SuiteSparse_jll)), "..", "StdlibArtifacts.toml")
SuiteSparse_dir = Pkg.Artifacts.ensure_artifact_installed("SuiteSparse", SuiteSparse_toml)

include_dir = joinpath(SuiteSparse_dir, "include") |> normpath
cholmod_h = joinpath(include_dir, "cholmod.h")
@assert isfile(cholmod_h)

cholmod_blas_h = joinpath(include_dir, "cholmod_blas.h")
@assert isfile(cholmod_blas_h)

SuiteSparseQR_C_h = joinpath(include_dir, "SuiteSparseQR_C.h")
@assert isfile(SuiteSparseQR_C_h)

umfpack_h = joinpath(include_dir, "umfpack.h")
@assert isfile(umfpack_h)

amd_h = joinpath(include_dir, "amd.h")
@assert isfile(amd_h)

colamd_h = joinpath(include_dir, "colamd.h")
@assert isfile(colamd_h)

ccolamd_h = joinpath(include_dir, "ccolamd.h")
@assert isfile(ccolamd_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"

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

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' -D'SuiteSparse_long_max=9223372036854775801'")
end

header_files = [cholmod_h, cholmod_blas_h, SuiteSparseQR_C_h, amd_h, colamd_h, ccolamd_h, umfpack_h]

ctx = create_context(header_files, args, options)

build!(ctx)
end
51 changes: 51 additions & 0 deletions gen/generator.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[general]
library_name = "libcholmod"
library_names = { "SuiteSparseQR_C.h" = "libspqr", "umfpack.*.h" = "libumfpack", "amd.h" = "libamd", "colamd.h" = "libcolamd", "ccolamd.h" = "libccolamd", "cholmod_camd.h" = "libcholmod"}

use_julia_native_enum_type = true
use_deterministic_symbol = true
auto_mutability = true

output_ignorelist = [
# Clang.jl cannot handle these macro correctly, skip for now.
"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",
]

[codegen]
use_ccall_macro = true

[codegen.macro]
macro_mode = "basic"

functionlike_macro_includelist = [
"SUITESPARSE_VER_CODE",
"CHOLMOD_VER_CODE",
"SPQR_VER_CODE",
"AMD_VERSION_CODE",
"UMFPACK_VER_CODE",
"COLAMD_VERSION_CODE",
"KLU_VERSION_CODE",
"BTF_VERSION_CODE"
]
Loading

0 comments on commit a15fe4b

Please sign in to comment.