Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions sycl/include/sycl/info/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#pragma once

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/defines_elementary.hpp> // for __SYCL_DEPRECATED
Comment thread
KornevNikita marked this conversation as resolved.
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
#endif // __INTEL_PREVIEW_BREAKING_CHANGES

#include <sycl/detail/info_desc_traits.hpp>
#include <sycl/range.hpp>
#include <unified-runtime/ur_api.h>
Expand Down Expand Up @@ -35,15 +38,21 @@ struct num_args : kernel_traits<UR_KERNEL_INFO_NUM_ARGS> {
struct attributes : kernel_traits<UR_KERNEL_INFO_ATTRIBUTES> {
using return_type = std::string;
};
struct function_name : kernel_traits<UR_KERNEL_INFO_FUNCTION_NAME> {
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
struct __SYCL_DEPRECATED("info::kernel::function_name is not part of SYCL 2020")
function_name : kernel_traits<UR_KERNEL_INFO_FUNCTION_NAME> {
using return_type = std::string;
};
struct reference_count : kernel_traits<UR_KERNEL_INFO_REFERENCE_COUNT> {
struct __SYCL_DEPRECATED(
"info::kernel::reference_count is not part of SYCL 2020") reference_count
: kernel_traits<UR_KERNEL_INFO_REFERENCE_COUNT> {
using return_type = uint32_t;
};
struct context : kernel_traits<UR_KERNEL_INFO_CONTEXT> {
struct __SYCL_DEPRECATED("info::kernel::context is not part of SYCL 2020")
context : kernel_traits<UR_KERNEL_INFO_CONTEXT> {
using return_type = sycl::context;
};
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
} // namespace kernel

namespace kernel_device_specific {
Expand Down
19 changes: 15 additions & 4 deletions sycl/source/detail/kernel_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <detail/kernel_impl.hpp>

#include <memory>
#include <vector>

namespace sycl {
inline namespace _V1 {
Expand Down Expand Up @@ -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<function_name> should behave instead.
std::string_view kernel_impl::getName() const {
std::call_once(MNameInitFlag,
[&]() { MName = get_info<info::kernel::function_name>(); });
std::call_once(MNameInitFlag, [&]() {
adapter_impl &Adapter = getAdapter();
size_t NameSize = 0;
Adapter.call<UrApiKind::urKernelGetInfo>(
MKernel, UR_KERNEL_INFO_FUNCTION_NAME, 0u, nullptr, &NameSize);
if (NameSize > 0) {
std::vector<char> NameBuf(NameSize);
Adapter.call<UrApiKind::urKernelGetInfo>(
MKernel, UR_KERNEL_INFO_FUNCTION_NAME, NameSize, NameBuf.data(),
nullptr);
MName = std::string(NameBuf.data());
}
});

return MName;
}
Expand All @@ -139,7 +150,7 @@ bool kernel_impl::isBuiltInKernel(device_impl &Device) const {
auto BuiltInKernels = Device.get_info<info::device::built_in_kernel_ids>();
if (BuiltInKernels.empty())
return false;
std::string KernelName = get_info<info::kernel::function_name>();
std::string_view KernelName = getName();
return (std::any_of(
BuiltInKernels.begin(), BuiltInKernels.end(),
[&KernelName](kernel_id &Id) { return Id.get_name() == KernelName; }));
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,12 @@ inline typename Param::return_type kernel_impl::get_info() const {
return get_kernel_info<Param>(this->getHandleRef(), getAdapter());
}

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
template <>
inline context kernel_impl::get_info<info::kernel::context>() const {
return createSyclObjFromImpl<context>(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
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2831,7 +2831,7 @@ void enqueueImpKernel(
uint32_t IdQueryRangeProp = 0;

if (nullptr != MSyclKernel) {
assert(MSyclKernel->get_info<info::kernel::context>() ==
assert(createSyclObjFromImpl<context>(MSyclKernel->getContextImpl()) ==
Queue.get_context());
Kernel = MSyclKernel->getHandleRef();
Program = MSyclKernel->getProgramRef();
Expand Down
4 changes: 3 additions & 1 deletion sycl/source/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<info::kernel::context>();
return detail::createSyclObjFromImpl<context>(impl->getContextImpl());
}

backend kernel::get_backend() const noexcept { return getImplBackend(impl); }
Expand All @@ -61,9 +61,11 @@ kernel::get_info_impl() const {
kernel::get_info_impl<info::kernel::NAME>() 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 <typename Param>
Expand Down