Skip to content

[SYCL] Throw right errc for work_group_size query #8645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 16, 2023
Merged
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
2 changes: 1 addition & 1 deletion sycl/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ set(SYCL_SOURCES
"detail/device_global_map.cpp"
"detail/device_global_map_entry.cpp"
"detail/device_impl.cpp"
"detail/error_handling/enqueue_kernel.cpp"
"detail/error_handling/error_handling.cpp"
"detail/event_impl.cpp"
"detail/filter_selector_impl.cpp"
"detail/fusion/fusion_wrapper.cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,28 @@ void handleErrorOrWarning(pi_result Error, const device_impl &DeviceImpl,
}

} // namespace detail::enqueue_kernel_launch

namespace detail::kernel_get_group_info {
void handleErrorOrWarning(pi_result Error, pi_kernel_group_info Descriptor,
const plugin &Plugin) {
assert(Error != PI_SUCCESS &&
"Success is expected to be handled on caller side");
switch (Error) {
case PI_ERROR_INVALID_VALUE:
if (Descriptor == CL_KERNEL_GLOBAL_WORK_SIZE)
throw sycl::exception(
sycl::make_error_code(errc::invalid),
"info::kernel_device_specific::global_work_size descriptor may only "
"be used if the device type is device_type::custom or if the kernel "
"is a built-in kernel.");
break;
// TODO: Handle other error codes
default:
Plugin.checkPiResult(Error);
break;
}
}
} // namespace detail::kernel_get_group_info

} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl
5 changes: 5 additions & 0 deletions sycl/source/detail/error_handling/error_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ void handleErrorOrWarning(pi_result, const device_impl &, pi_kernel,
const NDRDescT &);
} // namespace enqueue_kernel_launch

namespace kernel_get_group_info {
/// Analyzes error code of piKernelGetGroupInfo.
void handleErrorOrWarning(pi_result, pi_kernel_group_info, const plugin &);
} // namespace kernel_get_group_info

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl
6 changes: 5 additions & 1 deletion sycl/source/detail/kernel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <detail/error_handling/error_handling.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/common_info.hpp>
#include <sycl/detail/info_desc_helpers.hpp>
Expand Down Expand Up @@ -71,8 +72,11 @@ typename std::enable_if<!IsSubGroupInfo<Param>::value>::type
get_kernel_device_specific_info_helper(RT::PiKernel Kernel, RT::PiDevice Device,
const plugin &Plugin, void *Result,
size_t Size) {
Plugin.call<PiApiKind::piKernelGetGroupInfo>(
RT::PiResult Error = Plugin.call_nocheck<PiApiKind::piKernelGetGroupInfo>(
Kernel, Device, PiInfoCode<Param>::value, Size, Result, nullptr);
if (Error != PI_SUCCESS)
kernel_get_group_info::handleErrorOrWarning(Error, PiInfoCode<Param>::value,
Plugin);
}

template <typename Param>
Expand Down