Skip to content

[SYCL] Use urGetDeviceInfo to check bfloat16 native conversion extension #18023

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 5 commits into from
Apr 16, 2025
Merged
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
17 changes: 13 additions & 4 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,21 @@ bool ProgramManager::isSpecialDeviceImageShouldBeUsed(
// TODO: re-design the encode of the devicelib metadata if we must support
// more devicelib images in this way.
enum { DEVICELIB_FALLBACK = 0, DEVICELIB_NATIVE };
ur_bool_t NativeBF16Supported = false;
const std::shared_ptr<detail::device_impl> &DeviceImpl =
detail::getSyclObjImpl(Dev);
std::string NativeBF16ExtName = "cl_intel_bfloat16_conversions";
bool NativeBF16Supported = (DeviceImpl->has_extension(NativeBF16ExtName));
return NativeBF16Supported ==
(Bfloat16DeviceLibVersion == DEVICELIB_NATIVE);
ur_result_t CallSuccessful =
DeviceImpl->getAdapter()->call_nocheck<UrApiKind::urDeviceGetInfo>(
DeviceImpl->getHandleRef(),
UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE, sizeof(ur_bool_t),
&NativeBF16Supported, nullptr);
if (CallSuccessful != UR_RESULT_SUCCESS) {
// If backend query is not successful, we will use fallback bfloat16
// device library for safety.
return Bfloat16DeviceLibVersion == DEVICELIB_FALLBACK;
} else
return NativeBF16Supported ==
(Bfloat16DeviceLibVersion == DEVICELIB_NATIVE);
}

return false;
Expand Down