Skip to content

Commit 3f1aa18

Browse files
Revert "[SYCL] Support online_compiler::compile compiled with pre-C++11 ABI" (#16248)
Reverts #16179 ``` template <source_language Lang> __SYCL_EXPORT std::vector<byte> online_compiler<Lang>::compile_impl( detail::string_view Src, detail::string_view DeviceStepping, const std::vector<detail::string_view> &Options) { ``` accesses `this->CompileToSPIRVHandle` which is laid out *after* `std::string` data member: ``` /// Target device stepping (implementation defined) std::string DeviceStepping; /// Handles to helper functions used by the implementation. void *CompileToSPIRVHandle = nullptr; ``` resulting in ABI incompatibility.
1 parent 705e8fe commit 3f1aa18

File tree

5 files changed

+38
-80
lines changed

5 files changed

+38
-80
lines changed

sycl/include/sycl/detail/string_view.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,14 @@ class string_view {
3737

3838
const char *data() const noexcept { return str; }
3939

40-
friend bool operator==(string_view lhs, std::string_view rhs) noexcept {
40+
friend bool operator==(const string_view &lhs,
41+
std::string_view rhs) noexcept {
4142
return rhs == lhs.data();
4243
}
43-
friend bool operator==(std::string_view lhs, string_view rhs) noexcept {
44+
friend bool operator==(std::string_view lhs,
45+
const string_view &rhs) noexcept {
4446
return lhs == rhs.data();
4547
}
46-
47-
friend bool operator!=(string_view lhs, std::string_view rhs) noexcept {
48-
return rhs != lhs.data();
49-
}
50-
friend bool operator!=(std::string_view lhs, string_view rhs) noexcept {
51-
return lhs != rhs.data();
52-
}
5348
};
5449

5550
} // namespace detail

sycl/include/sycl/ext/intel/experimental/online_compiler.hpp

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,6 @@ class __SYCL2020_DEPRECATED(
8181
"experimental online_compiler is being deprecated. See "
8282
"'sycl_ext_oneapi_kernel_compiler.asciidoc' instead for new kernel "
8383
"compiler extension to kernel_bundle implementation.") online_compiler {
84-
__SYCL_EXPORT std::vector<byte>
85-
compile_impl(sycl::detail::string_view Src,
86-
sycl::detail::string_view DeviceStepping,
87-
const std::vector<sycl::detail::string_view> &Options);
88-
89-
std::vector<byte> compile_impl(const std::string &Source,
90-
const std::vector<std::string> &UserArgs) {
91-
std::vector<sycl::detail::string_view> Args;
92-
for (auto &&Arg : UserArgs)
93-
Args.emplace_back(Arg);
94-
95-
return compile_impl(std::string_view{Source},
96-
std::string_view{DeviceStepping}, Args);
97-
}
98-
9984
public:
10085
/// Constructs online compiler which can target any device and produces
10186
/// given compiled code format. Produces 64-bit device code.
@@ -211,17 +196,9 @@ class __SYCL2020_DEPRECATED(
211196
/// OpenCL JIT compiler options must be supported.
212197
template <>
213198
template <>
214-
#if !defined(__SYCL_ONLINE_COMPILER_CPP) || \
215-
defined(__INTEL_PREVIEW_BREAKING_CHANGES)
216-
inline
217-
#else
218-
__SYCL_EXPORT
219-
#endif
220-
std::vector<byte>
221-
online_compiler<source_language::opencl_c>::compile(
222-
const std::string &src, const std::vector<std::string> &options) {
223-
return compile_impl(src, options);
224-
}
199+
__SYCL_EXPORT std::vector<byte>
200+
online_compiler<source_language::opencl_c>::compile(
201+
const std::string &src, const std::vector<std::string> &options);
225202

226203
/// Compiles the given OpenCL source. May throw \c online_compile_error.
227204
/// @param src - contents of the source.
@@ -237,17 +214,8 @@ online_compiler<source_language::opencl_c>::compile(const std::string &src) {
237214
/// @param options - compilation options (implementation defined).
238215
template <>
239216
template <>
240-
#if !defined(__SYCL_ONLINE_COMPILER_CPP) || \
241-
defined(__INTEL_PREVIEW_BREAKING_CHANGES)
242-
inline
243-
#else
244-
__SYCL_EXPORT
245-
#endif
246-
std::vector<byte>
247-
online_compiler<source_language::cm>::compile(
248-
const std::string &src, const std::vector<std::string> &options) {
249-
return compile_impl(src, options);
250-
}
217+
__SYCL_EXPORT std::vector<byte> online_compiler<source_language::cm>::compile(
218+
const std::string &src, const std::vector<std::string> &options);
251219

252220
/// Compiles the given CM source \p src.
253221
template <>

sycl/source/detail/online_compiler/online_compiler.cpp

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#define __SYCL_ONLINE_COMPILER_CPP
10-
119
#include <sycl/detail/os_util.hpp>
1210
#include <sycl/detail/ur.hpp>
1311
#include <sycl/ext/intel/experimental/online_compiler.hpp>
@@ -21,11 +19,9 @@ inline namespace _V1 {
2119
namespace ext::intel::experimental {
2220
namespace detail {
2321

24-
using namespace sycl::detail;
25-
2622
static std::vector<const char *>
2723
prepareOclocArgs(sycl::info::device_type DeviceType, device_arch DeviceArch,
28-
bool Is64Bit, string_view DeviceStepping,
24+
bool Is64Bit, const std::string &DeviceStepping,
2925
const std::string &UserArgs) {
3026
std::vector<const char *> Args = {"ocloc", "-q", "-spv_only", "-device"};
3127

@@ -58,7 +54,7 @@ prepareOclocArgs(sycl::info::device_type DeviceType, device_arch DeviceArch,
5854

5955
if (DeviceStepping != "") {
6056
Args.push_back("-revision_id");
61-
Args.push_back(DeviceStepping.data());
57+
Args.push_back(DeviceStepping.c_str());
6258
}
6359

6460
Args.push_back(Is64Bit ? "-64" : "-32");
@@ -86,11 +82,11 @@ prepareOclocArgs(sycl::info::device_type DeviceType, device_arch DeviceArch,
8682
/// allocated during the compilation.
8783
/// @param UserArgs - User's options to ocloc compiler.
8884
static std::vector<byte>
89-
compileToSPIRV(string_view Src, sycl::info::device_type DeviceType,
90-
device_arch DeviceArch, bool Is64Bit, string_view DeviceStepping,
91-
void *&CompileToSPIRVHandle, void *&FreeSPIRVOutputsHandle,
85+
compileToSPIRV(const std::string &Source, sycl::info::device_type DeviceType,
86+
device_arch DeviceArch, bool Is64Bit,
87+
const std::string &DeviceStepping, void *&CompileToSPIRVHandle,
88+
void *&FreeSPIRVOutputsHandle,
9289
const std::vector<std::string> &UserArgs) {
93-
std::string Source{Src.data()};
9490

9591
if (!CompileToSPIRVHandle) {
9692
#ifdef __SYCL_RT_OS_WINDOWS
@@ -202,10 +198,11 @@ compileToSPIRV(string_view Src, sycl::info::device_type DeviceType,
202198
}
203199
} // namespace detail
204200

205-
template <source_language Lang>
206-
__SYCL_EXPORT std::vector<byte> online_compiler<Lang>::compile_impl(
207-
detail::string_view Src, detail::string_view DeviceStepping,
208-
const std::vector<detail::string_view> &Options) {
201+
template <>
202+
template <>
203+
__SYCL_EXPORT std::vector<byte>
204+
online_compiler<source_language::opencl_c>::compile(
205+
const std::string &Source, const std::vector<std::string> &UserArgs) {
209206

210207
if (OutputFormatVersion != std::pair<int, int>{0, 0}) {
211208
std::string Version = std::to_string(OutputFormatVersion.first) + ", " +
@@ -214,27 +211,29 @@ __SYCL_EXPORT std::vector<byte> online_compiler<Lang>::compile_impl(
214211
Version + ") is not supported yet");
215212
}
216213

217-
std::vector<std::string> UserArgs;
218-
for (auto &&Opt : Options)
219-
UserArgs.emplace_back(Opt.data());
220-
221-
if constexpr (Lang == source_language::cm)
222-
UserArgs.push_back("-cmc");
223-
224-
return detail::compileToSPIRV(Src, DeviceType, DeviceArch, Is64Bit,
214+
return detail::compileToSPIRV(Source, DeviceType, DeviceArch, Is64Bit,
225215
DeviceStepping, CompileToSPIRVHandle,
226216
FreeSPIRVOutputsHandle, UserArgs);
227217
}
228218

229-
template __SYCL_EXPORT std::vector<byte>
230-
online_compiler<source_language::opencl_c>::compile_impl(
231-
detail::string_view Src, detail::string_view DeviceStepping,
232-
const std::vector<detail::string_view> &Options);
219+
template <>
220+
template <>
221+
__SYCL_EXPORT std::vector<byte> online_compiler<source_language::cm>::compile(
222+
const std::string &Source, const std::vector<std::string> &UserArgs) {
233223

234-
template __SYCL_EXPORT std::vector<byte>
235-
online_compiler<source_language::cm>::compile_impl(
236-
detail::string_view Src, detail::string_view DeviceStepping,
237-
const std::vector<detail::string_view> &Options);
224+
if (OutputFormatVersion != std::pair<int, int>{0, 0}) {
225+
std::string Version = std::to_string(OutputFormatVersion.first) + ", " +
226+
std::to_string(OutputFormatVersion.second);
227+
throw online_compile_error(std::string("The output format version (") +
228+
Version + ") is not supported yet");
229+
}
230+
231+
std::vector<std::string> CMUserArgs = UserArgs;
232+
CMUserArgs.push_back("-cmc");
233+
return detail::compileToSPIRV(Source, DeviceType, DeviceArch, Is64Bit,
234+
DeviceStepping, CompileToSPIRVHandle,
235+
FreeSPIRVOutputsHandle, CMUserArgs);
236+
}
238237
} // namespace ext::intel::experimental
239238

240239
namespace ext {

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,9 +2985,7 @@ _ZN4sycl3_V121__isgreaterequal_implEdd
29852985
_ZN4sycl3_V121__isgreaterequal_implEff
29862986
_ZN4sycl3_V122accelerator_selector_vERKNS0_6deviceE
29872987
_ZN4sycl3_V128verifyUSMAllocatorPropertiesERKNS0_13property_listE
2988-
_ZN4sycl3_V13ext5intel12experimental15online_compilerILNS3_15source_languageE0EE12compile_implENS0_6detail11string_viewES8_RKSt6vectorIS8_SaIS8_EE
29892988
_ZN4sycl3_V13ext5intel12experimental15online_compilerILNS3_15source_languageE0EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISE_EEEEES8_IhSaIhEERKSE_DpRKT_
2990-
_ZN4sycl3_V13ext5intel12experimental15online_compilerILNS3_15source_languageE1EE12compile_implENS0_6detail11string_viewES8_RKSt6vectorIS8_SaIS8_EE
29912989
_ZN4sycl3_V13ext5intel12experimental15online_compilerILNS3_15source_languageE1EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISE_EEEEES8_IhSaIhEERKSE_DpRKT_
29922990
_ZN4sycl3_V13ext5intel12experimental9pipe_base13get_pipe_nameB5cxx11EPKv
29932991
_ZN4sycl3_V13ext5intel12experimental9pipe_base17wait_non_blockingERKNS0_5eventE

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,8 +3743,6 @@
37433743
?category@exception@_V1@sycl@@QEBAAEBVerror_category@std@@XZ
37443744
?clearArgs@handler@_V1@sycl@@AEAAXXZ
37453745
?code@exception@_V1@sycl@@QEBAAEBVerror_code@std@@XZ
3746-
?compile_impl@?$online_compiler@$00@experimental@intel@ext@_V1@sycl@@AEAA?AV?$vector@EV?$allocator@E@std@@@std@@Vstring_view@detail@56@0AEBV?$vector@Vstring_view@detail@_V1@sycl@@V?$allocator@Vstring_view@detail@_V1@sycl@@@std@@@8@@Z
3747-
?compile_impl@?$online_compiler@$0A@@experimental@intel@ext@_V1@sycl@@AEAA?AV?$vector@EV?$allocator@E@std@@@std@@Vstring_view@detail@56@0AEBV?$vector@Vstring_view@detail@_V1@sycl@@V?$allocator@Vstring_view@detail@_V1@sycl@@@std@@@8@@Z
37483746
?compile_impl@detail@_V1@sycl@@YA?AV?$shared_ptr@Vkernel_bundle_impl@detail@_V1@sycl@@@std@@AEBV?$kernel_bundle@$0A@@23@AEBV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@5@AEBVproperty_list@23@@Z
37493747
?complete_fusion@fusion_wrapper@experimental@codeplay@ext@_V1@sycl@@QEAA?AVevent@56@AEBVproperty_list@56@@Z
37503748
?computeFallbackKernelBounds@handler@_V1@sycl@@AEAA?AV?$id@$01@23@_K0@Z

0 commit comments

Comments
 (0)