Skip to content

Commit aa9d3a7

Browse files
authored
Merge pull request #36 from JuliaMath/dev
Adding BinaryProvider and tests for mutating functions
2 parents 58e8c11 + 2601f07 commit aa9d3a7

File tree

10 files changed

+176
-147
lines changed

10 files changed

+176
-147
lines changed

.github/workflows/main.yml

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
os:
1919
- ubuntu-latest
2020
- macOS-latest
21-
# - windows-latest
21+
- windows-latest
2222
arch:
2323
- x64
2424
steps:
@@ -27,40 +27,36 @@ jobs:
2727
with:
2828
version: ${{ matrix.version }}
2929
arch: ${{ matrix.arch }}
30-
- run: julia --color=yes --project -e 'using Pkg; Pkg.add(PackageSpec(url=\"https://github.com/JuliaComputing/MKL.jl\")); Pkg.instantiate()'
31-
if: matrix.os == 'windows-latest'
32-
- run: julia --color=yes --project -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/JuliaComputing/MKL.jl")); Pkg.instantiate()'
33-
if: matrix.os != 'windows-latest'
3430
- uses: julia-actions/julia-buildpkg@latest
3531
- uses: julia-actions/julia-runtest@latest
3632

37-
testAptMKL:
38-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
39-
runs-on: ${{ matrix.os }}
40-
strategy:
41-
matrix:
42-
version:
43-
- '1.0'
44-
- '1.3'
45-
os:
46-
- ubuntu-latest
47-
arch:
48-
- x64
49-
env:
50-
LD_LIBRARY_PATH: /opt/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64_lin/
51-
steps:
52-
- name: Install MKL via apt
53-
run: |
54-
curl https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB > GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
55-
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
56-
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
57-
sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list'
58-
sudo apt-get update
59-
sudo apt-get install -y intel-mkl-64bit-2019.4-070
60-
- uses: actions/checkout@v2
61-
- uses: julia-actions/setup-julia@latest
62-
with:
63-
version: ${{ matrix.version }}
64-
arch: ${{ matrix.arch }}
65-
- uses: julia-actions/julia-buildpkg@latest
66-
- uses: julia-actions/julia-runtest@latest
33+
# testAptMKL:
34+
# name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
35+
# runs-on: ${{ matrix.os }}
36+
# strategy:
37+
# matrix:
38+
# version:
39+
# - '1.0'
40+
# - '1.3'
41+
# os:
42+
# - ubuntu-latest
43+
# arch:
44+
# - x64
45+
# env:
46+
# LD_LIBRARY_PATH: /opt/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64_lin/
47+
# steps:
48+
# - name: Install MKL via apt
49+
# run: |
50+
# curl https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB > GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
51+
# sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
52+
# rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
53+
# sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list'
54+
# sudo apt-get update
55+
# sudo apt-get install -y intel-mkl-64bit-2019.4-070
56+
# - uses: actions/checkout@v2
57+
# - uses: julia-actions/setup-julia@latest
58+
# with:
59+
# version: ${{ matrix.version }}
60+
# arch: ${{ matrix.arch }}
61+
# - uses: julia-actions/julia-buildpkg@latest
62+
# - uses: julia-actions/julia-runtest@latest

.github/workflows/nightly.yml

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
os:
2020
- ubuntu-latest
2121
- macOS-latest
22-
# - windows-latest
22+
- windows-latest
2323
arch:
2424
- x64
2525
steps:
@@ -28,40 +28,36 @@ jobs:
2828
with:
2929
version: ${{ matrix.version }}
3030
arch: ${{ matrix.arch }}
31-
- run: julia --color=yes --project -e 'using Pkg; Pkg.add(PackageSpec(url=\"https://github.com/JuliaComputing/MKL.jl\")); Pkg.instantiate()'
32-
if: matrix.os == 'windows-latest'
33-
- run: julia --color=yes --project -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/JuliaComputing/MKL.jl")); Pkg.instantiate()'
34-
if: matrix.os != 'windows-latest'
3531
- uses: julia-actions/julia-buildpkg@latest
3632
- uses: julia-actions/julia-runtest@latest
3733

