Skip to content

Commit c00305b

Browse files
[SYCL][Joint Matrix] Relax matrix_combinations error handling (#12866)
This patch relaxes reporting of unsupported HW for matrix_combinations query. Before: exception thrown in case customer uses matrix_combinations query on platform unsupported by ext_oneapi_device_architecture. With this patch: customer gets empty vector from matrix_combinations query on platform unsupported by ext_oneapi_device_architecture. --------- Co-authored-by: Sergey Semenov <[email protected]>
1 parent 90a55a5 commit c00305b

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

sycl/source/detail/device_info.hpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,26 @@ struct get_device_info_impl<
740740
using namespace ext::oneapi::experimental::matrix;
741741
using namespace ext::oneapi::experimental;
742742
backend CurrentBackend = Dev->getBackend();
743-
architecture DeviceArch = get_device_info_impl<
744-
ext::oneapi::experimental::architecture,
745-
ext::oneapi::experimental::info::device::architecture>::get(Dev);
743+
auto get_current_architecture = [&Dev]() -> std::optional<architecture> {
744+
// this helper lambda ignores all runtime-related exceptions from
745+
// quering the device architecture. For instance, if device architecture
746+
// on user's machine is not supported by
747+
// sycl_ext_oneapi_device_architecture, the runtime exception is omitted,
748+
// and std::nullopt is returned.
749+
try {
750+
return get_device_info_impl<
751+
architecture,
752+
ext::oneapi::experimental::info::device::architecture>::get(Dev);
753+
} catch (sycl::exception &e) {
754+
if (e.code() != errc::runtime)
755+
std::rethrow_exception(std::make_exception_ptr(e));
756+
}
757+
return std::nullopt;
758+
};
759+
std::optional<architecture> DeviceArchOpt = get_current_architecture();
760+
if (!DeviceArchOpt.has_value())
761+
return {};
762+
architecture DeviceArch = DeviceArchOpt.value();
746763
if (architecture::intel_cpu_spr == DeviceArch)
747764
return {
748765
{16, 16, 64, 0, 0, 0, matrix_type::uint8, matrix_type::uint8,
@@ -850,10 +867,7 @@ struct get_device_info_impl<
850867
for (const auto &Item : NvidiaArchNumbs)
851868
if (Item.second == arch)
852869
return Item.first;
853-
throw sycl::exception(
854-
make_error_code(errc::runtime),
855-
"The current device architecture is not supported by "
856-
"sycl_ext_oneapi_matrix.");
870+
return 0.f;
857871
};
858872
float ComputeCapability = GetArchNum(DeviceArch);
859873
std::vector<combination> sm_70_combinations = {

0 commit comments

Comments
 (0)