|
26 | 26 | # *****************************************************************************
|
27 | 27 |
|
28 | 28 | import os
|
| 29 | +import sys |
29 | 30 |
|
30 | 31 |
|
31 | 32 | IS_CONDA_BUILD = os.environ.get("CONDA_BUILD") == "1"
|
32 | 33 |
|
| 34 | +IS_WIN = False |
| 35 | +IS_MAC = False |
| 36 | +IS_LIN = False |
| 37 | + |
| 38 | +if 'linux' in sys.platform: |
| 39 | + IS_LIN = True |
| 40 | +elif sys.platform == 'darwin': |
| 41 | + IS_MAC = True |
| 42 | +elif sys.platform in ['win32', 'cygwin']: |
| 43 | + IS_WIN = True |
| 44 | +else: |
| 45 | + raise EnvironmentError(f"Intel NumPy: {sys.platform} not supported") |
| 46 | + |
33 | 47 |
|
34 | 48 | def find_library(var_name, rel_header_paths, rel_lib_paths,
|
35 | 49 | rel_include_path="include", rel_libdir_path="lib", verbose=False):
|
@@ -76,6 +90,57 @@ def find_library(var_name, rel_header_paths, rel_lib_paths,
|
76 | 90 | return [include_find], [libpath_find]
|
77 | 91 |
|
78 | 92 |
|
| 93 | +def _find_cmplr_in_dpcpp_root(verbose=False): |
| 94 | + """ |
| 95 | + Find compiler in dpcpp root using $DPCPPROOT. |
| 96 | +
|
| 97 | + Parameters |
| 98 | + ---------- |
| 99 | + verbose : bool |
| 100 | + to print paths to include and library directories |
| 101 | +
|
| 102 | + Returns |
| 103 | + ------- |
| 104 | + tuple(list(str), list(str)) |
| 105 | + path to include directory, path to library directory |
| 106 | + """ |
| 107 | + rel_header_paths = rel_lib_paths = [] |
| 108 | + |
| 109 | + if IS_LIN: |
| 110 | + rel_include_path = os.path.join('linux', 'include') |
| 111 | + rel_libdir_path = os.path.join('linux', 'lib') |
| 112 | + elif IS_WIN: |
| 113 | + rel_include_path = os.path.join('windows', 'include') |
| 114 | + rel_libdir_path = os.path.join('windows', 'lib') |
| 115 | + else: |
| 116 | + rel_include_path, rel_libdir_path = 'include', 'lib' |
| 117 | + |
| 118 | + return find_library("DPCPPROOT", rel_header_paths, rel_lib_paths, |
| 119 | + rel_include_path=rel_include_path, rel_libdir_path=rel_libdir_path, verbose=verbose) |
| 120 | + |
| 121 | + |
| 122 | +def find_cmplr(verbose=False): |
| 123 | + """ |
| 124 | + Find compiler in environment. |
| 125 | +
|
| 126 | + Parameters |
| 127 | + ---------- |
| 128 | + verbose : bool |
| 129 | + to print paths to include and library directories |
| 130 | +
|
| 131 | + Returns |
| 132 | + ------- |
| 133 | + tuple(list(str), list(str)) |
| 134 | + path to include directory, path to library directory |
| 135 | + """ |
| 136 | + cmplr_include, cmplr_libpath = _find_cmplr_in_dpcpp_root(verbose=verbose) |
| 137 | + |
| 138 | + if not cmplr_include or not cmplr_libpath: |
| 139 | + raise EnvironmentError(f"Intel DPNP: Unable to find compiler. Please install Intel OneAPI environment") |
| 140 | + |
| 141 | + return cmplr_include, cmplr_libpath |
| 142 | + |
| 143 | + |
79 | 144 | def _find_mathlib_in_conda_root(verbose=False):
|
80 | 145 | """
|
81 | 146 | Find mathlib in conda root using $CONDA_PREFIX or $PREFIX.
|
@@ -142,3 +207,54 @@ def find_mathlib(verbose=False):
|
142 | 207 | raise EnvironmentError("Intel DPNP: Unable to find math library")
|
143 | 208 |
|
144 | 209 | return mathlib_include, mathlib_path
|
| 210 | + |
| 211 | + |
| 212 | +def _find_omp_in_dpcpp_root(verbose=False): |
| 213 | + """ |
| 214 | + Find omp in dpcpp root using $DPCPPROOT. |
| 215 | +
|
| 216 | + Parameters |
| 217 | + ---------- |
| 218 | + verbose : bool |
| 219 | + to print paths to include and library directories |
| 220 | +
|
| 221 | + Returns |
| 222 | + ------- |
| 223 | + tuple(list(str), list(str)) |
| 224 | + path to include directory, path to library directory |
| 225 | + """ |
| 226 | + rel_header_paths = rel_lib_paths = [] |
| 227 | + |
| 228 | + if IS_LIN: |
| 229 | + rel_include_path = os.path.join('linux', 'compiler', 'include') |
| 230 | + rel_libdir_path = os.path.join('linux', 'compiler', 'lib', 'intel64') |
| 231 | + elif IS_WIN: |
| 232 | + rel_include_path = os.path.join('windows', 'compiler', 'include') |
| 233 | + rel_libdir_path = os.path.join('windows', 'compiler', 'lib', 'intel64_win') |
| 234 | + else: |
| 235 | + rel_include_path, rel_libdir_path = 'include', 'lib' |
| 236 | + |
| 237 | + return find_library("DPCPPROOT", rel_header_paths, rel_lib_paths, |
| 238 | + rel_include_path=rel_include_path, rel_libdir_path=rel_libdir_path, verbose=verbose) |
| 239 | + |
| 240 | + |
| 241 | +def find_omp(verbose=False): |
| 242 | + """ |
| 243 | + Find omp in environment. |
| 244 | +
|
| 245 | + Parameters |
| 246 | + ---------- |
| 247 | + verbose : bool |
| 248 | + to print paths to include and library directories |
| 249 | +
|
| 250 | + Returns |
| 251 | + ------- |
| 252 | + tuple(list(str), list(str)) |
| 253 | + path to include directory, path to library directory |
| 254 | + """ |
| 255 | + omp_include, omp_libpath = _find_omp_in_dpcpp_root(verbose=verbose) |
| 256 | + |
| 257 | + if not omp_include or not omp_libpath: |
| 258 | + raise EnvironmentError(f"Intel DPNP: Unable to find omp. Please install Intel OneAPI environment") |
| 259 | + |
| 260 | + return omp_include, omp_libpath |
0 commit comments