Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static link option for intel-mkl-src #45

Merged
merged 11 commits into from
Jun 17, 2020
70 changes: 70 additions & 0 deletions .github/workflows/intel-mkl-sys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: intel-mkl-sys

on:
push:
branches:
- master
pull_request: {}

jobs:
windows:
strategy:
fail-fast: false
matrix:
feature:
- mkl-dynamic-lp64-seq
- mkl-dynamic-ilp64-seq
runs-on: windows-2019
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--manifest-path=intel-mkl-sys/Cargo.toml
--no-default-features
--features=${{ matrix.feature }},download

macos:
strategy:
fail-fast: false
matrix:
feature:
- mkl-dynamic-lp64-iomp
- mkl-dynamic-lp64-seq
- mkl-dynamic-ilp64-iomp
- mkl-dynamic-ilp64-seq
runs-on: macos-10.15
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--manifest-path=intel-mkl-sys/Cargo.toml
--no-default-features
--features=${{ matrix.feature }},download

linux:
strategy:
fail-fast: false
matrix:
feature:
- mkl-static-lp64-iomp
- mkl-static-lp64-seq
- mkl-static-ilp64-iomp
- mkl-static-ilp64-seq
- mkl-dynamic-lp64-iomp
- mkl-dynamic-lp64-seq
- mkl-dynamic-ilp64-iomp
- mkl-dynamic-ilp64-seq
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: >
--manifest-path=intel-mkl-sys/Cargo.toml
--no-default-features
--features=${{ matrix.feature }},download
34 changes: 34 additions & 0 deletions .github/workflows/intel-mkl-tool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: intel-mkl-tool

on:
push:
branches:
- master
pull_request: {}

jobs:
test:
strategy:
fail-fast: false
matrix:
os:
- windows-2019
- macos-10.15
- ubuntu-18.04
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=intel-mkl-tool/Cargo.toml

docker:
runs-on: ubuntu-18.04
strategy:
matrix:
target: ["test", "seek", "package", "download"]
steps:
- uses: actions/checkout@v1
- name: Test with mkl-rust container
run: make -C intel-mkl-tool ${{ matrix.target }}
47 changes: 0 additions & 47 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,6 @@ on:
pull_request: {}

jobs:
windows:
runs-on: windows-2019
strategy:
matrix:
target: ["intel-mkl-src", "intel-mkl-sys", "intel-mkl-tool"]
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=${{ matrix.target }}/Cargo.toml

macos:
runs-on: macos-10.15
strategy:
matrix:
target: ["intel-mkl-src", "intel-mkl-sys", "intel-mkl-tool"]
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=${{ matrix.target }}/Cargo.toml

linux:
runs-on: ubuntu-18.04
strategy:
matrix:
target: ["intel-mkl-src", "intel-mkl-sys", "intel-mkl-tool"]
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=${{ matrix.target }}/Cargo.toml

docker:
runs-on: ubuntu-18.04
strategy:
matrix:
target: ["test", "seek", "package", "download"]
steps:
- uses: actions/checkout@v1
- name: Test with mkl-rust container
run: make -C intel-mkl-tool ${{ matrix.target }}

check-format:
runs-on: ubuntu-18.04
steps:
Expand All @@ -61,4 +15,3 @@ jobs:
with:
command: fmt
args: -- --check

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

## Supported features

| feature name | Linux | macOS | Windows |
|:-----------------------|:------------------:|:------------------:|:------------------:|
| mkl-static-lp64-iomp | :heavy_check_mark: | - | - |
| mkl-static-lp64-seq | :heavy_check_mark: | - | - |
| mkl-static-ilp64-iomp | :heavy_check_mark: | - | - |
| mkl-static-ilp64-seq | :heavy_check_mark: | - | - |
| mkl-dynamic-lp64-iomp | :heavy_check_mark: | :heavy_check_mark: | - |
| mkl-dynamic-lp64-seq | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| mkl-dynamic-ilp64-iomp | :heavy_check_mark: | :heavy_check_mark: | - |
| mkl-dynamic-ilp64-seq | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |

## Usage

This crate is a `*-src` crate. This downloads and link Intel MKL, but does not introduce any symbols.
Expand Down
27 changes: 19 additions & 8 deletions intel-mkl-src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ build = "build.rs"
links = "mkl_core"

[features]
default = []
use-shared = []
default = ["download", "mkl-dynamic-lp64-iomp"]

[build-dependencies.intel-mkl-tool]
version = "0.1.0"
path = "../intel-mkl-tool"
default-features = false
# MKL config
# https://software.intel.com/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html
mkl-static-lp64-iomp = []
mkl-static-lp64-seq = []
mkl-static-ilp64-iomp = []
mkl-static-ilp64-seq = []
mkl-dynamic-lp64-iomp = []
mkl-dynamic-lp64-seq = []
mkl-dynamic-ilp64-iomp = []
mkl-dynamic-ilp64-seq = []

[dev-dependencies]
libc = "0.2.65"
# Enable downloading from AWS S3 when not found
download = []
# (Experimental) Cache download archive ad $XDG_DATA_HOME/intel-mkl-tool/
xdg-data-home = []

