Skip to content

Commit

Permalink
Remove checking result of plugin calls for get info commands so excep…
Browse files Browse the repository at this point in the history
…tion isn't thrown.
  • Loading branch information
martygrant committed Apr 5, 2024
1 parent cec923e commit c9c70e2
Show file tree
Hide file tree
Showing 24 changed files with 20 additions and 117 deletions.
6 changes: 0 additions & 6 deletions sycl/source/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}
ProgramDevices.resize(NumDevices);

Expand All @@ -246,8 +244,6 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

for (const auto &Dev : ProgramDevices) {
Expand All @@ -259,8 +255,6 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

switch (BinaryType) {
Expand Down
4 changes: 0 additions & 4 deletions sycl/source/backend/opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Platform get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}
if (ResultSize == 0)
return false;
Expand All @@ -89,8 +87,6 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Platform get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}

std::string_view ExtensionsString(Result.get());
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/buffer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ buffer_impl::getNativeVector(backend BackendName) const {
// resident on, so pass nullptr for Device param. Buffer interop may not be
// supported by all backends.
sycl::detail::pi::PiResult Result =
Plugin->call_nocheck<PiApiKind::piextMemGetNativeHandle>(NativeMem,
&Handle);
Plugin->call_nocheck<PiApiKind::piextMemGetNativeHandle>(
NativeMem, /*Dev*/ nullptr, &Handle);
if (Result == PI_ERROR_INVALID_OPERATION) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
Expand Down
6 changes: 0 additions & 6 deletions sycl/source/detail/error_handling/error_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}
size_t OptsSize = 0;

Expand All @@ -222,8 +220,6 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

std::string Opts(OptsSize, '\0');
Expand All @@ -234,8 +230,6 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

const bool HasStd20 = Opts.find("-cl-std=CL2.0") != std::string::npos;
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/event_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void event_impl::waitInternal(bool *Success) {
(Error == PI_ERROR_UNKNOWN ||
Error == PI_ERROR_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST)) {
*Success = false;
} else if (Success == PI_ERROR_INVALID_OPERATION) {
} else if (Error == PI_ERROR_INVALID_OPERATION) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Event wait command not supported by backend.");
Expand Down
4 changes: 0 additions & 4 deletions sycl/source/detail/image_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ static void getImageInfo(const ContextImplPtr Context,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Mem image get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}
}

Expand All @@ -296,8 +294,6 @@ image_impl::image_impl(cl_mem MemObject, const context &SyclContext,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Mem get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

sycl::detail::pi::PiMemImageFormat Format;
Expand Down
6 changes: 0 additions & 6 deletions sycl/source/detail/kernel_bundle_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,6 @@ class kernel_bundle_impl {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

// Get the kernel names.
Expand All @@ -433,8 +431,6 @@ class kernel_bundle_impl {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

// semi-colon delimited list of kernel names.
Expand All @@ -446,8 +442,6 @@ class kernel_bundle_impl {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}
std::vector<std::string> KernelNames =
detail::split_string(KernelNamesStr, ';');
Expand Down
2 changes: 0 additions & 2 deletions sycl/source/detail/kernel_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get info command not supported by backend.");
} else {
getPlugin()->checkPiResult(Result);
}

if (ContextImpl->getHandleRef() != Context) {
Expand Down
10 changes: 0 additions & 10 deletions sycl/source/detail/kernel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ get_kernel_info(sycl::detail::pi::PiKernel Kernel, const PluginPtr &Plugin) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}
if (ResultSize == 0) {
return "";
Expand All @@ -52,8 +50,6 @@ get_kernel_info(sycl::detail::pi::PiKernel Kernel, const PluginPtr &Plugin) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}
return std::string(Result.data());
}
Expand All @@ -72,8 +68,6 @@ get_kernel_info(sycl::detail::pi::PiKernel Kernel, const PluginPtr &Plugin) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}
return Result;
}
Expand All @@ -93,8 +87,6 @@ get_kernel_device_specific_info_helper(sycl::detail::pi::PiKernel Kernel,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get sub group info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}
}

Expand Down Expand Up @@ -169,8 +161,6 @@ uint32_t get_kernel_device_specific_info_with_input(
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get sub group info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}

return Result;
Expand Down
8 changes: 1 addition & 7 deletions sycl/source/detail/persistent_device_code_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ void PersistentDeviceCodeCache::putItemToDisc(
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}

std::vector<size_t> BinarySizes(DeviceNum);
Expand All @@ -126,8 +124,6 @@ void PersistentDeviceCodeCache::putItemToDisc(
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}

std::vector<std::vector<char>> Result;
Expand All @@ -137,15 +133,13 @@ void PersistentDeviceCodeCache::putItemToDisc(
Pointers.push_back(Result[I].data());
}

