Skip to content

Commit 3b4af65

Browse files
committed
[SYCL] Fix abi issues caused by reduction implementation
The fix also removes the field handler::MReductionsStorage and re-uses the existing MSharedPtrStorage to keep reductions buffers alive until the execution on device/host code using those buffers finishes. Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent f974f85 commit 3b4af65

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

sycl/include/CL/sycl/detail/cg.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ class CGExecKernel : public CG {
456456
string_class MKernelName;
457457
detail::OSModuleHandle MOSModuleHandle;
458458
vector_class<shared_ptr_class<detail::stream_impl>> MStreams;
459-
vector_class<shared_ptr_class<void>> MReductions;
460459

461460
CGExecKernel(NDRDescT NDRDesc, unique_ptr_class<HostKernelBase> HKernel,
462461
shared_ptr_class<detail::kernel_impl> SyclKernel,
@@ -468,15 +467,14 @@ class CGExecKernel : public CG {
468467
vector_class<ArgDesc> Args, string_class KernelName,
469468
detail::OSModuleHandle OSModuleHandle,
470469
vector_class<shared_ptr_class<detail::stream_impl>> Streams,
471-
vector_class<shared_ptr_class<void>> Reductions, CGTYPE Type,
472-
detail::code_location loc = {})
470+
CGTYPE Type, detail::code_location loc = {})
473471
: CG(Type, std::move(ArgsStorage), std::move(AccStorage),
474472
std::move(SharedPtrStorage), std::move(Requirements),
475473
std::move(Events), std::move(loc)),
476474
MNDRDesc(std::move(NDRDesc)), MHostKernel(std::move(HKernel)),
477475
MSyclKernel(std::move(SyclKernel)), MArgs(std::move(Args)),
478476
MKernelName(std::move(KernelName)), MOSModuleHandle(OSModuleHandle),
479-
MStreams(std::move(Streams)), MReductions(std::move(Reductions)) {
477+
MStreams(std::move(Streams)) {
480478
assert((getType() == RUN_ON_HOST_INTEL || getType() == KERNEL) &&
481479
"Wrong type of exec kernel CG.");
482480
}

sycl/include/CL/sycl/handler.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ class __SYCL_EXPORT handler {
255255
MStreamStorage.push_back(std::move(Stream));
256256
}
257257

258-
/// Saves buffers and scalars associated with reduction to handler.
259-
/// They are then forwarded to command group later and destroyed
260-
/// only after the command group finishes the work on device/host.
258+
/// Saves buffers created by handling reduction feature in handler.
259+
/// They are then forwarded to command group and destroyed only after
260+
/// the command group finishes the work on device/host.
261+
/// The 'MSharedPtrStorage' suits that need.
261262
///
262-
/// @param ReduObj is a pointer to object that must be preserved
263-
/// for reduction until the .
264-
void addReduction(shared_ptr_class<void> ReduObj) {
265-
MReductionStorage.push_back(std::move(ReduObj));
263+
/// @param ReduObj is a pointer to object that must be stored.
264+
void addReduction(shared_ptr_class<const void> ReduObj) {
265+
MSharedPtrStorage.push_back(std::move(ReduObj));
266266
}
267267

268268
~handler() = default;
@@ -1714,7 +1714,6 @@ class __SYCL_EXPORT handler {
17141714
vector_class<detail::AccessorImplPtr> MAccStorage;
17151715
vector_class<detail::LocalAccessorImplPtr> MLocalAccStorage;
17161716
vector_class<shared_ptr_class<detail::stream_impl>> MStreamStorage;
1717-
vector_class<shared_ptr_class<void>> MReductionStorage;
17181717
vector_class<shared_ptr_class<const void>> MSharedPtrStorage;
17191718
/// The list of arguments for the kernel.
17201719
vector_class<detail::ArgDesc> MArgs;

sycl/source/handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ event handler::finalize() {
4040
std::move(MArgsStorage), std::move(MAccStorage),
4141
std::move(MSharedPtrStorage), std::move(MRequirements),
4242
std::move(MEvents), std::move(MArgs), std::move(MKernelName),
43-
std::move(MOSModuleHandle), std::move(MStreamStorage),
44-
std::move(MReductionStorage), MCGType, MCodeLoc));
43+
std::move(MOSModuleHandle), std::move(MStreamStorage), MCGType,
44+
MCodeLoc));
4545
break;
4646
}
4747
case detail::CG::INTEROP_TASK_CODEPLAY:

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3232,7 +3232,8 @@ _ZN2cl4sycl7handler10processArgEPvRKNS0_6detail19kernel_param_kind_tEimRmb
32323232
_ZN2cl4sycl7handler13getKernelNameB5cxx11Ev
32333233
_ZN2cl4sycl7handler18extractArgsAndReqsEv
32343234
_ZN2cl4sycl7handler28extractArgsAndReqsFromLambdaEPcmPKNS0_6detail19kernel_param_desc_tE
3235-
_ZN2cl4sycl7handler8finalizeERKNS0_6detail13code_locationE
3235+
_ZN2cl4sycl7handler15addEventToQueueESt10shared_ptrINS0_6detail10queue_implEENS0_5eventE
3236+
_ZN2cl4sycl7handler8finalizeEv
32363237
_ZN2cl4sycl7program17build_with_sourceENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_
32373238
_ZN2cl4sycl7program19compile_with_sourceENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_
32383239
_ZN2cl4sycl7program22build_with_kernel_nameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_l

sycl/test/abi/symbol_size.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main() {
4343
check_size<device_selector, 8>();
4444
check_size<event, 16>();
4545
check_size<gpu_selector, 8>();
46-
check_size<handler, 472>();
46+
check_size<handler, 528>();
4747
check_size<image<1>, 16>();
4848
check_size<kernel, 16>();
4949
check_size<platform, 16>();

0 commit comments

Comments
 (0)