[build-dependencies]
anyhow = "1"
intel-mkl-tool = { version = "0.1.0", path = "../intel-mkl-tool", default-features = false }
57 changes: 42 additions & 15 deletions intel-mkl-src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,50 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use anyhow::*;
use intel_mkl_tool::*;
use std::{env, path::*};

fn main() {
let out_dir = if let Some(path) = intel_mkl_tool::seek_pkg_config() {
path
} else {
let out_dir = if cfg!(feature = "use-shared") {
intel_mkl_tool::xdg_home_path()
#[cfg(feature = "mkl-static-lp64-iomp")]
const MKL_CONFIG: &str = "mkl-static-lp64-iomp";
#[cfg(feature = "mkl-static-lp64-seq")]
const MKL_CONFIG: &str = "mkl-static-lp64-seq";
#[cfg(feature = "mkl-static-ilp64-iomp")]
const MKL_CONFIG: &str = "mkl-static-ilp64-iomp";
#[cfg(feature = "mkl-static-ilp64-seq")]
const MKL_CONFIG: &str = "mkl-static-ilp64-seq";
#[cfg(feature = "mkl-dynamic-lp64-iomp")]
const MKL_CONFIG: &str = "mkl-dynamic-lp64-iomp";
#[cfg(feature = "mkl-dynamic-lp64-seq")]
const MKL_CONFIG: &str = "mkl-dynamic-lp64-seq";
#[cfg(feature = "mkl-dynamic-ilp64-iomp")]
const MKL_CONFIG: &str = "mkl-dynamic-ilp64-iomp";
#[cfg(feature = "mkl-dynamic-ilp64-seq")]
const MKL_CONFIG: &str = "mkl-dynamic-ilp64-seq";

fn main() -> Result<()> {
let cfg = Config::from_str(MKL_CONFIG).unwrap();

// already exists on system
if let Ok(entry) = Entry::from_config(cfg) {
entry.print_cargo_metadata();
return Ok(());
}

// download if not found
if cfg!(feature = "download") {
let path = if cfg!(feature = "xdg-data-home") {
xdg_home_path()
} else {
PathBuf::from(env::var("OUT_DIR").expect("Failed to get OUT_DIR"))
PathBuf::from(env::var("OUT_DIR").unwrap())
};

intel_mkl_tool::download_default(&out_dir).expect("Failed to downalod Intel-MKL archive");
out_dir
};
println!("cargo:rustc-link-search={}", out_dir.display());
println!("cargo:rustc-link-lib=mkl_intel_lp64");
println!("cargo:rustc-link-lib=mkl_sequential");
println!("cargo:rustc-link-lib=mkl_core");
println!(
r#"cargo:warning="Download Intel MKL archive into {}""#,
path.display()
);
cfg.download(path)?;
let entry = Entry::from_config(cfg).unwrap(); // must found
entry.print_cargo_metadata();
}
Ok(())
}
40 changes: 0 additions & 40 deletions intel-mkl-src/tests/link.rs

This file was deleted.

22 changes: 19 additions & 3 deletions intel-mkl-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,25 @@ repository = "https://github.com/rust-math/intel-mkl-src"
keywords = ["ffi"]
license = "MIT"

[dependencies.intel-mkl-src]
path = "../intel-mkl-src"
version = "0.5.0"
[features]
default = ["download", "mkl-dynamic-lp64-iomp"]

# MKL config
# https://software.intel.com/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html
mkl-static-lp64-iomp = ["intel-mkl-src/mkl-static-lp64-iomp"]
mkl-static-lp64-seq = ["intel-mkl-src/mkl-static-lp64-seq"]
mkl-static-ilp64-iomp = ["intel-mkl-src/mkl-static-ilp64-iomp"]
mkl-static-ilp64-seq = ["intel-mkl-src/mkl-static-ilp64-seq"]
mkl-dynamic-lp64-iomp = ["intel-mkl-src/mkl-dynamic-lp64-iomp"]
mkl-dynamic-lp64-seq = ["intel-mkl-src/mkl-dynamic-lp64-seq"]
mkl-dynamic-ilp64-iomp = ["intel-mkl-src/mkl-dynamic-ilp64-iomp"]
mkl-dynamic-ilp64-seq = ["intel-mkl-src/mkl-dynamic-ilp64-seq"]

# Enable downloading from AWS S3 when not found
download = ["intel-mkl-src/download"]

[dependencies]
intel-mkl-src = { path = "../intel-mkl-src", version = "0.5.0", default-features = false }

[dev-dependencies]
criterion = "0.3.0"
Expand Down
3 changes: 3 additions & 0 deletions intel-mkl-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ zstd = "0.5.1"
structopt = { version = "0.3.5", optional = true }
env_logger = { version = "0.7.1", optional = true }

[dev-dependencies]
paste = "*"

[[bin]]
name = "intel-mkl-tool"
path = "src/cli.rs"
Expand Down
2 changes: 1 addition & 1 deletion intel-mkl-tool/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn main() -> Result<()> {
} else {
println!("{:<22}", lib.name());
}
for (path, name) in &lib.files() {
for (path, name) in &lib.found_files() {
println!(" {:<25} at {}", name, path.display());
}
}
Expand Down
Loading