Skip to content

Commit 28d0a02

Browse files
authored
Merge pull request #20 from rust-math/tools
intel-mkl-tool executable
2 parents 5779c5e + 09821eb commit 28d0a02

File tree

11 files changed

+252
-119
lines changed

11 files changed

+252
-119
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Cargo
22
# will have compiled files and executables
3-
/target/
3+
target/
44

55
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
66
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock

Cargo.toml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
1-
[package]
2-
name = "intel-mkl-src"
3-
version = "0.4.1"
4-
authors = ["Toshiki Teramura <[email protected]>"]
5-
edition = "2018"
6-
7-
description = "Redistribution of Intel(R) MKL as a crate"
8-
repository = "https://github.com/termoshtt/rust-intel-mkl"
9-
keywords = ["fft", "blas", "lapack"]
10-
license-file = "License.txt"
11-
readme = "README.md"
12-
13-
build = "build.rs"
14-
links = "mkl_intel_lp64"
15-
16-
exclude = ["mkl_lib/mkl.tar.xz"]
17-
18-
[build-dependencies]
19-
pkg-config = "0.3.16"
20-
failure = "0.1.6"
21-
xz2 = "0.1.6"
22-
tar = "0.4.26"
23-
curl = "0.4.25"
24-
25-
[dev-dependencies]
26-
libc = "0.2.65"
1+
[workspace]
2+
members = [
3+
"intel-mkl-src",
4+
"intel-mkl-tool",
5+
]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ Be sure to set `PKG_CONFIG_PATH` and `LD_LIBRARY_PATH` correctly.
2121
For debian and ubuntu users, [ci/Dockerfile](ci/Dockerfile) may be helpful.
2222
Windows is not supported yet.
2323

24+
## `use-shared` feature
25+
26+
(Optional, Experimental) This feature uses `$XDG_DATA_HOME/intel-mkl-tool` directory for downloading Intel-MKL.
27+
You can share this directory among several projects using `intel-mkl-src` crate.
28+
This will reduce disk occupancy and downloading time.
29+
2430
## License
2531
MKL is distributed under the Intel Simplified Software License for Intel(R) Math Kernel Library, See [License.txt](License.txt).
2632
Some wrapper codes are licensed by MIT License (see the header of each file).

build.rs

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

intel-mkl-src/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "intel-mkl-src"
3+
version = "0.4.1"
4+
authors = ["Toshiki Teramura <[email protected]>"]
5+
edition = "2018"
6+
7+
description = "Redistribution of Intel(R) MKL as a crate"
8+
repository = "https://github.com/termoshtt/rust-intel-mkl"
9+
keywords = ["fft", "blas", "lapack"]
10+
license-file = "License.txt"
11+
readme = "README.md"
12+
13+
build = "build.rs"
14+
links = "mkl_intel_lp64"
15+
16+
exclude = ["mkl_lib/mkl.tar.xz"]
17+
18+
[features]
19+
default = []
20+
use-shared = []
21+
22+
[build-dependencies]
23+
failure = "0.1"
24+
25+
[build-dependencies.intel-mkl-tool]
26+
version = "0.1.0"
27+
path = "../intel-mkl-tool"
28+
default-features = false
29+
30+
[dev-dependencies]
31+
libc = "0.2.65"

intel-mkl-src/build.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// MIT License
2+
//
3+
// Copyright (c) 2017 Toshiki Teramura
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
use failure::*;
24+
use std::{env, path::*};
25+
26+
fn main() -> Fallible<()> {
27+
let out_dir = if let Some(path) = intel_mkl_tool::seek_pkg_config() {
28+
path
29+
} else {
30+
let out_dir = if cfg!(feature = "use-shared") {
31+
intel_mkl_tool::home_library_path()
32+
} else {
33+
PathBuf::from(env::var("OUT_DIR").unwrap())
34+
};
35+
36+
intel_mkl_tool::download(&out_dir)?;
37+
out_dir
38+
};
39+
println!("cargo:rustc-link-search={}", out_dir.display());
40+
println!("cargo:rustc-link-lib=mkl_intel_lp64");
41+
println!("cargo:rustc-link-lib=mkl_sequential");
42+
println!("cargo:rustc-link-lib=mkl_core");
43+
Ok(())
44+
}
File renamed without changes.
File renamed without changes.

intel-mkl-tool/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "intel-mkl-tool"
3+
version = "0.1.0"
4+
authors = ["Toshiki Teramura <[email protected]>"]
5+
edition = "2018"
6+
7+
[features]
8+
default = ["cli"]
9+
cli = ["structopt", "env_logger"]
10+
11+
[dependencies]
12+
curl = "0.4.25"
13+
failure = "0.1.6"
14+
pkg-config = "0.3.17"
15+
tar = "0.4.26"
16+
xz2 = "0.1.6"
17+
log = "0.4.8"
18+
dirs = "*"
19+
20+
# CLI
21+
structopt = { version = "0.3.4", optional = true }
22+
env_logger = { version = "0.7.1", optional = true }
23+
24+
[[bin]]
25+
name = "intel-mkl-tool"
26+
path = "src/cli.rs"
27+
required-features = ["cli"]

intel-mkl-tool/src/cli.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use failure::*;
2+
use std::{env, path::PathBuf};
3+
use structopt::StructOpt;
4+
5+
/// CLI tool for intel-mkl crate
6+
#[derive(Debug, StructOpt)]
7+
enum Opt {
8+
/// Download Intel-MKL library
9+
Download {
10+
/// Install destination. Default is `$XDG_DATA_HOME/intel-mkl-tool`
11+
path: Option<PathBuf>,
12+
},
13+
/// Seek Intel-MKL library
14+
///
15+
/// 1. pkg-config
16+
/// 2. `$XDG_DATA_HOME/intel-mkl-tool`
17+
/// will be sought.
18+
Seek {},
19+
}
20+
21+
fn main() -> Fallible<()> {
22+
env::set_var("RUST_LOG", "info");
23+
env_logger::init();
24+
25+
let opt = Opt::from_args();
26+
27+
match opt {
28+
Opt::Download { path } => {
29+
let path = if let Some(path) = path {
30+
path
31+
} else {
32+
intel_mkl_tool::home_library_path()
33+
};
34+
intel_mkl_tool::download(&path)?;
35+
}
36+
Opt::Seek {} => {
37+
if let Some(path) = intel_mkl_tool::seek_pkg_config() {
38+
println!("{}", path.display());
39+
return Ok(());
40+
}
41+
if let Some(path) = intel_mkl_tool::seek_home() {
42+
println!("{}", path.display());
43+
return Ok(());
44+
}
45+
bail!("Intel-MKL not found.");
46+
}
47+
}
48+
Ok(())
49+
}

0 commit comments

Comments
 (0)