Skip to content

Commit c3ec188

Browse files
authored
Implement CONDA based MKL paths (#121)
* Implement CONDA based MKL paths
1 parent 2d7556b commit c3ec188

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

setup.py

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,54 @@
200200
_omp_rpath = []
201201

202202

203-
_mkl_root = os.environ.get('MKLROOT', None)
204-
if _mkl_root is None:
205-
raise EnvironmentError("Intel NumPy: Please install Intel OneAPI environment. MKLROOT is empty")
206-
_mkl_include = [os.path.join(_mkl_root, 'include')]
203+
"""
204+
Get the math library environemnt
205+
"""
206+
_mkl_include = None
207+
_mkl_libpath = None
208+
# TODO make it as a function in utils
209+
_conda_root = os.environ.get("CONDA_PREFIX", None)
210+
if _mkl_include is None and _mkl_libpath is None and _conda_root is not None:
211+
_mkl_include_find = os.path.join(_conda_root, "include")
212+
_mkl_libpath_find = os.path.join(_conda_root, "lib")
213+
_required_header = os.path.join(_mkl_include_find, "mkl_blas_sycl.hpp")
214+
_required_library = os.path.join(_mkl_libpath_find, "libmkl_sycl.so")
215+
216+
if (os.path.exists(_required_header) and os.path.exists(_required_library)):
217+
print(
218+
f"Intel DPNP: using $CONDA_PREFIX based math library. include={_mkl_include_find}, libpath={_mkl_libpath_find}")
219+
_mkl_include = [_mkl_include_find]
220+
_mkl_libpath = [_mkl_libpath_find]
221+
222+
223+
_mkl_root = os.environ.get("MKLROOT", None)
224+
if _mkl_include is None and _mkl_libpath is None and _mkl_root is not None:
225+
_mkl_include_find = os.path.join(_mkl_root, "include")
226+
_mkl_libpath_find = os.path.join(_mkl_root, "lib", "intel64")
227+
_required_header = os.path.join(_mkl_include_find, "mkl_blas_sycl.hpp")
228+
_required_library = os.path.join(_mkl_libpath_find, "libmkl_sycl.so")
229+
230+
if (os.path.exists(_required_header) and os.path.exists(_required_library)):
231+
print(
232+
f"Intel DPNP: using $MKLROOT based math library. include={_mkl_include_find}, libpath={_mkl_libpath_find}")
233+
_mkl_include = [_mkl_include_find]
234+
_mkl_libpath = [_mkl_libpath_find]
235+
236+
if _mkl_include is None and _mkl_libpath is None:
237+
raise EnvironmentError("Intel DPNP: Please install Intel OneAPI environment. MKLROOT is empty")
238+
239+
_project_cmplr_macro += [("MKL_ILP64", "1")] # using 64bit integers in MKL interface (long)
207240
_mkl_libs = ["mkl_rt", "mkl_sycl", "mkl_intel_ilp64", "mkl_sequential",
208241
"mkl_core", "sycl", "OpenCL", "pthread", "m", "dl"]
209-
_project_cmplr_macro += [("MKL_ILP64", "1")] # using 64bit integers in MKL interface (long)
210242

211-
_mkl_libpath = [os.path.join(_mkl_root, 'lib', 'intel64')]
212243
if IS_LIN:
213244
_mkl_rpath = _mkl_libpath
214245
elif IS_WIN:
215246
_mkl_libs = ["mkl_sycl", "mkl_intel_ilp64", "mkl_tbb_thread", "mkl_core", "sycl", "OpenCL", "tbb"]
216247

248+
"""
249+
Get the compiler environemnt
250+
"""
217251
_cmplr_root = os.environ.get('ONEAPI_ROOT', None)
218252
if _cmplr_root is None:
219253
raise EnvironmentError("Please install Intel OneAPI environment. ONEAPI_ROOT is empty")

0 commit comments

Comments
 (0)