38-
testAptMKL:
39-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
40-
runs-on: ${{ matrix.os }}
41-
strategy:
42-
matrix:
43-
version:
44-
- 'nightly'
45-
os:
46-
- ubuntu-latest
47-
arch:
48-
- x64
49-
env:
50-
LD_LIBRARY_PATH: /opt/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64_lin/
51-
steps:
52-
- name: Install MKL via apt
53-
run: |
54-
curl https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB > GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
55-
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
56-
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
57-
sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list'
58-
sudo apt-get update
59-
sudo apt-get install -y intel-mkl-64bit-2019.4-070
60-
source /opt/intel/mkl/bin/mklvars.sh intel64
61-
- uses: actions/checkout@v2
62-
- uses: julia-actions/setup-julia@latest
63-
with:
64-
version: ${{ matrix.version }}
65-
arch: ${{ matrix.arch }}
66-
- uses: julia-actions/julia-buildpkg@latest
67-
- uses: julia-actions/julia-runtest@latest
34+
# testAptMKL:
35+
# name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
36+
# runs-on: ${{ matrix.os }}
37+
# strategy:
38+
# matrix:
39+
# version:
40+
# - 'nightly'
41+
# os:
42+
# - ubuntu-latest
43+
# arch:
44+
# - x64
45+
# env:
46+
# LD_LIBRARY_PATH: /opt/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64_lin/
47+
# steps:
48+
# - name: Install MKL via apt
49+
# run: |
50+
# curl https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB > GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
51+
# sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
52+
# rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
53+
# sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list'
54+
# sudo apt-get update
55+
# sudo apt-get install -y intel-mkl-64bit-2019.4-070
56+
# source /opt/intel/mkl/bin/mklvars.sh intel64
57+
# - uses: actions/checkout@v2
58+
# - uses: julia-actions/setup-julia@latest
59+
# with:
60+
# version: ${{ matrix.version }}
61+
# arch: ${{ matrix.arch }}
62+
# - uses: julia-actions/julia-buildpkg@latest
63+
# - uses: julia-actions/julia-runtest@latest

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
name = "IntelVectorMath"
22
uuid = "c8ce9da6-5d36-5c03-b118-5a70151be7bc"
3-
version = "0.2.1"
3+
version = "0.3"
44

55
[deps]
6+
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
67
CpuId = "adafc99b-e345-5852-983c-f28acb93d879"
78
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
89
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
910

1011
[compat]
11-
julia = "0.7, 1.0"
1212
CpuId = "0.2"
1313
SpecialFunctions = "0.8, 0.9, 0.10"
14+
julia = "0.7, 1.0"
1415

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

