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

Use artifact MUMPS_jll #80

Merged
merged 6 commits into from
Aug 19, 2022
Merged
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
50 changes: 50 additions & 0 deletions .github/workflows/ci_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI-Artifacts
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow_failure }}
strategy:
fail-fast: false
matrix:
version: ['1.6', '1']
os: [ubuntu-latest, macOS-latest]
arch: [x64]
allow_failure: [false]
include:
- version: 'nightly'
os: ubuntu-latest
arch: x64
allow_failure: true
- version: 'nightly'
os: macOS-latest
arch: x64
allow_failure: true
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI-Homebrew
on:
push:
branches:
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ version = "1.2.1"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
MUMPS_jll = "ca64183c-ec4f-5579-95d5-17e128c21291"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
MPI = "^0.19"
MUMPS_jll = "= 5.5.1"
julia = "^1.6"

[extras]
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Expand Down
166 changes: 84 additions & 82 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,96 +22,98 @@ if get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") == "true"
write(io, "const libmumps_simple = \"julia_registryci_automerge\"")
end
else
mumps_prefix = "/usr"
scalapack_prefix = "/usr"
add_to_path("MUMPS_PREFIX")
add_to_path("SCALAPACK_PREFIX")
scalapack_libdir = joinpath(scalapack_prefix, "lib")
if haskey(ENV, "MUMPS_PREFIX")
mumps_prefix = "/usr"
scalapack_prefix = "/usr"
add_to_path("MUMPS_PREFIX")
add_to_path("SCALAPACK_PREFIX")
scalapack_libdir = joinpath(scalapack_prefix, "lib")

# look for MUMPS
libsmumps_path = ""
libdmumps_path = ""
libcmumps_path = ""
libzmumps_path = ""
try
libmumps = Libdl.dlopen("libsmumps.$(Libdl.dlext)")
global libsmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libsmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end
try
libmumps = Libdl.dlopen("libdmumps.$(Libdl.dlext)")
global libdmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libdmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end
try
libmumps = Libdl.dlopen("libcmumps.$(Libdl.dlext)")
global libcmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libcmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end
try
libmumps = Libdl.dlopen("libzmumps.$(Libdl.dlext)")
global libzmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libzmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end
# look for MUMPS
libsmumps_path = ""
libdmumps_path = ""
libcmumps_path = ""
libzmumps_path = ""
try
libmumps = Libdl.dlopen("libsmumps.$(Libdl.dlext)")
global libsmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libsmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end
try
libmumps = Libdl.dlopen("libdmumps.$(Libdl.dlext)")
global libdmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libdmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end
try
libmumps = Libdl.dlopen("libcmumps.$(Libdl.dlext)")
global libcmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libcmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end
try
libmumps = Libdl.dlopen("libzmumps.$(Libdl.dlext)")
global libzmumps_path = Libdl.dlpath(libmumps)
catch
error("unable to locate libzmumps.$(Libdl.dlext)... please install MUMPS or set MUMPS_PREFIX")
end

# if we found MUMPS, see if libmumps_simple is there
found_libmumps_simple = false
libmumps_simple_path = ""
try
libmumps_simple = Libdl.dlopen("libmumps_simple.$(Libdl.dlext)")
global found_libmumps_simple = true
global libmumps_simple_path = Libdl.dlpath(libmumps_simple)
Libdl.dlclose(libmumps_simple)
catch
@warn "unable to locate libmumps_simple.$(Libdl.dlext)... will compile from source"
end
# if we found MUMPS, see if libmumps_simple is there
found_libmumps_simple = false
libmumps_simple_path = ""
try
libmumps_simple = Libdl.dlopen("libmumps_simple.$(Libdl.dlext)")
global found_libmumps_simple = true
global libmumps_simple_path = Libdl.dlpath(libmumps_simple)
Libdl.dlclose(libmumps_simple)
catch
@warn "unable to locate libmumps_simple.$(Libdl.dlext)... will compile from source"
end

@info "" found_libmumps_simple libmumps_simple_path
@info "" found_libmumps_simple libmumps_simple_path

# prepare to build libmumps_simple from source
const libmumps_simple_ver = "0.4"
const libmumps_simple_archive = "v$(libmumps_simple_ver).tar.gz"
const libmumps_simple_url = "https://codeload.github.com/dpo/mumps_simple/tar.gz/v$(libmumps_simple_ver)"
const libmumps_simple_sha = "87d1fc87eb04cfa1cba0ca0a18f051b348a93b0b2c2e97279b23994664ee437e"
# prepare to build libmumps_simple from source
const libmumps_simple_ver = "0.4"
const libmumps_simple_archive = "v$(libmumps_simple_ver).tar.gz"
const libmumps_simple_url = "https://codeload.github.com/dpo/mumps_simple/tar.gz/v$(libmumps_simple_ver)"
const libmumps_simple_sha = "87d1fc87eb04cfa1cba0ca0a18f051b348a93b0b2c2e97279b23994664ee437e"

depsdir = @__DIR__
prefix = joinpath(depsdir, "usr")
srcdir = joinpath(depsdir, "src", "mumps_simple-$(libmumps_simple_ver)")
libdir = joinpath(prefix, "lib")
depsdir = @__DIR__
prefix = joinpath(depsdir, "usr")
srcdir = joinpath(depsdir, "src", "mumps_simple-$(libmumps_simple_ver)")
libdir = joinpath(prefix, "lib")

