Skip to content

Commit b466cd0

Browse files
[SYCL] Fix unintentional vtable ABI break in HostKernelBase (#15310)
The changes in #15256 unintentionally broke ABI by reordering the virtual member functions of HostKernelBase. This commit amends this by moving the new function to the end of the new member function. Additionally, this fixes a typo in the new function. --------- Signed-off-by: Larsen, Steffen <[email protected]> Co-authored-by: Marcos Maronas <[email protected]>
1 parent 0546dc1 commit b466cd0

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

sycl/include/sycl/detail/cg_types.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ runKernelWithArg(KernelType KernelName, ArgType Arg) {
154154
// The pure virtual class aimed to store lambda/functors of any type.
155155
class HostKernelBase {
156156
public:
157-
// NOTE: InstatitateKernelOnHost() should not be called.
158-
virtual void InstatitateKernelOnHost() = 0;
159157
// Return pointer to the lambda object.
160158
// Used to extract captured variables.
161159
virtual char *getPtr() = 0;
162160
virtual ~HostKernelBase() = default;
161+
// NOTE: InstatiateKernelOnHost() should not be called.
162+
virtual void InstantiateKernelOnHost() = 0;
163163
};
164164

165165
// Class which stores specific lambda object.
@@ -174,11 +174,15 @@ class HostKernel : public HostKernelBase {
174174
public:
175175
HostKernel(KernelType Kernel) : MKernel(Kernel) {}
176176

177+
char *getPtr() override { return reinterpret_cast<char *>(&MKernel); }
178+
179+
~HostKernel() = default;
180+
177181
// This function is needed for host-side compilation to keep kernels
178182
// instantitated. This is important for debuggers to be able to associate
179183
// kernel code instructions with source code lines.
180-
// NOTE: InstatitateKernelOnHost() should not be called.
181-
void InstatitateKernelOnHost() override {
184+
// NOTE: InstatiateKernelOnHost() should not be called.
185+
void InstantiateKernelOnHost() override {
182186
if constexpr (std::is_same_v<KernelArgType, void>) {
183187
runKernelWithoutArg(MKernel);
184188
} else if constexpr (std::is_same_v<KernelArgType, sycl::id<Dims>>) {
@@ -217,10 +221,6 @@ class HostKernel : public HostKernelBase {
217221
runKernelWithArg<KernelArgType>(MKernel, KernelArgType{});
218222
}
219223
}
220-
221-
char *getPtr() override { return reinterpret_cast<char *>(&MKernel); }
222-
223-
~HostKernel() = default;
224224
};
225225

226226
} // namespace detail

sycl/test/abi/vtable.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
// Guide for further instructions.
1010

1111
void foo(sycl::detail::HostKernelBase &HKB) {
12-
HKB.InstatitateKernelOnHost();
12+
HKB.InstantiateKernelOnHost();
1313
}
1414
// CHECK: Vtable for 'sycl::detail::HostKernelBase' (6 entries).
1515
// CHECK-NEXT: 0 | offset_to_top (0)
1616
// CHECK-NEXT: 1 | sycl::detail::HostKernelBase RTTI
1717
// CHECK-NEXT: -- (sycl::detail::HostKernelBase, 0) vtable address --
18-
// CHECK-NEXT: 2 | void sycl::detail::HostKernelBase::InstatitateKernelOnHost() [pure]
19-
// CHECK-NEXT: 3 | char *sycl::detail::HostKernelBase::getPtr() [pure]
20-
// CHECK-NEXT: 4 | sycl::detail::HostKernelBase::~HostKernelBase() [complete]
21-
// CHECK-NEXT: 5 | sycl::detail::HostKernelBase::~HostKernelBase() [deleting]
18+
// CHECK-NEXT: 2 | char *sycl::detail::HostKernelBase::getPtr() [pure]
19+
// CHECK-NEXT: 3 | sycl::detail::HostKernelBase::~HostKernelBase() [complete]
20+
// CHECK-NEXT: 4 | sycl::detail::HostKernelBase::~HostKernelBase() [deleting]
21+
// CHECK-NEXT: 5 | void sycl::detail::HostKernelBase::InstantiateKernelOnHost() [pure]
2222

2323
void foo(sycl::detail::PropertyWithDataBase *Prop) { delete Prop; }
2424
// CHECK: Vtable for 'sycl::detail::PropertyWithDataBase' (4 entries).

0 commit comments

Comments
 (0)