Skip to content

Commit ccacf75

Browse files
authored
Merge pull request #45 from rust-math/static-link-flag
Static link option for intel-mkl-src
2 parents dbbb31d + 7e4e1ae commit ccacf75

File tree

13 files changed

+260
-143
lines changed

13 files changed

+260
-143
lines changed

.github/workflows/intel-mkl-sys.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: intel-mkl-sys
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request: {}
8+
9+
jobs:
10+
windows:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
feature:
15+
- mkl-dynamic-lp64-seq
16+
- mkl-dynamic-ilp64-seq
17+
runs-on: windows-2019
18+
steps:
19+
- uses: actions/checkout@v1
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: test
23+
args: >
24+
--manifest-path=intel-mkl-sys/Cargo.toml
25+
--no-default-features
26+
--features=${{ matrix.feature }},download
27+
28+
macos:
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
feature:
33+
- mkl-dynamic-lp64-iomp
34+
- mkl-dynamic-lp64-seq
35+
- mkl-dynamic-ilp64-iomp
36+
- mkl-dynamic-ilp64-seq
37+
runs-on: macos-10.15
38+
steps:
39+
- uses: actions/checkout@v1
40+
- uses: actions-rs/cargo@v1
41+
with:
42+
command: test
43+
args: >
44+
--manifest-path=intel-mkl-sys/Cargo.toml
45+
--no-default-features
46+
--features=${{ matrix.feature }},download
47+
48+
linux:
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
feature:
53+
- mkl-static-lp64-iomp
54+
- mkl-static-lp64-seq
55+
- mkl-static-ilp64-iomp
56+
- mkl-static-ilp64-seq
57+
- mkl-dynamic-lp64-iomp
58+
- mkl-dynamic-lp64-seq
59+
- mkl-dynamic-ilp64-iomp
60+
- mkl-dynamic-ilp64-seq
61+
runs-on: ubuntu-18.04
62+
steps:
63+
- uses: actions/checkout@v1
64+
- uses: actions-rs/cargo@v1
65+
with:
66+
command: test
67+
args: >
68+
--manifest-path=intel-mkl-sys/Cargo.toml
69+
--no-default-features
70+
--features=${{ matrix.feature }},download

.github/workflows/intel-mkl-tool.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: intel-mkl-tool
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request: {}
8+
9+
jobs:
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os:
15+
- windows-2019
16+
- macos-10.15
17+
- ubuntu-18.04
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v1
21+
- uses: actions-rs/cargo@v1
22+
with:
23+
command: test
24+
args: --manifest-path=intel-mkl-tool/Cargo.toml
25+
26+
docker:
27+
runs-on: ubuntu-18.04
28+
strategy:
29+
matrix:
30+
target: ["test", "seek", "package", "download"]
31+
steps:
32+
- uses: actions/checkout@v1
33+
- name: Test with mkl-rust container
34+
run: make -C intel-mkl-tool ${{ matrix.target }}

.github/workflows/rust.yml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,6 @@ on:
77
pull_request: {}
88

