Skip to content

Commit dd2732d

Browse files
authored
Merge pull request #39 from JuliaMath/artifact
Adding MKL_jll artifact
2 parents 995138d + 1b33574 commit dd2732d

File tree

10 files changed

+60
-113
lines changed

10 files changed

+60
-113
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: julia 1.0/1.3
1+
name: julia 1.3
22
on:
33
push:
44
branches:
@@ -13,7 +13,6 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
version:
16-
- '1.0'
1716
- '1.3'
1817
os:
1918
- ubuntu-latest

Project.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
name = "IntelVectorMath"
22
uuid = "c8ce9da6-5d36-5c03-b118-5a70151be7bc"
3-
version = "0.3.1"
3+
version = "0.4.0"
44

55
[deps]
6-
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
7-
CpuId = "adafc99b-e345-5852-983c-f28acb93d879"
8-
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
6+
MKL_jll = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
97

108
[compat]
11-
BinaryProvider = "0.5.8"
12-
CpuId = "0.2"
13-
julia = "0.7, 1.0"
9+
julia = "1.3"
10+
MKL_jll = "2020"
1411

1512
[extras]
1613
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[pkgeval-url]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/report.html
55

66
[![PkgEval][pkgeval-img]][pkgeval-url]
7-
![](https://github.com/JuliaMath/VML.jl/workflows/julia%201.0/1.3/badge.svg)
7+
![](https://github.com/JuliaMath/VML.jl/workflows/julia%201.3/badge.svg)
88
![](https://github.com/JuliaMath/VML.jl/workflows/julia%20nightly/badge.svg)
99

1010
This package provides bindings to the Intel MKL [Vector Mathematics Functions](https://software.intel.com/en-us/node/521751).
@@ -13,14 +13,18 @@ Until Julia 0.6 the package was registered as `VML.jl`.
1313

1414
Similar packages are [Yeppp.jl](https://github.com/JuliaMath/Yeppp.jl), which wraps the open source Yeppp library, and [AppleAccelerate.jl](https://github.com/JuliaMath/AppleAccelerate.jl), which provides access to macOS's Accelerate framework.
1515

16+
### Warning for macOS
17+
There is currently [the following](https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/700) issue between the `CompilerSupportLibraries_jll` artifact, which is used for example by `SpecialFunctions.jl`, and `MKL_jll`. Unless `MKL_jll` is loaded first, there might be wrong results coming from a small number of function for particular input array lengths. If you are unsure which, if any, your used packages might load this artifact, loading `IntelVectorMath` as the very first package should be fine.
18+
1619
## Basic install
1720

1821
To install IntelVectorMath.jl run
1922
```julia
2023
julia> ] add IntelVectorMath
2124
```
22-
Since version 0.3 IntelVectorMath downloads its own version of MKL and keeps only the required files in its own directory. As such installing MKL.jl or MKL via intel are no longer required, and may mean some duplicate files if they are present. However, this package will adopt the new artifact system in the next minor version update and fix this issue.
25+
Since version 0.4 `IntelVectorMath` uses the `MKL_jll` artifact, which is shared with other packages uses MKL, removing several other dependencies. This has the side effect that from version 0.4 onwards this package requires at least Julia 1.3.
2326

27+
For older versions of Julia `IntelVectorMath v0.3` downloads its own version of MKL and keeps only the required files in its own directory. As such installing MKL.jl or MKL via intel are no longer required, and may mean some duplicate files if they are present. However, this package will adopt the new artifact system in the next minor version update and fix this issue.
2428
In the event that MKL was not installed properly you will get an error when first `using` it. Please try running
2529
```julia
2630
julia> ] build IntelVectorMath

deps/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

deps/build.jl

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/IntelVectorMath.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ export IVM
66
const IVM = IntelVectorMath
77

88
# import Base: .^, ./
9-
# using Libdl
10-
include("../deps/deps.jl")
11-
129
include("setup.jl")
1310

11+
function __init__()
12+
compilersupportlibaries_jll_uuid = Base.UUID("e66e0078-7015-5450-92f7-15fbd957f2ae")
13+
if Sys.isapple() && haskey(Base.loaded_modules, Base.PkgId(compilersupportlibaries_jll_uuid, "CompilerSupportLibraries_jll"))
14+
@warn "It appears CompilerSupportLibraries_jll was loaded prior to this package, which currently on mac may lead to wrong results in some cases. For further details see github.com/JuliaMath/IntelVectorMath.jl"
15+
end
16+
end
17+
1418
for t in (Float32, Float64, ComplexF32, ComplexF64)
1519
# Unary, real or complex
1620
def_unary_op(t, t, :acos, :acos!, :Acos)

src/setup.jl

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
2-
function __init__()
3-
check_deps()
4-
5-
Libdl.dlopen(libmkl_core, Libdl.RTLD_GLOBAL)
6-
Libdl.dlopen(libmkl_rt, Libdl.RTLD_GLOBAL) # maybe only needed on mac
7-
Libdl.dlopen(libmkl_vml_avx, Libdl.RTLD_GLOBAL)
8-
9-
end
10-
11-
__init__()
1+
import MKL_jll
122

133
struct VMLAccuracy
144
mode::UInt
@@ -20,15 +10,15 @@ const VML_EP = VMLAccuracy(0x00000003)
2010

2111
Base.show(io::IO, m::VMLAccuracy) = print(io, m == VML_LA ? "VML_LA" :
2212
m == VML_HA ? "VML_HA" : "VML_EP")
23-
vml_get_mode() = ccall((:_vmlGetMode, libmkl_vml_avx), Cuint, ())
24-
vml_set_mode(mode::Integer) = (ccall((:_vmlSetMode, libmkl_vml_avx), Cuint, (UInt,), mode); nothing)
13+
14+
vml_get_mode() = ccall((:vmlGetMode, MKL_jll.libmkl_rt), Cuint, ())
15+
vml_set_mode(mode::Integer) = (ccall((:vmlSetMode, MKL_jll.libmkl_rt), Cuint, (UInt,), mode); nothing)
2516

2617
vml_set_accuracy(m::VMLAccuracy) = vml_set_mode((vml_get_mode() & ~0x03) | m.mode)
2718
vml_get_accuracy() = VMLAccuracy(vml_get_mode() & 0x3)
2819

29-
vml_set_mode((vml_get_mode() & ~0x0000FF00))
3020
function vml_check_error()
31-
vml_error = ccall((:_vmlClearErrStatus, libmkl_vml_avx), Cint, ())
21+
vml_error = ccall((:vmlClearErrStatus, MKL_jll.libmkl_rt), Cint, ())
3222
if vml_error != 0
3323
if vml_error == 1
3424
throw(DomainError(-1, "This function does not support arguments outside its domain"))
@@ -45,13 +35,13 @@ end
4535

4636
function vml_prefix(t::DataType)
4737
if t == Float32
48-
return "_vmls"
38+
return "vs"
4939
elseif t == Float64
50-
return "_vmld"
40+
return "vd"
5141
elseif t == Complex{Float32}
52-
return "_vmlc"
42+
return "vc"
5343
elseif t == Complex{Float64}
54-
return "_vmlz"
44+
return "vz"
5545
end
5646
error("unknown type $t")
5747
end
@@ -63,24 +53,24 @@ function def_unary_op(tin, tout, jlname, jlname!, mklname;
6353
(@isdefined jlname) || push!(exports, jlname)
6454
(@isdefined jlname!) || push!(exports, jlname!)
6555
@eval begin
66-
function ($jlname!)(out::Array{$tout,N}, A::Array{$tin,N}) where {N}
56+
function ($jlname!)(out::Array{$tout}, A::Array{$tin})
6757
size(out) == size(A) || throw(DimensionMismatch())
68-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
58+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
6959
vml_check_error()
7060
return out
7161
end
7262
$(if tin == tout
7363
quote
7464
function $(jlname!)(A::Array{$tin})
75-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, A)
65+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, A)
7666
vml_check_error()
7767
return A
7868
end
7969
end
8070
end)
8171
function ($jlname)(A::Array{$tin})
8272
out = similar(A, $tout)
83-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
73+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
8474
vml_check_error()
8575
return out
8676
end
@@ -95,16 +85,16 @@ function def_binary_op(tin, tout, jlname, jlname!, mklname, broadcast)
9585
(@isdefined jlname!) || push!(exports, jlname!)
9686
@eval begin
9787
$(isempty(exports) ? nothing : Expr(:export, exports...))
98-
function ($jlname!)(out::Array{$tout,N}, A::Array{$tin,N}, B::Array{$tin,N}) where {N}
99-
size(out) == size(A) == size(B) || $(broadcast ? :(return broadcast!($jlname, out, A, B)) : :(throw(DimensionMismatch())))
100-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tin}, Ptr{$tout}), length(A), A, B, out)
88+
function ($jlname!)(out::Array{$tout}, A::Array{$tin}, B::Array{$tin})
89+
size(out) == size(A) == size(B) || throw(DimensionMismatch("Input arrays and output array need to have the same size"))
90+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tin}, Ptr{$tout}), length(A), A, B, out)
10191
vml_check_error()
10292
return out
10393
end
104-
function ($jlname)(A::Array{$tout,N}, B::Array{$tin,N}) where {N}
105-
size(A) == size(B) || $(broadcast ? :(return broadcast($jlname, A, B)) : :(throw(DimensionMismatch())))
94+
function ($jlname)(A::Array{$tout}, B::Array{$tin})
95+
size(A) == size(B) || throw(DimensionMismatch("Input arrays need to have the same size"))
10696
out = similar(A)
107-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tin}, Ptr{$tout}), length(A), A, B, out)
97+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tin}, Ptr{$tout}), length(A), A, B, out)
10898
vml_check_error()
10999
return out
110100
end

test/Manifest.toml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
[[Base64]]
44
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
55

6+
[[CompilerSupportLibraries_jll]]
7+
deps = ["Libdl", "Pkg"]
8+
git-tree-sha1 = "b57c5d019367c90f234a7bc7e24ff0a84971da5d"
9+
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
10+
version = "0.2.0+1"
11+
612
[[CpuId]]
713
deps = ["Markdown", "Test"]
814
git-tree-sha1 = "f0464e499ab9973b43c20f8216d088b61fda80c6"
@@ -17,6 +23,12 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
1723
deps = ["Random", "Serialization", "Sockets"]
1824
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1925

26+
[[IntelOpenMP_jll]]
27+
deps = ["Libdl", "Pkg"]
28+
git-tree-sha1 = "fb8e1c7a5594ba56f9011310790e03b5384998d6"
29+
uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0"
30+
version = "2018.0.3+0"
31+
2032
[[InteractiveUtils]]
2133
deps = ["Markdown"]
2234
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
@@ -30,15 +42,21 @@ uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
3042
[[Logging]]
3143
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
3244

45+
[[MKL_jll]]
46+
deps = ["IntelOpenMP_jll", "Libdl", "Pkg"]
47+
git-tree-sha1 = "7f7034f27491a8bb955a9e4097e4fb5c2167bda5"
48+
uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
49+
version = "2020.0.166+0"
50+
3351
[[Markdown]]
3452
deps = ["Base64"]
3553
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
3654

3755
[[OpenSpecFun_jll]]
38-
deps = ["Libdl", "Pkg"]
39-
git-tree-sha1 = "65f672edebf3f4e613ddf37db9dcbd7a407e5e90"
56+
deps = ["CompilerSupportLibraries_jll", "Libdl", "Pkg"]
57+
git-tree-sha1 = "d110040968b9afe95c6bd9c6233570b0fe8abd22"
4058
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
41-
version = "0.5.3+1"
59+
version = "0.5.3+2"
4260

4361
[[Pkg]]
4462
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"]

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[deps]
22
CpuId = "adafc99b-e345-5852-983c-f28acb93d879"
3-
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
3+
MKL_jll = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
44
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
55
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import MKL_jll
12
using Test
23
using IntelVectorMath
34

0 commit comments

Comments
 (0)