@@ -688,22 +688,31 @@ struct get_device_info_impl<
688688 ext::oneapi::experimental::info::device::architecture> {
689689 static ext::oneapi::experimental::architecture get (const DeviceImplPtr &Dev) {
690690 backend CurrentBackend = Dev->getBackend ();
691- if (Dev->is_gpu () && (backend::ext_oneapi_level_zero == CurrentBackend ||
692- backend::opencl == CurrentBackend)) {
693- auto MapArchIDToArchName = [](const int arch) {
694- for (const auto &Item : IntelGPUArchitectures) {
695- if (Item.first == arch)
696- return Item.second ;
697- }
698- return ext::oneapi::experimental::architecture::unknown;
699- };
691+ auto LookupIPVersion = [&](auto &ArchList)
692+ -> std::optional<ext::oneapi::experimental::architecture> {
700693 uint32_t DeviceIp;
701- Dev->getPlugin ()->call (
694+ ur_result_t Err = Dev->getPlugin ()->call_nocheck (
702695 urDeviceGetInfo, Dev->getHandleRef (),
703696 UrInfoCode<
704697 ext::oneapi::experimental::info::device::architecture>::value,
705698 sizeof (DeviceIp), &DeviceIp, nullptr );
706- return MapArchIDToArchName (DeviceIp);
699+ if (Err == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) {
700+ // Not all devices support this device info query
701+ return std::nullopt ;
702+ }
703+ Dev->getPlugin ()->checkUrResult (Err);
704+
705+ for (const auto &Item : ArchList) {
706+ if (Item.first == static_cast <int >(DeviceIp))
707+ return Item.second ;
708+ }
709+ return std::nullopt ;
710+ };
711+
712+ if (Dev->is_gpu () && (backend::ext_oneapi_level_zero == CurrentBackend ||
713+ backend::opencl == CurrentBackend)) {
714+ return LookupIPVersion (IntelGPUArchitectures)
715+ .value_or (ext::oneapi::experimental::architecture::unknown);
707716 } else if (Dev->is_gpu () && (backend::ext_oneapi_cuda == CurrentBackend ||
708717 backend::ext_oneapi_hip == CurrentBackend)) {
709718 auto MapArchIDToArchName = [](const char *arch) {
@@ -726,20 +735,8 @@ struct get_device_info_impl<
726735 DeviceArchCopy.substr (0 , DeviceArchCopy.find (" :" ));
727736 return MapArchIDToArchName (DeviceArchSubstr.data ());
728737 } else if (Dev->is_cpu () && backend::opencl == CurrentBackend) {
729- auto MapArchIDToArchName = [](const int arch) {
730- for (const auto &Item : IntelCPUArchitectures) {
731- if (Item.first == arch)
732- return Item.second ;
733- }
734- return sycl::ext::oneapi::experimental::architecture::x86_64;
735- };
736- uint32_t DeviceIp;
737- Dev->getPlugin ()->call (
738- urDeviceGetInfo, Dev->getHandleRef (),
739- UrInfoCode<
740- ext::oneapi::experimental::info::device::architecture>::value,
741- sizeof (DeviceIp), &DeviceIp, nullptr );
742- return MapArchIDToArchName (DeviceIp);
738+ return LookupIPVersion (IntelCPUArchitectures)
739+ .value_or (ext::oneapi::experimental::architecture::x86_64);
743740 } // else is not needed
744741 // TODO: add support of other architectures by extending with else if
745742 return ext::oneapi::experimental::architecture::unknown;
0 commit comments