99
jobs:
10-
windows:
11-
runs-on: windows-2019
12-
strategy:
13-
matrix:
14-
target: ["intel-mkl-src", "intel-mkl-sys", "intel-mkl-tool"]
15-
steps:
16-
- uses: actions/checkout@v1
17-
- uses: actions-rs/cargo@v1
18-
with:
19-
command: test
20-
args: --manifest-path=${{ matrix.target }}/Cargo.toml
21-
22-
macos:
23-
runs-on: macos-10.15
24-
strategy:
25-
matrix:
26-
target: ["intel-mkl-src", "intel-mkl-sys", "intel-mkl-tool"]
27-
steps:
28-
- uses: actions/checkout@v1
29-
- uses: actions-rs/cargo@v1
30-
with:
31-
command: test
32-
args: --manifest-path=${{ matrix.target }}/Cargo.toml
33-
34-
linux:
35-
runs-on: ubuntu-18.04
36-
strategy:
37-
matrix:
38-
target: ["intel-mkl-src", "intel-mkl-sys", "intel-mkl-tool"]
39-
steps:
40-
- uses: actions/checkout@v1
41-
- uses: actions-rs/cargo@v1
42-
with:
43-
command: test
44-
args: --manifest-path=${{ matrix.target }}/Cargo.toml
45-
46-
docker:
47-
runs-on: ubuntu-18.04
48-
strategy:
49-
matrix:
50-
target: ["test", "seek", "package", "download"]
51-
steps:
52-
- uses: actions/checkout@v1
53-
- name: Test with mkl-rust container
54-
run: make -C intel-mkl-tool ${{ matrix.target }}
55-
5610
check-format:
5711
runs-on: ubuntu-18.04
5812
steps:
@@ -61,4 +15,3 @@ jobs:
6115
with:
6216
command: fmt
6317
args: -- --check
64-

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ Redistribution of Intel MKL as a crate. Tested on Linux, macOS, and Windows (sin
1111
[VM]: https://software.intel.com/en-us/mkl-developer-reference-c-vector-mathematical-functions
1212
[VSL]: https://software.intel.com/en-us/mkl-developer-reference-c-statistical-functions
1313

14+
## Supported features
15+
16+
| feature name | Linux | macOS | Windows |
17+
|:-----------------------|:------------------:|:------------------:|:------------------:|
18+
| mkl-static-lp64-iomp | :heavy_check_mark: | - | - |
19+
| mkl-static-lp64-seq | :heavy_check_mark: | - | - |
20+
| mkl-static-ilp64-iomp | :heavy_check_mark: | - | - |
21+
| mkl-static-ilp64-seq | :heavy_check_mark: | - | - |
22+
| mkl-dynamic-lp64-iomp | :heavy_check_mark: | :heavy_check_mark: | - |
23+
| mkl-dynamic-lp64-seq | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
24+
| mkl-dynamic-ilp64-iomp | :heavy_check_mark: | :heavy_check_mark: | - |
25+
| mkl-dynamic-ilp64-seq | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
26+
1427
## Usage
1528

1629
This crate is a `*-src` crate. This downloads and link Intel MKL, but does not introduce any symbols.

intel-mkl-src/Cargo.toml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,24 @@ build = "build.rs"
1414
links = "mkl_core"
1515

1616
[features]
17-
default = []
18-
use-shared = []
17+
default = ["download", "mkl-dynamic-lp64-iomp"]
1918

20-
[build-dependencies.intel-mkl-tool]
21-
version = "0.1.0"
22-
path = "../intel-mkl-tool"
23-
default-features = false
19+
# MKL config
20+
# https://software.intel.com/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html
21+
mkl-static-lp64-iomp = []
22+
mkl-static-lp64-seq = []
23+
mkl-static-ilp64-iomp = []
24+
mkl-static-ilp64-seq = []
25+
mkl-dynamic-lp64-iomp = []
26+
mkl-dynamic-lp64-seq = []
27+
mkl-dynamic-ilp64-iomp = []
28+
mkl-dynamic-ilp64-seq = []
2429

25-
[dev-dependencies]
26-
libc = "0.2.65"
30+
# Enable downloading from AWS S3 when not found
31+
download = []
32+
# (Experimental) Cache download archive ad $XDG_DATA_HOME/intel-mkl-tool/
33+
xdg-data-home = []
34+
35+
[build-dependencies]
36+
anyhow = "1"
37+
intel-mkl-tool = { version = "0.1.0", path = "../intel-mkl-tool", default-features = false }

intel-mkl-src/build.rs

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,50 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23+
use anyhow::*;
24+
use intel_mkl_tool::*;
2325
use std::{env, path::*};
2426

25-
fn main() {
26-
let out_dir = if let Some(path) = intel_mkl_tool::seek_pkg_config() {
27-
path
28-
} else {
29-
let out_dir = if cfg!(feature = "use-shared") {
30-
intel_mkl_tool::xdg_home_path()
27+
#[cfg(feature = "mkl-static-lp64-iomp")]
28+
const MKL_CONFIG: &str = "mkl-static-lp64-iomp";
29+
#[cfg(feature = "mkl-static-lp64-seq")]
30+
const MKL_CONFIG: &str = "mkl-static-lp64-seq";
31+
#[cfg(feature = "mkl-static-ilp64-iomp")]
32+
const MKL_CONFIG: &str = "mkl-static-ilp64-iomp";
33+
#[cfg(feature = "mkl-static-ilp64-seq")]
34+
const MKL_CONFIG: &str = "mkl-static-ilp64-seq";
35+
#[cfg(feature = "mkl-dynamic-lp64-iomp")]
36+
const MKL_CONFIG: &str = "mkl-dynamic-lp64-iomp";
37+
#[cfg(feature = "mkl-dynamic-lp64-seq")]
38+
const MKL_CONFIG: &str = "mkl-dynamic-lp64-seq";
39+
#[cfg(feature = "mkl-dynamic-ilp64-iomp")]
40+
const MKL_CONFIG: &str = "mkl-dynamic-ilp64-iomp";
41+
#[cfg(feature = "mkl-dynamic-ilp64-seq")]
42+
const MKL_CONFIG: &str = "mkl-dynamic-ilp64-seq";
43+
44+
fn main() -> Result<()> {
45+
let cfg = Config::from_str(MKL_CONFIG).unwrap();
46+
47+
// already exists on system
48+
if let Ok(entry) = Entry::from_config(cfg) {
49+
entry.print_cargo_metadata();
50+
return Ok(());
51+
}
52+
53+
// download if not found
54+
if cfg!(feature = "download") {
55+
let path = if cfg!(feature = "xdg-data-home") {
56+
xdg_home_path()
3157
} else {
32-
PathBuf::from(env::var("OUT_DIR").expect("Failed to get OUT_DIR"))
58+
PathBuf::from(env::var("OUT_DIR").unwrap())
3359
};
34-
35-
intel_mkl_tool::download_default(&out_dir).expect("Failed to downalod Intel-MKL archive");
36-
out_dir
37-
};
38-
println!("cargo:rustc-link-search={}", out_dir.display());
39-
println!("cargo:rustc-link-lib=mkl_intel_lp64");
40-
println!("cargo:rustc-link-lib=mkl_sequential");
41-
println!("cargo:rustc-link-lib=mkl_core");
60+
println!(
61+
r#"cargo:warning="Download Intel MKL archive into {}""#,
62+
path.display()
63+
);
64+
cfg.download(path)?;
65+
let entry = Entry::from_config(cfg).unwrap(); // must found
66+
entry.print_cargo_metadata();
67+
}
68+
Ok(())
4269
}

intel-mkl-src/tests/link.rs

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

intel-mkl-sys/Cargo.toml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,25 @@ repository = "https://github.com/rust-math/intel-mkl-src"
99
keywords = ["ffi"]
1010
license = "MIT"
1111

12-
[dependencies.intel-mkl-src]
13-
path = "../intel-mkl-src"
14-
version = "0.5.0"
12+
[features]
13+
default = ["download", "mkl-dynamic-lp64-iomp"]
14+
15+
# MKL config
16+
# https://software.intel.com/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html
17+
mkl-static-lp64-iomp = ["intel-mkl-src/mkl-static-lp64-iomp"]
18+
mkl-static-lp64-seq = ["intel-mkl-src/mkl-static-lp64-seq"]
19+
mkl-static-ilp64-iomp = ["intel-mkl-src/mkl-static-ilp64-iomp"]
20+
mkl-static-ilp64-seq = ["intel-mkl-src/mkl-static-ilp64-seq"]
21+
mkl-dynamic-lp64-iomp = ["intel-mkl-src/mkl-dynamic-lp64-iomp"]
22+
mkl-dynamic-lp64-seq = ["intel-mkl-src/mkl-dynamic-lp64-seq"]
23+
mkl-dynamic-ilp64-iomp = ["intel-mkl-src/mkl-dynamic-ilp64-iomp"]
24+
mkl-dynamic-ilp64-seq = ["intel-mkl-src/mkl-dynamic-ilp64-seq"]
25+
26+
# Enable downloading from AWS S3 when not found
27+
download = ["intel-mkl-src/download"]
28+
29+
[dependencies]
30+
intel-mkl-src = { path = "../intel-mkl-src", version = "0.5.0", default-features = false }
1531

1632
[dev-dependencies]
1733
criterion = "0.3.0"

intel-mkl-tool/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ zstd = "0.5.1"
2828
structopt = { version = "0.3.5", optional = true }
2929
env_logger = { version = "0.7.1", optional = true }
3030

31+
[dev-dependencies]
32+
paste = "*"
33+
3134
[[bin]]
3235
name = "intel-mkl-tool"
3336
path = "src/cli.rs"

intel-mkl-tool/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn main() -> Result<()> {
6464
} else {
6565
println!("{:<22}", lib.name());
6666
}
67-
for (path, name) in &lib.files() {
67+
for (path, name) in &lib.found_files() {
6868
println!(" {:<25} at {}", name, path.display());
6969
}
7070
}

0 commit comments

Comments
 (0)