rust-math / intel-mkl-src

Redistribute Intel MKL as a crate
Other
77 stars 22 forks source link

Unable to link with HPC intel-mkl #107

Open matthagan15 opened 1 year ago

matthagan15 commented 1 year ago

Hi I'm trying to get a simple ndarray setup using BLAS on a HPC cluster working with intel-mkl as the BLAS library. Unfortunately even a bare bones setup is unable to find the proper library, and even a simple binary just doing a matrix multiplication fails to build. After loading the proper modules and checking that the intel-mkl library is accessible (I can navigate through the mkl folders, I can find blas libraries, and $MKLROOT points to the proper path and so does pkg-config -- variable=prefix mkl-static-lp64-seq) I try to build a basic binary with the following Cargo.toml:

[package]
name = "tester"
version = "0.1.0"
edition = "2021"

[dependencies]
ndarray = {version = "0.15.0", features = ["blas"]}
blas-src = {version = "0.8.0", features = ["intel-mkl"]}
intel-mkl-src = {version = "*"}

and I get a bunch of errors like the following: /gpfs/fs1/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/zstd-sys-1.4.18+zstd.1.4.7/zstd/lib/common/xxhash.c:85: undefined reference to `_intel_fast_memcpy' with the following "help"

collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `intel-mkl-src` due to previous error

I know that the HPC FAQ specifies that a -mkl flag should be passed to gcc if linking against intel-mkl with c++ but I was not sure how to add that into here or if it would be necessary. Any help would be appreciated.