Skip to content

Commit f8014f5

Browse files
author
sergei
authored
[SYCL] Disable fallback assert for interop kernels (#4712)
Signed-off-by: Sergey Kanaev <[email protected]>
1 parent 7eeae9e commit f8014f5

File tree

7 files changed

+314
-7
lines changed

7 files changed

+314
-7
lines changed

sycl/source/detail/kernel_bundle_impl.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class kernel_bundle_impl {
9797
"Not all devices are associated with the context or "
9898
"vector of devices is empty");
9999
MDeviceImages.push_back(DevImage);
100+
MIsInterop = true;
100101
}
101102

102103
// Matches sycl::build and sycl::compile
@@ -482,13 +483,16 @@ class kernel_bundle_impl {
482483
return MSpecConstValues;
483484
}
484485

486+
bool isInterop() const { return MIsInterop; }
487+
485488
private:
486489
context MContext;
487490
std::vector<device> MDevices;
488491
std::vector<device_image_plain> MDeviceImages;
489492
// This map stores values for specialization constants, that are missing
490493
// from any device image.
491494
SpecConstMapT MSpecConstValues;
495+
bool MIsInterop = false;
492496
};
493497

494498
} // namespace detail

sycl/source/detail/kernel_impl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr Context)
3030
// For others, PI will turn this into a NOP.
3131
getPlugin().call<PiApiKind::piKernelSetExecInfo>(
3232
MKernel, PI_USM_INDIRECT_ACCESS, sizeof(pi_bool), &PI_TRUE);
33+
34+
MIsInterop = true;
3335
}
3436

3537
kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl,
@@ -47,6 +49,8 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl,
4749
throw cl::sycl::invalid_parameter_error(
4850
"Input context must be the same as the context of cl_kernel",
4951
PI_INVALID_CONTEXT);
52+
53+
MIsInterop = MProgramImpl->isInterop();
5054
}
5155

5256
kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl,
@@ -60,6 +64,8 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl,
6064
if (!is_host()) {
6165
getPlugin().call<PiApiKind::piKernelRetain>(MKernel);
6266
}
67+
68+
MIsInterop = MKernelBundleImpl->isInterop();
6369
}
6470

6571
kernel_impl::kernel_impl(ContextImplPtr Context,

sycl/source/detail/kernel_impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,16 @@ class kernel_impl {
200200

201201
KernelBundleImplPtr get_kernel_bundle() const { return MKernelBundleImpl; }
202202

203+
bool isInterop() const { return MIsInterop; }
204+
203205
private:
204206
RT::PiKernel MKernel;
205207
const ContextImplPtr MContext;
206208
const ProgramImplPtr MProgramImpl;
207209
bool MCreatedFromSource = true;
208210
const DeviceImageImplPtr MDeviceImageImpl;
209211
const KernelBundleImplPtr MKernelBundleImpl;
212+
bool MIsInterop = false;
210213
};
211214

212215
template <info::kernel param>

sycl/source/detail/program_impl.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ program_impl::program_impl(
117117

118118
program_impl::program_impl(ContextImplPtr Context,
119119
pi_native_handle InteropProgram)
120-
: program_impl(Context, InteropProgram, nullptr) {}
120+
: program_impl(Context, InteropProgram, nullptr) {
121+
MIsInterop = true;
122+
}
121123

122124
program_impl::program_impl(ContextImplPtr Context,
123125
pi_native_handle InteropProgram,
@@ -198,7 +200,9 @@ program_impl::program_impl(ContextImplPtr Context,
198200
program_impl::program_impl(ContextImplPtr Context, RT::PiKernel Kernel)
199201
: program_impl(Context, reinterpret_cast<pi_native_handle>(nullptr),
200202
ProgramManager::getInstance().getPiProgramFromPiKernel(
201-
Kernel, Context)) {}
203+
Kernel, Context)) {
204+
MIsInterop = true;
205+
}
202206

203207
program_impl::~program_impl() {
204208
// TODO catch an exception and put it to list of asynchronous exceptions
@@ -244,6 +248,7 @@ void program_impl::compile_with_source(std::string KernelSource,
244248
compile(CompileOptions);
245249
}
246250
MState = program_state::compiled;
251+
MIsInterop = true;
247252
}
248253

249254
void program_impl::build_with_kernel_name(std::string KernelName,
@@ -275,6 +280,7 @@ void program_impl::build_with_source(std::string KernelSource,
275280
build(BuildOptions);
276281
}
277282
MState = program_state::linked;
283+
MIsInterop = true;
278284
}
279285

280286
void program_impl::link(std::string LinkOptions) {

sycl/source/detail/program_impl.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ class program_impl {
346346
/// Returns the native plugin handle.
347347
pi_native_handle getNative() const;
348348

349+
bool isInterop() const { return MIsInterop; }
350+
349351
private:
350352
// Deligating Constructor used in Implementation.
351353
program_impl(ContextImplPtr Context, pi_native_handle InteropProgram,
@@ -448,6 +450,8 @@ class program_impl {
448450
/// device list and context) and built with build_with_kernel_type with
449451
/// default build options
450452
bool MProgramAndKernelCachingAllowed = false;
453+
454+
bool MIsInterop = false;
451455
};
452456

453457
template <>

sycl/source/detail/queue_impl.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <detail/context_impl.hpp>
2525
#include <detail/device_impl.hpp>
2626
#include <detail/event_impl.hpp>
27+
#include <detail/kernel_impl.hpp>
2728
#include <detail/plugin.hpp>
2829
#include <detail/scheduler/scheduler.hpp>
2930
#include <detail/thread_pool.hpp>
@@ -470,11 +471,12 @@ class queue_impl {
470471
if (PostProcess) {
471472
bool IsKernel = Type == CG::Kernel;
472473
bool KernelUsesAssert = false;
474+
473475
if (IsKernel)
474-
KernelUsesAssert =
475-
Handler.MKernel ? true
476-
: ProgramManager::getInstance().kernelUsesAssert(
477-
Handler.MOSModuleHandle, Handler.MKernelName);
476+
// Kernel only uses assert if it's non interop one
477+
KernelUsesAssert = !(Handler.MKernel && Handler.MKernel->isInterop()) &&
478+
ProgramManager::getInstance().kernelUsesAssert(
479+
Handler.MOSModuleHandle, Handler.MKernelName);
478480

479481
finalizeHandler(Handler, NeedSeparateDependencyMgmt, Event);
480482

0 commit comments

Comments
 (0)