diff --git a/sycl/include/sycl/info/kernel.hpp b/sycl/include/sycl/info/kernel.hpp index eec1f242635c2..721357c9bf50a 100644 --- a/sycl/include/sycl/info/kernel.hpp +++ b/sycl/include/sycl/info/kernel.hpp @@ -8,6 +8,9 @@ #pragma once +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +#include // for __SYCL_DEPRECATED +#endif #include #include #include @@ -35,15 +38,21 @@ struct num_args : kernel_traits { struct attributes : kernel_traits { using return_type = std::string; }; -struct function_name : kernel_traits { +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +struct __SYCL_DEPRECATED("info::kernel::function_name is not part of SYCL 2020") + function_name : kernel_traits { using return_type = std::string; }; -struct reference_count : kernel_traits { +struct __SYCL_DEPRECATED( + "info::kernel::reference_count is not part of SYCL 2020") reference_count + : kernel_traits { using return_type = uint32_t; }; -struct context : kernel_traits { +struct __SYCL_DEPRECATED("info::kernel::context is not part of SYCL 2020") + context : kernel_traits { using return_type = sycl::context; }; +#endif // __INTEL_PREVIEW_BREAKING_CHANGES } // namespace kernel namespace kernel_device_specific { diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index a628bb50d5929..7340fabe35f41 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace sycl { inline namespace _V1 { @@ -117,10 +118,20 @@ bool kernel_impl::hasSYCLMetadata() const noexcept { sycl::ext::oneapi::experimental::source_language::sycl)); } -// TODO this is how kernel_impl::get_info should behave instead. std::string_view kernel_impl::getName() const { - std::call_once(MNameInitFlag, - [&]() { MName = get_info(); }); + std::call_once(MNameInitFlag, [&]() { + adapter_impl &Adapter = getAdapter(); + size_t NameSize = 0; + Adapter.call( + MKernel, UR_KERNEL_INFO_FUNCTION_NAME, 0u, nullptr, &NameSize); + if (NameSize > 0) { + std::vector NameBuf(NameSize); + Adapter.call( + MKernel, UR_KERNEL_INFO_FUNCTION_NAME, NameSize, NameBuf.data(), + nullptr); + MName = std::string(NameBuf.data()); + } + }); return MName; } @@ -139,7 +150,7 @@ bool kernel_impl::isBuiltInKernel(device_impl &Device) const { auto BuiltInKernels = Device.get_info(); if (BuiltInKernels.empty()) return false; - std::string KernelName = get_info(); + std::string_view KernelName = getName(); return (std::any_of( BuiltInKernels.begin(), BuiltInKernels.end(), [&KernelName](kernel_id &Id) { return Id.get_name() == KernelName; })); diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index c7d1d6a13bcbb..bf3a4ab6aff13 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -329,10 +329,12 @@ inline typename Param::return_type kernel_impl::get_info() const { return get_kernel_info(this->getHandleRef(), getAdapter()); } +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES template <> inline context kernel_impl::get_info() const { return createSyclObjFromImpl(MContext); } +#endif // __INTEL_PREVIEW_BREAKING_CHANGES // NOTE: the global_work_size and spill_memory_size pre-query checks below are // mirrored in validateDeviceSpecificQuery (get_kernel_info_impl.cpp), which diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index c85608faa2dd1..f511f7b662703 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -2831,7 +2831,7 @@ void enqueueImpKernel( uint32_t IdQueryRangeProp = 0; if (nullptr != MSyclKernel) { - assert(MSyclKernel->get_info() == + assert(createSyclObjFromImpl(MSyclKernel->getContextImpl()) == Queue.get_context()); Kernel = MSyclKernel->getHandleRef(); Program = MSyclKernel->getProgramRef(); diff --git a/sycl/source/kernel.cpp b/sycl/source/kernel.cpp index 8abde164c6b62..96a39ceaab745 100644 --- a/sycl/source/kernel.cpp +++ b/sycl/source/kernel.cpp @@ -39,7 +39,7 @@ kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { cl_kernel kernel::get() const { return impl->get(); } context kernel::get_context() const { - return impl->get_info(); + return detail::createSyclObjFromImpl(impl->getContextImpl()); } backend kernel::get_backend() const noexcept { return getImplBackend(impl); } @@ -61,9 +61,11 @@ kernel::get_info_impl() const { kernel::get_info_impl() const; __SYCL_KERNEL_INFO_INST(num_args, uint32_t) __SYCL_KERNEL_INFO_INST(attributes, std::string) +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES __SYCL_KERNEL_INFO_INST(function_name, std::string) __SYCL_KERNEL_INFO_INST(reference_count, uint32_t) __SYCL_KERNEL_INFO_INST(context, sycl::context) +#endif // __INTEL_PREVIEW_BREAKING_CHANGES #undef __SYCL_KERNEL_INFO_INST template