diff --git a/.github/workflows/intel-mkl-sys.yml b/.github/workflows/intel-mkl-sys.yml index 7ca59efe..dba38b69 100644 --- a/.github/workflows/intel-mkl-sys.yml +++ b/.github/workflows/intel-mkl-sys.yml @@ -7,58 +7,6 @@ on: pull_request: {} jobs: - windows: - strategy: - fail-fast: false - matrix: - feature: - - mkl-static-lp64-seq - - mkl-static-ilp64-seq - - mkl-dynamic-lp64-seq - - mkl-dynamic-ilp64-seq - runs-on: windows-2019 - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: "1.56.0" - profile: minimal - default: true - override: true - - 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/toolchain@v1 - with: - toolchain: "1.56.0" - profile: minimal - default: true - override: true - - 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 @@ -73,18 +21,14 @@ jobs: - mkl-dynamic-ilp64-iomp - mkl-dynamic-ilp64-seq runs-on: ubuntu-22.04 + container: + image: ghcr.io/rust-math/intel-mkl-src/mkl-rust:1.56.0 steps: - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: "1.56.0" - profile: minimal - default: true - override: true - uses: actions-rs/cargo@v1 with: command: test args: > --manifest-path=intel-mkl-sys/Cargo.toml --no-default-features - --features=${{ matrix.feature }},download + --features=${{ matrix.feature }} diff --git a/.github/workflows/intel-mkl-tool.yml b/.github/workflows/intel-mkl-tool.yml index 8cb2fee2..b5cfa278 100644 --- a/.github/workflows/intel-mkl-tool.yml +++ b/.github/workflows/intel-mkl-tool.yml @@ -24,24 +24,36 @@ jobs: profile: minimal default: true override: true - - uses: actions-rs/cargo@v1 + - name: cargo test + uses: actions-rs/cargo@v1 with: command: test args: --manifest-path=intel-mkl-tool/Cargo.toml - name: cargo-test - - uses: actions-rs/cargo@v1 + - name: cargo test with no-default-features + uses: actions-rs/cargo@v1 with: command: test - args: --manifest-path=intel-mkl-tool/Cargo.toml --no-default-features - name: cargo-test no-default-features + args: > + --manifest-path=intel-mkl-tool/Cargo.toml + --no-default-features - docker: - runs-on: ubuntu-22.04 + seek: strategy: fail-fast: false matrix: - target: ["test", "package", "seek", "seek-ubuntu", "seek-centos"] + image: + - mkl-rust + - mkl-ubuntu + - mkl-centos + runs-on: ubuntu-22.04 + container: + image: ghcr.io/rust-math/intel-mkl-src/${{ matrix.image }}:1.56.0 steps: - uses: actions/checkout@v1 - - name: Test with mkl-rust container - run: make -C intel-mkl-tool ${{ matrix.target }} + - name: cargo run -- seek + uses: actions-rs/cargo@v1 + with: + command: run + args: > + --manifest-path=intel-mkl-tool/Cargo.toml + -- seek diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 00dfa704..6c6e8235 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,15 +9,10 @@ on: jobs: check-format: runs-on: ubuntu-22.04 + container: + image: ghcr.io/rust-math/intel-mkl-src/mkl-rust:1.56.0 steps: - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: "1.56.0" - profile: minimal - components: rustfmt - default: true - override: true - uses: actions-rs/cargo@v1 with: command: fmt @@ -25,15 +20,10 @@ jobs: clippy: runs-on: ubuntu-22.04 + container: + image: ghcr.io/rust-math/intel-mkl-src/mkl-rust:1.56.0 steps: - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: "1.56.0" - profile: minimal - components: clippy - default: true - override: true - uses: actions-rs/cargo@v1 with: command: clippy diff --git a/docker/mkl-rust.Dockerfile b/docker/mkl-rust.Dockerfile index 154ece78..826ff747 100644 --- a/docker/mkl-rust.Dockerfile +++ b/docker/mkl-rust.Dockerfile @@ -29,3 +29,4 @@ RUN sed -i "s/MKLROOT/prefix/g" ${PKG_CONFIG_PATH}/*.pc # Setup basic rust development tools WORKDIR /src RUN cargo install cargo-tarpaulin +RUN rustup component add rustfmt clippy diff --git a/intel-mkl-src/Cargo.toml b/intel-mkl-src/Cargo.toml index b64c52db..672f5d6b 100644 --- a/intel-mkl-src/Cargo.toml +++ b/intel-mkl-src/Cargo.toml @@ -29,9 +29,6 @@ mkl-dynamic-lp64-seq = [] mkl-dynamic-ilp64-iomp = [] mkl-dynamic-ilp64-seq = [] -# Enable downloading from AWS S3 when system MKL not found -download = ["intel-mkl-tool/archive"] - [build-dependencies] anyhow = "1.0.58" intel-mkl-tool = { version = "0.3.0", path = "../intel-mkl-tool", default-features = false } diff --git a/intel-mkl-sys/Cargo.toml b/intel-mkl-sys/Cargo.toml index 27eaa438..17332dd7 100644 --- a/intel-mkl-sys/Cargo.toml +++ b/intel-mkl-sys/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["ffi"] license = "MIT" [features] -default = ["download", "mkl-static-ilp64-seq"] +default = ["mkl-static-ilp64-seq"] # MKL config # https://software.intel.com/content/www/us/en/develop/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool.html @@ -25,9 +25,6 @@ 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.7.0", default-features = false } diff --git a/intel-mkl-tool/Cargo.toml b/intel-mkl-tool/Cargo.toml index 6e9aebfd..788c40be 100644 --- a/intel-mkl-tool/Cargo.toml +++ b/intel-mkl-tool/Cargo.toml @@ -12,8 +12,7 @@ license = "MIT" [features] default = ["cli"] -archive = ["curl", "tar", "zstd"] -cli = ["structopt", "archive"] +cli = ["structopt"] [dependencies] anyhow = "1.0.58" @@ -22,11 +21,6 @@ dirs = "4.0.0" glob = "0.3.0" pkg-config = "0.3.25" -# archive -curl = { version = "0.4.44", optional = true } -tar = { version = "0.4.38", optional = true } -zstd = { version = "0.11.2", optional = true } - # CLI structopt = { version = "0.3.26", optional = true } diff --git a/intel-mkl-tool/Makefile b/intel-mkl-tool/Makefile deleted file mode 100644 index 1b4cc521..00000000 --- a/intel-mkl-tool/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -REGISTRY := ghcr.io/rust-math/intel-mkl-src -RUST_VERSION := 1.56.0 -DOCKER_OPTION := --rm -u $(shell id -u):$(shell id -g) -v $(HERE):/src - -test: - docker run $(DOCKER_OPTION) --env CARGO_HOME=/src/.cargo-cache $(REGISTRY)/mkl-rust:$(RUST_VERSION) cargo test with_mkl -- --ignored - -seek: - docker run $(DOCKER_OPTION) --env CARGO_HOME=/src/.cargo-cache $(REGISTRY)/mkl-rust:$(RUST_VERSION) cargo run --release -- seek - -package: - docker run $(DOCKER_OPTION) --env CARGO_HOME=/src/.cargo-cache $(REGISTRY)/mkl-rust:$(RUST_VERSION) cargo run --release -- package - -seek-ubuntu: - docker run $(DOCKER_OPTION) --env CARGO_HOME=/src/.cargo-ubuntu $(REGISTRY)/mkl-ubuntu:$(RUST_VERSION) cargo run --release -- seek - -seek-centos: - docker run $(DOCKER_OPTION) --env CARGO_HOME=/src/.cargo-centos $(REGISTRY)/mkl-centos:$(RUST_VERSION) cargo run --release -- seek diff --git a/intel-mkl-tool/src/cli.rs b/intel-mkl-tool/src/cli.rs index 3c0d0b3c..ea9cb6c4 100644 --- a/intel-mkl-tool/src/cli.rs +++ b/intel-mkl-tool/src/cli.rs @@ -1,49 +1,18 @@ use anyhow::{bail, Result}; use intel_mkl_tool::*; -use std::{env, path::PathBuf, str::FromStr}; use structopt::StructOpt; /// CLI tool for intel-mkl crate #[derive(Debug, StructOpt)] enum Opt { - /// Download Intel-MKL library - Download { - /// Archive name, e.g. "mkl-static-lp64-iomp". Download all archives if None - #[structopt(long = "name")] - name: Option, - /// Install destination - #[structopt(short = "o", long = "path")] - path: PathBuf, - }, - /// Seek Intel-MKL library Seek {}, - - /// Package Intel MKL libraries into an archive - Package { - #[structopt(long = "name")] - name: Option, - #[structopt(short = "o", long = "path")] - path: Option, - }, } fn main() -> Result<()> { let opt = Opt::from_args(); match opt { - Opt::Download { name, path } => { - if let Some(name) = name { - let cfg = Config::from_str(&name)?; - cfg.download(&path.join(cfg.to_string()))?; - } else { - for cfg in Config::possibles() { - println!("Download archive {:<22} into {}", cfg, path.display()); - cfg.download(&path.join(cfg.to_string()))?; - } - } - } - Opt::Seek {} => { let available = Entry::available(); if available.is_empty() { @@ -60,31 +29,6 @@ fn main() -> Result<()> { } } } - - Opt::Package { name, path } => { - let path = path.unwrap_or(env::current_dir().unwrap()); - if let Some(name) = name { - let cfg = Config::from_str(&name)?; - let entry = Entry::from_config(cfg)?; - let path = if let Ok(version) = entry.version() { - path.join(format!("{}.{}", version.0, version.1)) - } else { - path - }; - let package = entry.package(&path)?; - println!("Pacakge created: {}", package.display()); - } else { - for entry in Entry::available() { - let path = if let Ok(version) = entry.version() { - path.join(format!("{}.{}", version.0, version.1)) - } else { - path.clone() - }; - let package = entry.package(&path)?; - println!("Pacakge created: {}", package.display()); - } - } - } } Ok(()) } diff --git a/intel-mkl-tool/src/download.rs b/intel-mkl-tool/src/download.rs deleted file mode 100644 index 155f446f..00000000 --- a/intel-mkl-tool/src/download.rs +++ /dev/null @@ -1,92 +0,0 @@ -use crate::{s3_addr, Config}; -use anyhow::Result; -use curl::easy::Easy; -use std::{fs, path::Path}; - -impl Config { - /// Download archive from AWS S3, and expand into `${out_dir}/*.so` - pub fn download>(&self, out_dir: P) -> Result<()> { - let out_dir = out_dir.as_ref(); - if out_dir.exists() { - fs::create_dir_all(&out_dir)?; - } - let data = read_from_url(&format!("{}/{}.tar.zst", s3_addr(), self))?; - let zstd = zstd::stream::read::Decoder::new(data.as_slice())?; - let mut arc = tar::Archive::new(zstd); - arc.unpack(&out_dir)?; - Ok(()) - } -} - -/// Helper for download file from URL -/// -/// - This function expands obtained data into memory space -/// -fn read_from_url(url: &str) -> Result> { - let mut data = Vec::new(); - let mut handle = Easy::new(); - handle.fail_on_error(true)?; - handle.url(url)?; - { - let mut transfer = handle.transfer(); - transfer - .write_function(|new_data| { - data.extend_from_slice(new_data); - Ok(new_data.len()) - }) - .unwrap(); - transfer.perform().unwrap(); - } - Ok(data) -} - -#[cfg(test)] -mod tests { - use super::*; - use std::str::FromStr; - - macro_rules! impl_test_download { - ($name:expr) => { - paste::item! { - #[test] - fn []() -> Result<()> { - let name = $name; - let cfg = Config::from_str(name)?; - cfg.download(format!("test_download/{}", name))?; - Ok(()) - } - } - }; - } - - #[cfg(target_os = "windows")] - mod macos { - use super::*; - impl_test_download!("mkl-dynamic-lp64-seq"); - impl_test_download!("mkl-dynamic-ilp64-seq"); - impl_test_download!("mkl-static-lp64-seq"); - impl_test_download!("mkl-static-ilp64-seq"); - } - - #[cfg(target_os = "macos")] - mod macos { - use super::*; - impl_test_download!("mkl-dynamic-lp64-seq"); - impl_test_download!("mkl-dynamic-lp64-iomp"); - impl_test_download!("mkl-dynamic-ilp64-seq"); - impl_test_download!("mkl-dynamic-ilp64-iomp"); - } - - #[cfg(target_os = "linux")] - mod linux { - use super::*; - impl_test_download!("mkl-dynamic-lp64-seq"); - impl_test_download!("mkl-dynamic-lp64-iomp"); - impl_test_download!("mkl-dynamic-ilp64-seq"); - impl_test_download!("mkl-dynamic-ilp64-iomp"); - impl_test_download!("mkl-static-lp64-seq"); - impl_test_download!("mkl-static-lp64-iomp"); - impl_test_download!("mkl-static-ilp64-seq"); - impl_test_download!("mkl-static-ilp64-iomp"); - } -} diff --git a/intel-mkl-tool/src/lib.rs b/intel-mkl-tool/src/lib.rs index 2664ec7f..2ce4de97 100644 --- a/intel-mkl-tool/src/lib.rs +++ b/intel-mkl-tool/src/lib.rs @@ -95,19 +95,11 @@ mod config; mod entry; -#[cfg(feature = "archive")] -mod download; -#[cfg(feature = "archive")] -mod package; - pub use config::*; pub use entry::*; -const S3_ADDR: &str = "https://s3-ap-northeast-1.amazonaws.com/rust-intel-mkl"; - #[cfg(all(target_os = "linux", target_arch = "x86_64"))] mod mkl { - pub const OS: &str = "linux"; pub const EXTENSION_STATIC: &str = "a"; pub const EXTENSION_SHARED: &str = "so"; pub const PREFIX: &str = "lib"; @@ -134,13 +126,3 @@ mod mkl { pub const VERSION_YEAR: u32 = 2020; pub const VERSION_UPDATE: u32 = 1; } - -fn s3_addr() -> String { - format!( - "{}/{}/{}.{}", - S3_ADDR, - mkl::OS, - mkl::VERSION_YEAR, - mkl::VERSION_UPDATE - ) -} diff --git a/intel-mkl-tool/src/package.rs b/intel-mkl-tool/src/package.rs deleted file mode 100644 index 59a822f7..00000000 --- a/intel-mkl-tool/src/package.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::Entry; -use anyhow::{bail, Result}; -use std::{ - fs, io, - path::{Path, PathBuf}, -}; - -impl Entry { - pub fn package(&self, out_dir: &Path) -> Result { - fs::create_dir_all(out_dir)?; - let out = out_dir.join(format!("{}.tar.zst", self.name())); - if out.exists() { - bail!("Output archive already exits: {}", out.display()); - } - let f = fs::File::create(&out)?; - let buf = io::BufWriter::new(f); - let zstd = zstd::stream::write::Encoder::new(buf, 6)?; - let mut ar = tar::Builder::new(zstd); - ar.mode(tar::HeaderMode::Deterministic); - for (path, name) in self.found_files() { - let lib = path.join(&name); - ar.append_path_with_name(lib, name)?; - } - let zstd = ar.into_inner()?; - zstd.finish()?; - Ok(out) - } -}