Skip to content

Commit 4302bcb

Browse files
committed
WIP: impl Config
1 parent 1b77faa commit 4302bcb

File tree

3 files changed

+69
-7
lines changed

3 files changed

+69
-7
lines changed

intel-mkl-tool/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ cli = ["structopt", "env_logger"]
1616
[dependencies]
1717
anyhow = "1.0.31"
1818
curl = "0.4.25"
19+
derive_more = "0.99.7"
1920
dirs = "2.0.2"
21+
failure = "0.1.6"
2022
glob = "0.3.0"
2123
log = "0.4.8"
2224
pkg-config = "0.3.17"
@@ -26,4 +28,3 @@ zstd = "0.5.1"
2628
# CLI
2729
structopt = { version = "0.3.5", optional = true }
2830
env_logger = { version = "0.7.1", optional = true }
29-
derive_more = "0.99.7"

intel-mkl-tool/src/config.rs

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use derive_more::Display;
2+
use failure::*;
3+
use std::path::*;
24

35
#[derive(Debug, Clone, Copy, PartialEq, Display)]
46
pub enum Link {
@@ -32,24 +34,82 @@ pub struct Config {
3234
}
3335

3436
impl Config {
35-
fn as_pkg_config_name(&self) -> String {
37+
pub fn from_name(_name: &str) -> Fallible<Self> {
38+
todo!()
39+
}
40+
41+
/// identifier used in pkg-config
42+
pub fn name(&self) -> String {
3643
format!("mkl-{}-{}-{}", self.link, self.index_size, self.parallel)
3744
}
3845

46+
fn base_dir(&self) -> PathBuf {
47+
todo!()
48+
}
49+
50+
/// Static and shared library lists to be linked
51+
pub fn libs(
52+
&self,
53+
) -> (
54+
Vec<PathBuf>, /* static */
55+
Vec<String>, /* shared */
56+
) {
57+
// FIXME this implementation is for Linux, fix for Windows and macOS
58+
let mut static_libs = Vec::new();
59+
let mut shared_libs = vec!["pthread".into(), "m".into(), "dl".into()];
60+
61+
let mut add = |name: &str| match self.link {
62+
Link::Static => {
63+
let base_dir: PathBuf = self.base_dir();
64+
let path = base_dir.join(format!("lib{}.a", name));
65+
assert!(path.exists());
66+
static_libs.push(path);
67+
}
68+
Link::Shared => {
69+
shared_libs.push(name.to_string());
70+
}
71+
};
72+
73+
add("mkl_core");
74+
match self.index_size {
75+
IndexSize::LP64 => {
76+
add("mkl_intel_lp64");
77+
}
78+
IndexSize::ILP64 => {
79+
add("mkl_intel_ilp64");
80+
}
81+
};
82+
match self.parallel {
83+
Parallel::OpenMP => {
84+
add("iomp5");
85+
add("mkl_intel_thread");
86+
}
87+
Parallel::Sequential => {
88+
add("mkl_sequential");
89+
}
90+
};
91+
(static_libs, shared_libs)
92+
}
93+
3994
/// Check if pkg-config has a corresponding setting
40-
pub fn is_pkg_config_managed(&self) -> bool {
95+
pub fn pkg_config(&self) -> Option<pkg_config::Library> {
4196
pkg_config::Config::new()
4297
.cargo_metadata(false)
43-
.probe(&self.as_pkg_config_name())
44-
.is_ok()
98+
.probe(&self.name())
99+
.ok()
45100
}
46101

47102
/// Check if archive is cached in $XDG_DATA_HOME
48-
pub fn is_cached(&self) -> bool {
103+
pub fn exists(&self) -> bool {
104+
todo!()
105+
}
106+
107+
/// Download MKL archive and cache into $XDG_DATA_HOME
108+
pub fn download(&self) -> PathBuf {
49109
todo!()
50110
}
51111

52112
pub fn print_cargo_metadata(&self) {
53-
//
113+
todo!()
54114
}
55115
}

intel-mkl-tool/src/download.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ mod tests {
4545
use super::*;
4646
use crate::mkl;
4747

48+
#[ignore]
4849
#[test]
4950
fn download_url() {
5051
let url = format!(

0 commit comments

Comments
 (0)