Skip to content

Commit d7f4d81

Browse files
committed
Add MKL_jll and let MKL handle precessor detection
1 parent 995138d commit d7f4d81

File tree

5 files changed

+20
-97
lines changed

5 files changed

+20
-97
lines changed

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ To install IntelVectorMath.jl run
1919
```julia
2020
julia> ] add IntelVectorMath
2121
```
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.
22+
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.
2323

24+
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.
2425
In the event that MKL was not installed properly you will get an error when first `using` it. Please try running
2526
```julia
2627
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/setup.jl

Lines changed: 14 additions & 23 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,16 @@ 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

2920
vml_set_mode((vml_get_mode() & ~0x0000FF00))
3021
function vml_check_error()
31-
vml_error = ccall((:_vmlClearErrStatus, libmkl_vml_avx), Cint, ())
22+
vml_error = ccall((:vmlClearErrStatus, MKL_jll.libmkl_rt), Cint, ())
3223
if vml_error != 0
3324
if vml_error == 1
3425
throw(DomainError(-1, "This function does not support arguments outside its domain"))
@@ -45,13 +36,13 @@ end
4536

4637
function vml_prefix(t::DataType)
4738
if t == Float32
48-
return "_vmls"
39+
return "vs"
4940
elseif t == Float64
50-
return "_vmld"
41+
return "vd"
5142
elseif t == Complex{Float32}
52-
return "_vmlc"
43+
return "vc"
5344
elseif t == Complex{Float64}
54-
return "_vmlz"
45+
return "vz"
5546
end
5647
error("unknown type $t")
5748
end
@@ -65,22 +56,22 @@ function def_unary_op(tin, tout, jlname, jlname!, mklname;
6556
@eval begin
6657
function ($jlname!)(out::Array{$tout,N}, A::Array{$tin,N}) where {N}
6758
size(out) == size(A) || throw(DimensionMismatch())
68-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
59+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
6960
vml_check_error()
7061
return out
7162
end
7263
$(if tin == tout
7364
quote
7465
function $(jlname!)(A::Array{$tin})
75-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, A)
66+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, A)
7667
vml_check_error()
7768
return A
7869
end
7970
end
8071
end)
8172
function ($jlname)(A::Array{$tin})
8273
out = similar(A, $tout)
83-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
74+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tout}), length(A), A, out)
8475
vml_check_error()
8576
return out
8677
end
@@ -97,14 +88,14 @@ function def_binary_op(tin, tout, jlname, jlname!, mklname, broadcast)
9788
$(isempty(exports) ? nothing : Expr(:export, exports...))
9889
function ($jlname!)(out::Array{$tout,N}, A::Array{$tin,N}, B::Array{$tin,N}) where {N}
9990
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)
91+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tin}, Ptr{$tout}), length(A), A, B, out)
10192
vml_check_error()
10293
return out
10394
end
10495
function ($jlname)(A::Array{$tout,N}, B::Array{$tin,N}) where {N}
10596
size(A) == size(B) || $(broadcast ? :(return broadcast($jlname, A, B)) : :(throw(DimensionMismatch())))
10697
out = similar(A)
107-
ccall(($mklfn, libmkl_vml_avx), Nothing, (Int, Ptr{$tin}, Ptr{$tin}, Ptr{$tout}), length(A), A, B, out)
98+
ccall(($mklfn, MKL_jll.libmkl_rt), Nothing, (Int, Ptr{$tin}, Ptr{$tin}, Ptr{$tout}), length(A), A, B, out)
10899
vml_check_error()
109100
return out
110101
end

0 commit comments

Comments
 (0)