PiResult = Plugin->call<PiApiKind::piProgramGetInfo>(
PiResult = Plugin->call_nocheck<PiApiKind::piProgramGetInfo>(
NativePrg, PI_PROGRAM_INFO_BINARIES, sizeof(char *) * Pointers.size(),
Pointers.data(), nullptr);
if (PiResult == PI_ERROR_INVALID_OPERATION) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}

size_t i = 0;
Expand Down
2 changes: 0 additions & 2 deletions sycl/source/detail/platform_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ std::vector<int> platform_impl::filterDeviceFilter(
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Platform get info command not supported by backend.");
} else {
MPlugin->checkPiResult(Result);
}
backend Backend = convertBackend(PiBackend);

Expand Down
2 changes: 0 additions & 2 deletions sycl/source/detail/platform_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class platform_impl {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Platform get info command not supported by backend.");
} else {
APlugin->checkPiResult(Result);
}
MBackend = convertBackend(PiBackend);
}
Expand Down
4 changes: 0 additions & 4 deletions sycl/source/detail/platform_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ get_platform_info_string_impl(sycl::detail::pi::PiPlatform Plt,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Platform get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}
if (ResultSize == 0) {
return "";
Expand All @@ -47,8 +45,6 @@ get_platform_info_string_impl(sycl::detail::pi::PiPlatform Plt,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Platform get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}
return Result.get();
}
Expand Down
20 changes: 3 additions & 17 deletions sycl/source/detail/program_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ program_impl::program_impl(ContextImplPtr Context,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

std::vector<sycl::detail::pi::PiDevice> PiDevices(NumDevices);
Expand All @@ -169,8 +167,6 @@ program_impl::program_impl(ContextImplPtr Context,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

std::vector<device> PlatformDevices =
Expand Down Expand Up @@ -199,8 +195,6 @@ program_impl::program_impl(ContextImplPtr Context,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}
if (BinaryType == PI_PROGRAM_BINARY_TYPE_NONE) {
throw invalid_object_error(
Expand All @@ -216,8 +210,6 @@ program_impl::program_impl(ContextImplPtr Context,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

std::vector<char> OptionsVector(Size);
Expand All @@ -228,8 +220,6 @@ program_impl::program_impl(ContextImplPtr Context,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

std::string Options(OptionsVector.begin(), OptionsVector.end());
Expand Down Expand Up @@ -389,8 +379,6 @@ std::vector<std::vector<char>> program_impl::get_binaries() const {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}

std::vector<char *> Pointers;
Expand All @@ -406,8 +394,6 @@ std::vector<std::vector<char>> program_impl::get_binaries() const {
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(PiResult);
}

return Result;
Expand Down Expand Up @@ -480,10 +466,10 @@ program_impl::get_pi_kernel_arg_mask_pair(const std::string &KernelName) const {
// Some PI Plugins (like OpenCL) require this call to enable USM
// For others, PI will turn this into a NOP.
if (getContextImplPtr()->getPlatformImpl()->supports_usm()) {
Plugin->call<PiApiKind::piKernelSetExecInfo>(
Result.first, PI_USM_INDIRECT_ACCESS, sizeof(pi_bool), &PI_TRUE);
Plugin->call<PiApiKind::piKernelSetExecInfo>(
Result.first, PI_USM_INDIRECT_ACCESS, sizeof(pi_bool), &PI_TRUE);
}

return Result;
}

Expand Down
10 changes: 0 additions & 10 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,6 @@ ProgramManager::getPiProgramFromPiKernel(sycl::detail::pi::PiKernel Kernel,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Kernel get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

return Program;
Expand All @@ -787,8 +785,6 @@ ProgramManager::getProgramBuildLog(const sycl::detail::pi::PiProgram &Program,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

std::vector<sycl::detail::pi::PiDevice> PIDevices(
Expand All @@ -800,8 +796,6 @@ ProgramManager::getProgramBuildLog(const sycl::detail::pi::PiProgram &Program,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

std::string Log = "The program was built for " +
Expand All @@ -818,8 +812,6 @@ ProgramManager::getProgramBuildLog(const sycl::detail::pi::PiProgram &Program,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}

if (DeviceBuildInfoStrSize > 0) {
Expand All @@ -833,8 +825,6 @@ ProgramManager::getProgramBuildLog(const sycl::detail::pi::PiProgram &Program,
throw sycl::exception(
sycl::make_error_code(sycl::errc::feature_not_supported),
"Program get build info command not supported by backend.");
} else {
Plugin->checkPiResult(Result);
}
DeviceBuildInfoString = std::string(DeviceBuildInfo.data());
}
Expand Down
Loading

0 comments on commit c9c70e2

Please sign in to comment.