17 inline namespace _V1 {
26 true, KernelBundleImpl, ArgMask) {
30 if (Context->getPlatformImpl()->supports_usm())
40 bool IsCreatedFromSource,
43 : MKernel(Kernel), MContext(ContextImpl),
44 MProgram(ProgramImpl->getHandleRef()),
45 MCreatedFromSource(IsCreatedFromSource),
46 MKernelBundleImpl(
std::move(KernelBundleImpl)),
47 MKernelArgMaskPtr{ArgMask} {
53 if (ContextImpl->getHandleRef() != Context)
54 throw sycl::invalid_parameter_error(
55 "Input context must be the same as the context of cl_kernel",
56 PI_ERROR_INVALID_CONTEXT);
58 MIsInterop = ProgramImpl->isInterop();
66 std::mutex *CacheMutex)
67 : MKernel(Kernel), MContext(
std::move(ContextImpl)), MProgram(ProgramPI),
68 MCreatedFromSource(false), MDeviceImageImpl(
std::move(DeviceImageImpl)),
69 MKernelBundleImpl(
std::move(KernelBundleImpl)),
70 MKernelArgMaskPtr{ArgMask}, MCacheMutex{CacheMutex} {
71 MIsInterop = MKernelBundleImpl->isInterop();
75 : MContext(Context), MProgram(ProgramImpl->getHandleRef()) {}
97 return MCreatedFromSource;
100 bool kernel_impl::isBuiltInKernel(
const device &Device)
const {
101 auto BuiltInKernels = Device.
get_info<info::device::built_in_kernel_ids>();
102 if (BuiltInKernels.empty())
104 std::string KernelName = get_info<info::kernel::function_name>();
106 BuiltInKernels.begin(), BuiltInKernels.end(),
107 [&KernelName](
kernel_id &Id) { return Id.get_name() == KernelName; }));
110 void kernel_impl::checkIfValidForNumArgsInfoQuery()
const {
111 if (MKernelBundleImpl->isInterop())
113 auto Devices = MKernelBundleImpl->get_devices();
115 [
this](
device &Device) { return isBuiltInKernel(Device); }))
120 "info::kernel::num_args descriptor may only be used to query a kernel "
121 "that resides in a kernel bundle constructed using a backend specific"
122 "interoperability function or to query a device built-in kernel");
kernel_impl(sycl::detail::pi::PiKernel Kernel, ContextImplPtr Context, KernelBundleImplPtr KernelBundleImpl, const KernelArgMask *ArgMask=nullptr)
Constructs a SYCL kernel instance from a PiKernel.
bool is_host() const
Check if the associated SYCL context is a SYCL host context.
bool isCreatedFromSource() const
Check if kernel was created from a program that had been created from source.
const PluginPtr & getPlugin() const
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
detail::ABINeutralT_t< typename detail::is_device_info_desc< Param >::return_type > get_info() const
Queries this SYCL device for information requested by the template parameter param.
Objects of the class identify kernel is some kernel_bundle related APIs.
std::shared_ptr< device_image_impl > DeviceImageImplPtr
std::vector< bool > KernelArgMask
std::shared_ptr< program_impl > ProgramImplPtr
std::shared_ptr< sycl::detail::context_impl > ContextImplPtr
std::shared_ptr< detail::kernel_bundle_impl > KernelBundleImplPtr
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
pi_result piKernelRelease(pi_kernel kernel)
@ PI_USM_INDIRECT_ACCESS
indicates that the kernel might access data through USM ptrs
pi_result piKernelSetExecInfo(pi_kernel kernel, pi_kernel_exec_info value_name, size_t param_value_size, const void *param_value)
API to set attributes controlling kernel execution.
pi_result piKernelGetInfo(pi_kernel kernel, pi_kernel_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
bool any_of(const simd_mask< _Tp, _Abi > &) noexcept