Skip to content

Commit 8f2510f

Browse files
[SYCL] Use urGetDeviceInfo to check bfloat16 native conversion extension (#18023)
As agreement in #16729 , In general we discourage the use of the extension strings as it is a remnant of the OpenCL days. Instead we want to use urDeviceGetInfo when possible. This is a follow-up pr to replace checking OpenCL extension string with urGetDeviceInfo for native bfloat16 conversion extension. --------- Signed-off-by: jinge90 <[email protected]> Co-authored-by: Steffen Larsen <[email protected]>
1 parent a7f5e93 commit 8f2510f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,21 @@ bool ProgramManager::isSpecialDeviceImageShouldBeUsed(
641641
// TODO: re-design the encode of the devicelib metadata if we must support
642642
// more devicelib images in this way.
643643
enum { DEVICELIB_FALLBACK = 0, DEVICELIB_NATIVE };
644+
ur_bool_t NativeBF16Supported = false;
644645
const std::shared_ptr<detail::device_impl> &DeviceImpl =
645646
detail::getSyclObjImpl(Dev);
646-
std::string NativeBF16ExtName = "cl_intel_bfloat16_conversions";
647-
bool NativeBF16Supported = (DeviceImpl->has_extension(NativeBF16ExtName));
648-
return NativeBF16Supported ==
649-
(Bfloat16DeviceLibVersion == DEVICELIB_NATIVE);
647+
ur_result_t CallSuccessful =
648+
DeviceImpl->getAdapter()->call_nocheck<UrApiKind::urDeviceGetInfo>(
649+
DeviceImpl->getHandleRef(),
650+
UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE, sizeof(ur_bool_t),
651+
&NativeBF16Supported, nullptr);
652+
if (CallSuccessful != UR_RESULT_SUCCESS) {
653+
// If backend query is not successful, we will use fallback bfloat16
654+
// device library for safety.
655+
return Bfloat16DeviceLibVersion == DEVICELIB_FALLBACK;
656+
} else
657+
return NativeBF16Supported ==
658+
(Bfloat16DeviceLibVersion == DEVICELIB_NATIVE);
650659
}
651660

652661
return false;

0 commit comments

Comments
 (0)