Skip to content

Commit 1fcc4c4

Browse files
committed
Rename Entry2 to Library, add documents
1 parent 5981d47 commit 1fcc4c4

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

intel-mkl-tool/src/entry.rs

+41-11
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,36 @@ use std::{
99
str::FromStr,
1010
};
1111

12+
/// A library found in system
1213
#[derive(Debug, Clone)]
13-
pub enum Entry2 {
14+
pub enum Library {
1415
PkgConfig {
1516
config: Config,
1617
lib: pkg_config::Library,
1718
},
1819
Directory {
1920
config: Config,
20-
root_dir: PathBuf,
21+
/// Directory where `mkl.h` and `mkl_version.h` exists
22+
include_dir: PathBuf,
23+
/// Directory where `libmkl_core.a` or `libmkl_rt.so` exists
24+
library_dir: PathBuf,
25+
/// Directory where `libiomp5.a` or `libiomp5.so` exists
26+
///
27+
/// They are sometimes placed in different position.
28+
/// Returns `None` if they exist on `library_dir`.
29+
iomp5_dir: Option<PathBuf>,
2130
},
2231
}
2332

24-
impl Entry2 {
25-
pub fn try_pkg_config(config: Config) -> Option<Self> {
33+
impl Library {
34+
/// Try to find MKL using pkg-config
35+
pub fn pkg_config(config: Config) -> Option<Self> {
2636
if let Ok(lib) = pkg_config::Config::new()
2737
.cargo_metadata(false)
2838
.env_metadata(false)
2939
.probe(&config.to_string())
3040
{
31-
Some(Entry2::PkgConfig { config, lib })
41+
Some(Library::PkgConfig { config, lib })
3242
} else {
3343
None
3444
}
@@ -39,24 +49,44 @@ impl Entry2 {
3949
/// This will seek the directory recursively until finding MKL libraries.
4050
/// Returns `Ok(None)` if not found. `Err` means IO error while seeking.
4151
///
42-
pub fn seek_directory(_config: Config, dir_root: impl AsRef<Path>) -> Result<Option<Self>> {
43-
let _dir = dir_root.as_ref();
52+
pub fn seek_directory(config: Config, root_dir: impl AsRef<Path>) -> Result<Option<Self>> {
4453
todo!()
4554
}
4655

56+
/// Seek MKL in system
57+
///
58+
/// This try to find installed MKL in following order:
59+
///
60+
/// - Ask to `pkg-config`
61+
/// - Seek the directory specified by `$MKLROOT` environment variable
62+
/// - Seek well-known directory
63+
/// - `/opt/intel` for Linux
64+
/// - `C:/Program Files (x86)/IntelSWTools/` for Windows
65+
///
4766
pub fn new(config: Config) -> Result<Self> {
4867
todo!()
4968
}
5069

5170
pub fn config(&self) -> &Config {
5271
match self {
53-
Entry2::PkgConfig { config, .. } => config,
54-
Entry2::Directory { config, .. } => config,
72+
Library::PkgConfig { config, .. } => config,
73+
Library::Directory { config, .. } => config,
5574
}
5675
}
5776

58-
/// Found MKL version parsed from `mkl_version.h`, e.g. `(2020, 1)`
59-
pub fn version(&self) -> (u32, u32) {
77+
/// Found MKL version parsed from `mkl_version.h`
78+
///
79+
/// `mkl_version.h` will define
80+
///
81+
/// ```c
82+
/// #define __INTEL_MKL__ 2020
83+
/// #define __INTEL_MKL_MINOR__ 0
84+
/// #define __INTEL_MKL_UPDATE__ 1
85+
/// ```
86+
///
87+
/// and this corresponds to `(2020, 0, 1)`
88+
///
89+
pub fn version(&self) -> (u32, u32, u32) {
6090
todo!()
6191
}
6292
}

0 commit comments

Comments
 (0)