Skip to content

Commit c60ab88

Browse files
authored
[DLE2025.2] Fix warning: ext_oneapi_get_default_context is deprecated: use khr_get_default_context() instead (#4973)
Locally on subset tests - works. CI is still not successful for some reason: #4963 ~The implementation in PyTorch gives confidence in these changes https://github.com/pytorch/pytorch/blob/06c7516994d6fdd4b1ac8b8aeae74cdcae0d34f4/c10/xpu/XPUFunctions.cpp#L138~ **UPD:** Pytorch approach doesn't suit us, they define the version `SYCL_COMPILER_VERSION` in https://github.com/pytorch/pytorch/blob/2a70d98abf8256d3d768eff028fca20198579824/cmake/Modules/FindSYCLToolkit.cmake#L60, using `icpx --version`. Since `icpx` is not always available to us, we will have to use the sycl version, which is defined directly in `sycl/version.cpp` header (however, the version must be determined carefully, since it does not match the version Pytorch uses). For example: 2025.2.0 ```cpp // from sycl/version.hpp #define __SYCL_COMPILER_VERSION 20250604 #define __LIBSYCL_MAJOR_VERSION 8 #define __LIBSYCL_MINOR_VERSION 0 #define __LIBSYCL_PATCH_VERSION 0 ``` ```bash icpx --version Intel(R) oneAPI DPC++/C++ Compiler 2025.2.0 (2025.2.0.20250605) ``` vs 2025.1.1 ```cpp // from sycl/version.hpp #define __SYCL_COMPILER_VERSION 20250418 #define __LIBSYCL_MAJOR_VERSION 8 #define __LIBSYCL_MINOR_VERSION 0 #define __LIBSYCL_PATCH_VERSION 0 ``` ```bash icpx --version Intel(R) oneAPI DPC++/C++ Compiler 2025.1.1 (2025.1.1.20250418) ``` Candidate for cherry-pick. --------- Signed-off-by: Anatoly Myachev <[email protected]>
1 parent 4ee3353 commit c60ab88

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

third_party/intel/backend/arch_parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" EXPORT_FUNC const char *parse_device_arch(uint64_t dev_arch) {
4343
case sycl::ext::oneapi::experimental::architecture::intel_gpu_pvc:
4444
arch = "pvc";
4545
break;
46-
#if SYCL_COMPILER_VERSION >= 20250000
46+
#if __SYCL_COMPILER_VERSION >= 20250000
4747
case sycl::ext::oneapi::experimental::architecture::intel_gpu_ptl_h:
4848
arch = "ptl_h";
4949
break;

third_party/intel/backend/driver.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,27 @@ sycl::context get_default_context(const sycl::device &sycl_device) {
169169
#ifdef WIN32
170170
sycl::context ctx;
171171
try {
172+
#if __SYCL_COMPILER_VERSION >= 20250604
173+
ctx = platform.khr_get_default_context();
174+
#else
172175
ctx = platform.ext_oneapi_get_default_context();
176+
#endif
173177
} catch (const std::runtime_error &ex) {
174178
// This exception is thrown on Windows because
175-
// ext_oneapi_get_default_context is not implemented. But it can be safely
179+
// khr_get_default_context is not implemented. But it can be safely
176180
// ignored it seems.
177181
#if _DEBUG
178182
std::cout << "ERROR: " << ex.what() << std::endl;
179183
#endif
180184
}
181185
return ctx;
186+
#else
187+
#if __SYCL_COMPILER_VERSION >= 20250604
188+
return platform.khr_get_default_context();
182189
#else
183190
return platform.ext_oneapi_get_default_context();
184191
#endif
192+
#endif
185193
}
186194

187195
extern "C" EXPORT_FUNC PyObject *load_binary(PyObject *args) {

third_party/intel/tools/intel/compile.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ unsigned char BIN_NAME[{bin_size}] = {{ {bin_data} }};
3232
// sycl globals
3333
const sycl::device sycl_device;
3434
const auto ctx =
35+
#if __SYCL_COMPILER_VERSION >= 20250604
36+
sycl_device.get_platform().khr_get_default_context();
37+
#else
3538
sycl_device.get_platform().ext_oneapi_get_default_context();
39+
#endif
3640
const auto l0_device =
3741
sycl::get_native<sycl::backend::ext_oneapi_level_zero>(sycl_device);
3842
const auto l0_context =

utils/SPIRVRunner/SPIRVRunner.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,27 @@ sycl::context get_default_context(const sycl::device &sycl_device) {
127127
#ifdef WIN32
128128
sycl::context ctx;
129129
try {
130+
#if __SYCL_COMPILER_VERSION >= 20250604
131+
ctx = platform.khr_get_default_context();
132+
#else
130133
ctx = platform.ext_oneapi_get_default_context();
134+
#endif
131135
} catch (const std::runtime_error &ex) {
132136
// This exception is thrown on Windows because
133-
// ext_oneapi_get_default_context is not implemented. But it can be safely
137+
// khr_get_default_context is not implemented. But it can be safely
134138
// ignored it seems.
135139
#if _DEBUG
136140
std::cout << "ERROR: " << ex.what() << std::endl;
137141
#endif
138142
}
139143
return ctx;
144+
#else
145+
#if __SYCL_COMPILER_VERSION >= 20250604
146+
return platform.khr_get_default_context();
140147
#else
141148
return platform.ext_oneapi_get_default_context();
142149
#endif
150+
#endif
143151
}
144152

145153
/** SYCL Functions **/

0 commit comments

Comments
 (0)