|
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"
|
@@ -76,6 +77,57 @@ def find_library(var_name, rel_header_paths, rel_lib_paths,
|
76 | 77 | return [include_find], [libpath_find]
|
77 | 78 |
|
78 | 79 |
|
| 80 | +def _find_cmplr_in_dpcpp_root(verbose=False): |
| 81 | + """ |
| 82 | + Find compiler in dpcpp root using $DPCPPROOT. |
| 83 | +
|
| 84 | + Parameters |
| 85 | + ---------- |
| 86 | + verbose : bool |
| 87 | + to print paths to include and library directories |
| 88 | +
|
| 89 | + Returns |
| 90 | + ------- |
| 91 | + tuple(list(str), list(str)) |
| 92 | + path to include directory, path to library directory |
| 93 | + """ |
| 94 | + rel_header_paths = rel_lib_paths = [] |
| 95 | + |
| 96 | + if 'linux' in sys.platform: |
| 97 | + rel_include_path = os.path.join('linux', 'include') |
| 98 | + rel_libdir_path = os.path.join('linux', 'lib') |
| 99 | + elif sys.platform in ['win32', 'cygwin']: |
| 100 | + rel_include_path = os.path.join('windows', 'include') |
| 101 | + rel_libdir_path = os.path.join('windows', 'lib') |
| 102 | + else: |
| 103 | + rel_include_path, rel_libdir_path = 'include', 'lib' |
| 104 | + |
| 105 | + return find_library("DPCPPROOT", rel_header_paths, rel_lib_paths, |
| 106 | + rel_include_path=rel_include_path, rel_libdir_path=rel_libdir_path, verbose=verbose) |
| 107 | + |
| 108 | + |
| 109 | +def find_cmplr(verbose=False): |
| 110 | + """ |
| 111 | + Find compiler in environment. |
| 112 | +
|
| 113 | + Parameters |
| 114 | + ---------- |
| 115 | + verbose : bool |
| 116 | + to print paths to include and library directories |
| 117 | +
|
| 118 | + Returns |
| 119 | + ------- |
| 120 | + tuple(list(str), list(str)) |
| 121 | + path to include directory, path to library directory |
| 122 | + """ |
| 123 | + cmplr_include, cmplr_libpath = _find_cmplr_in_dpcpp_root(verbose=verbose) |
| 124 | + |
| 125 | + if not cmplr_include or not cmplr_libpath: |
| 126 | + raise EnvironmentError(f"Intel DPNP: Unable to find compiler. Please install Intel OneAPI environment") |
| 127 | + |
| 128 | + return cmplr_include, cmplr_libpath |
| 129 | + |
| 130 | + |
79 | 131 | def _find_mathlib_in_conda_root(verbose=False):
|
80 | 132 | """
|
81 | 133 | Find mathlib in conda root using $CONDA_PREFIX or $PREFIX.
|
@@ -142,3 +194,54 @@ def find_mathlib(verbose=False):
|
142 | 194 | raise EnvironmentError("Intel DPNP: Unable to find math library")
|
143 | 195 |
|
144 | 196 | return mathlib_include, mathlib_path
|
| 197 | + |
| 198 | + |
| 199 | +def _find_omp_in_dpcpp_root(verbose=False): |
| 200 | + """ |
| 201 | + Find omp in dpcpp root using $DPCPPROOT. |
| 202 | +
|
| 203 | + Parameters |
| 204 | + ---------- |
| 205 | + verbose : bool |
| 206 | + to print paths to include and library directories |
| 207 | +
|
| 208 | + Returns |
| 209 | + ------- |
| 210 | + tuple(list(str), list(str)) |
| 211 | + path to include directory, path to library directory |
| 212 | + """ |
| 213 | + rel_header_paths = rel_lib_paths = [] |
| 214 | + |
| 215 | + if 'linux' in sys.platform: |
| 216 | + rel_include_path = os.path.join('linux', 'compiler', 'include') |
| 217 | + rel_libdir_path = os.path.join('linux', 'compiler', 'lib', 'intel64') |
| 218 | + elif sys.platform in ['win32', 'cygwin']: |
| 219 | + rel_include_path = os.path.join('windows', 'compiler', 'include') |
| 220 | + rel_libdir_path = os.path.join('windows', 'compiler', 'lib', 'intel64_win') |
| 221 | + else: |
| 222 | + rel_include_path, rel_libdir_path = 'include', 'lib' |
| 223 | + |
| 224 | + return find_library("DPCPPROOT", rel_header_paths, rel_lib_paths, |
| 225 | + rel_include_path=rel_include_path, rel_libdir_path=rel_libdir_path, verbose=verbose) |
| 226 | + |
| 227 | + |
| 228 | +def find_omp(verbose=False): |
| 229 | + """ |
| 230 | + Find omp in environment. |
| 231 | +
|
| 232 | + Parameters |
| 233 | + ---------- |
| 234 | + verbose : bool |
| 235 | + to print paths to include and library directories |
| 236 | +
|
| 237 | + Returns |
| 238 | + ------- |
| 239 | + tuple(list(str), list(str)) |
| 240 | + path to include directory, path to library directory |
| 241 | + """ |
| 242 | + omp_include, omp_libpath = _find_omp_in_dpcpp_root(verbose=verbose) |
| 243 | + |
| 244 | + if not omp_include or not omp_libpath: |
| 245 | + raise EnvironmentError(f"Intel DPNP: Unable to find omp. Please install Intel OneAPI environment") |
| 246 | + |
| 247 | + return omp_include, omp_libpath |
0 commit comments