if !found_libmumps_simple
download(libmumps_simple_url, joinpath(depsdir, "src", libmumps_simple_archive))
cd(joinpath(depsdir, "src"))
shasum_observed = bytes2hex(sha256(libmumps_simple_archive))
if shasum_observed != libmumps_simple_sha
error("sha sum mismatch: expected $(libmumps_simple_sha) but got $(shasum_observed)")
if !found_libmumps_simple
download(libmumps_simple_url, joinpath(depsdir, "src", libmumps_simple_archive))
cd(joinpath(depsdir, "src"))
shasum_observed = bytes2hex(sha256(libmumps_simple_archive))
if shasum_observed != libmumps_simple_sha
error("sha sum mismatch: expected $(libmumps_simple_sha) but got $(shasum_observed)")
end
run(`tar zxf $(libmumps_simple_archive)`)
cd("mumps_simple-$(libmumps_simple_ver)")
run(
`make mumps_prefix=$mumps_prefix scalapack_libdir=$scalapack_libdir scalapack_libs= blas_libs=`,
)
run(`make install prefix=$prefix`)
try
libmumps_simple = Libdl.dlopen(joinpath(libdir, "libmumps_simple.$(Libdl.dlext)"))
global libmumps_simple_path = Libdl.dlpath(libmumps_simple)
global found_libmumps_simple = true
catch
@error "unable to open libmumps_simple.$(Libdl.dlext)"
end
end
run(`tar zxf $(libmumps_simple_archive)`)
cd("mumps_simple-$(libmumps_simple_ver)")
run(
`make mumps_prefix=$mumps_prefix scalapack_libdir=$scalapack_libdir scalapack_libs= blas_libs=`,
)
run(`make install prefix=$prefix`)
try
libmumps_simple = Libdl.dlopen(joinpath(libdir, "libmumps_simple.$(Libdl.dlext)"))
global libmumps_simple_path = Libdl.dlpath(libmumps_simple)
global found_libmumps_simple = true
catch
@error "unable to open libmumps_simple.$(Libdl.dlext)"
end
end

if found_libmumps_simple
open(_DEPS_FILE, "w") do io
write(io, "const libmumps_simple = \"$(libmumps_simple_path)\"\n")
write(io, "const libsmumps = \"$(libsmumps_path)\"\n")
write(io, "const libdmumps = \"$(libdmumps_path)\"\n")
write(io, "const libcmumps = \"$(libcmumps_path)\"\n")
write(io, "const libzmumps = \"$(libzmumps_path)\"")
if found_libmumps_simple
open(_DEPS_FILE, "w") do io
write(io, "const libmumps_simple = \"$(libmumps_simple_path)\"\n")
write(io, "const libsmumps = \"$(libsmumps_path)\"\n")
write(io, "const libdmumps = \"$(libdmumps_path)\"\n")
write(io, "const libcmumps = \"$(libcmumps_path)\"\n")
write(io, "const libzmumps = \"$(libzmumps_path)\"")
end
end
end
end
19 changes: 10 additions & 9 deletions src/MUMPS_C-API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ function __init__()
if isfile(_DEPS_FILE)
include(_DEPS_FILE)
else
error("MUMPS library not properly installed. Please run Pkg.build(\"MUMPS\")")
end
if (libmumps_simple == "julia_registryci_automerge")
@error "MUMPS library not properly installed but module is loaded for AutoMerge"
else
global LIB_S = dlopen(libsmumps)
global LIB_D = dlopen(libdmumps)
global LIB_C = dlopen(libcmumps)
global LIB_Z = dlopen(libzmumps)
haskey(ENV, "MUMPS_PREFIX") && error("MUMPS library not properly installed. Please run Pkg.build(\"MUMPS\")")
end
end

if haskey(ENV, "MUMPS_PREFIX")
const libsmumps = joinpath(ENV["MUMPS_PREFIX"], "lib/libsmumps.$dlext")
const libdmumps = joinpath(ENV["MUMPS_PREFIX"], "lib/libdmumps.$dlext")
const libcmumps = joinpath(ENV["MUMPS_PREFIX"], "lib/libcmumps.$dlext")
const libzmumps = joinpath(ENV["MUMPS_PREFIX"], "lib/libzmumps.$dlext")
else
using MUMPS_jll
end

include("mumps_types.jl")
include("mumps_struc.jl")
include("interface.jl")
Expand Down
34 changes: 14 additions & 20 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,21 @@ initialized.

See also: [`invoke_mumps!`](@ref)
"""
@inline function invoke_mumps_unsafe!(mumps::Mumps{TC, TR}) where {TC, TR}
MPI.Initialized() ||
throw(MUMPSException("must call MPI.Init() exactly once before calling mumps"))
if TC == Float32
cfun = :smumps_c
LIB = LIB_S
elseif TC == Float64
cfun = :dmumps_c
LIB = LIB_D
elseif TC == ComplexF32
cfun = :cmumps_c
LIB = LIB_C
elseif TC == ComplexF64
cfun = :zmumps_c
LIB = LIB_Z
invoke_mumps_unsafe!

for (fname, lname, elty, subty) in (("smumps_c", libsmumps, Float32 , Float32),
("dmumps_c", libdmumps, Float64 , Float64),
("cmumps_c", libcmumps, ComplexF32, Float32),
("zmumps_c", libzmumps, ComplexF64, Float64))

@eval begin
function invoke_mumps_unsafe!(mumps :: Mumps{$elty,$subty})
MPI.Initialized() || throw(MUMPSException("must call MPI.Init() exactly once before calling mumps"))
ccall(($fname, $lname), Cvoid, (Ref{Mumps{$elty,$subty}},), mumps)
mumps.err = mumps.infog[1]
return mumps
end
end
sym = dlsym(LIB, cfun)
ccall(sym, Cvoid, (Ref{Mumps{TC, TR}},), mumps)

mumps.err = mumps.infog[1]
return mumps
end

"""
Expand Down