README.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,20 @@ Similar packages are [Yeppp.jl](https://github.com/JuliaMath/Yeppp.jl), which wr
1010

1111
## Basic install
1212

13-
To use IntelVectorMath.jl, you must have the shared libraries of the Intel Vector Math Library available on your system, for which you currently have two options:
14-
15-
### 1. MKL.jl
16-
The easiest option is to use [MKL.jl](https://github.com/JuliaComputing/MKL.jl) via
13+
To install IntelVectorMath.jl run
1714
```julia
18-
julia> ] add https://github.com/JuliaComputing/MKL.jl.git
15+
julia> ] add IntelVectorMath
1916
```
20-
#### Note:
21-
This will overwrite your julia sysimage to use MKL instead of OpenBLAS which could break compatability with certain packages and is difficult to reverse without reinstalling julia from scratch. In addition, MKL.jl is currently broken on Windows, so you can only use the following option. Please see the MKL.jl repository for more information.
22-
23-
### 2. Standalone MKL
24-
You can also install MKL directly [from intel](https://software.intel.com/en-us/mkl/choose-download). For macOS and Windows this requires a free registration, on Linux this can be done via the command line, as seen [here](https://github.com/JuliaMath/IntelVectorMath.jl/blob/d4f8dd4083cf228cd493a4aed9964f1bc0f08d4f/.github/workflows/main.yml#L53).
25-
There is also the `intel-mkl-slim` package in the AUR that works well.
26-
27-
Note that intel MKL has a separate license, which you may want to check for commercial projects (see [FAQ]( https://software.intel.com/en-us/mkl/license-faq)).
17+
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.
2818

29-
### IntelVectorMath
30-
To install IntelVectorMath.jl run
19+
In the event that MKL was not installed properly you will get an error when first `using` it. Please try running
3120
```julia
32-
julia> ] add IntelVectorMath
21+
julia> ] build IntelVectorMath
3322
```
34-
If you used this package prior to its renaming, you may have to run `] rm VML` first. Otherwise there will be a conflict due to the UUID.
23+
If this does not work, please open an issue and include the output of `<packagedir>/deps/build.log`.
3524

36-
In the event that MKL was not installed properly you will get an error when first `using` it.
25+
#### Renaming from VML
26+
If you used this package prior to its renaming, you may have to run `] rm VML` first. Otherwise there will be a conflict due to the UUID.
3727

3828
## Using IntelVectorMath
3929
After loading `IntelVectorMath`, you have the supported function listed below, for example `IntelVectorMath.sin(rand(100))`. These should provide a significant speed-up over broadcasting the Base functions.
@@ -253,14 +243,13 @@ Next steps for this package
253243
* [x] Move Testing to GitHub Actions
254244
* [x] Add test for using standalone MKL
255245
* [x] Update Benchmarks
256-
* [ ] Add tests for mutating functions
246+
* [x] Add tests for mutating functions
247+
* [x] Add own dependency management via BinaryProvider
248+
* [ ] Update function list in README
249+
* [ ] Adopt Julia 1.3 artifact system, breaking backwards compatibility
257250

258251

259252

260253
## Advanced
261-
IntelVectorMath.jl works via Libdl which loads the relevant shared libraries. Libdl automatically finds the relevant libraries if the location of the binaries has been added to the system search paths.
262-
This already taken care of if you use MKL.jl, but the stand-alone may require you to source `mklvars.sh` in the shell you are opening the REPL in. The default command on Mac and Ubuntu is `source /opt/intel/mkl/bin/mklvars.sh intel64`. You may want to add this to your `.bashrc`.
263-
Adding a new `*.conf` file in `/etc/ld.so.conf.d` also works, as the `intel-mkl-slim` package in the AUR does automatically.
264-
265-
Further, IntelVectorMath.jl uses [CpuId.jl](https://github.com/m-j-w/CpuId.jl) to detect if your processor supports the newer `avx2` instructions, and if not defaults to `libmkl_vml_avx`. If your system does not have AVX this package will currently not work for you.
254+
IntelVectorMath.jl uses [CpuId.jl](https://github.com/m-j-w/CpuId.jl) to detect if your processor supports the newer `avx2` instructions, and if not defaults to `libmkl_vml_avx`. If your system does not have AVX this package will currently not work for you.
266255
If the CPU feature detection does not work for you, please open an issue.

deps/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
deps.jl
2-
build.log
2+
build.log
3+
4+
usr/

deps/build.jl

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,62 @@
1-
1+
using BinaryProvider # requires BinaryProvider 0.3.0 or later
22
using CpuId
3-
using Libdl
4-
5-
## this lets us load CpuId only once
63

74
if cpufeature(:AVX2)
8-
libsuffix = :avx2
5+
avxlib = "avx2"
96
println("AVX2 support detected, vml_avx2 selected")
107
else
11-
libsuffix = :avx
8+
avxlib = "avx"
129
println("AVX2 support missing, vml_avx selected")
1310
end
1411

15-
if Sys.iswindows()
16-
rtlib = :mkl_rt
17-
corelib = :mkl_core
18-
lib = Symbol(:mkl_vml_, libsuffix)
19-
else
20-
rtlib = :libmkl_rt
21-
corelib = :libmkl_core
22-
lib = Symbol(:libmkl_vml_, libsuffix)
23-
end
12+
# Parse some basic command-line arguments
13+
const verbose = "--verbose" in ARGS
14+
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))
15+
16+
baseproducts = [("mkl_core", :libmkl_core),
17+
("mkl_rt", :libmkl_rt),
18+
("mkl_vml_" * avxlib, :libmkl_vml_avx)]
19+
# if Sys.iswindows()
20+
# push!(baseproducts, ("mkl_intel_thread", :libmkl_intel_thread))
21+
# end
22+
23+
products = [LibraryProduct(prefix, ["lib"*bp[1], bp[1]], bp[2]) for bp in baseproducts]
2424

25+
# Download binaries from hosted location
26+
bin_prefix = "https://github.com/JuliaPackaging/Yggdrasil/releases/download/MKL-v2019.0.117"
2527

26-
depsjl_path = joinpath(@__DIR__, "deps.jl")
27-
open(depsjl_path, "w") do depsjl_file
28-
println(depsjl_file, strip("""
29-
## This file was autogenerated by build.jl.
30-
## Do not edit.
31-
import Libdl
28+
# Listing of files generated by BinaryBuilder:
29+
download_info = Dict(
30+
Linux(:x86_64) => ("$bin_prefix/MKL.v2019.0.117.x86_64-linux-gnu.tar.gz", "9a496908c05eccdb331218f4cf32229b024790b30bf7bc0ca0f5587e030d34e6"),
31+
Linux(:i686) => ("$bin_prefix/MKL.v2019.0.117.i686-linux-gnu.tar.gz", "ccdce675bf48738f28878bc831231498c7c9560a94f756da8c114f664790ffee"),
32+
MacOS(:x86_64) => ("$bin_prefix/MKL.v2019.0.117.x86_64-apple-darwin14.tar.gz", "605da525b16f61837bc35834f3a6ff90609b1d0a5f1606faa25bf45180ced6e9"),
33+
Windows(:x86_64) => ("$bin_prefix/MKL.v2019.0.117.x86_64-w64-mingw32.tar.gz", "0a9aaac254421fde0f26a95856b595deb8cce85d039050d8167293d049fd716d"),
34+
Windows(:i686) => ("$bin_prefix/MKL.v2019.0.117.i686-w64-mingw32.tar.gz", "53cac3a29bbb2acdc383297c256e3b68b3d4712e1b83417226da4971582e80cd"),
35+
)
3236

33-
const lib = :$lib
34-
const rtlib = :$rtlib
35-
const corelib = :$corelib
36-
"""))
37+
# Install unsatisfied or updated dependencies:
38+
unsatisfied = any(!satisfied(p; verbose=verbose) for p in products)
39+
dl_info = choose_download(download_info, platform_key_abi())
40+
if dl_info === nothing && unsatisfied
41+
# If we don't have a compatible .tar.gz to download, complain.
42+
# Alternatively, you could attempt to install from a separate provider,
43+
# build from source or something even more ambitious here.
44+
error("Your platform (\"$(Sys.MACHINE)\", parsed as \"$(triplet(platform_key_abi()))\") is not supported by this package!")
3745
end
46+
47+
# If we have a download, and we are unsatisfied (or the version we're
48+
# trying to install is not itself installed) then load it up!
49+
if unsatisfied || !isinstalled(dl_info...; prefix=prefix)
50+
# Download and install binaries
51+
install(dl_info...; prefix=prefix, force=true, verbose=verbose)
52+
end
53+
54+
# Write out a deps.jl file that will contain mappings for our products
55+
write_deps_file(joinpath(@__DIR__, "deps.jl"), products, verbose=verbose)
56+
57+
# cleanup for lean install
58+
libfiles = readdir("usr/lib")
59+
idx = .!mapreduce(p -> occursin.(p[1], libfiles), (x,y) -> x.|y, baseproducts)
60+
rm.("usr/lib/" .* libfiles[idx])
61+
62+
rm("usr/downloads/", recursive = true)

src/IntelVectorMath.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const IVM = IntelVectorMath
77

88
# import Base: .^, ./
99
using SpecialFunctions
10-
using Libdl
11-
include(joinpath(dirname(@__DIR__), "deps/deps.jl"))
10+
# using Libdl
11+
include("../deps/deps.jl")
1212

1313
include("setup.jl")
1414

0 commit comments

Comments
 (0)