Skip to content

Commit ad6253e

Browse files
[SYCL][L0] Fix BDF format on PCI query (#6011)
The PCI address currently reported by the L0 backend does not correctly report domain, bus, device, and function as hexadecimal values. This commit changes the reported format to use convert the values hexadecimal representation. Additionally it also pads the values with leading zeros. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
1 parent 2d471ea commit ad6253e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,12 +2838,14 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
28382838
}
28392839
ZesStruct<zes_pci_properties_t> ZeDevicePciProperties;
28402840
ZE_CALL(zesDevicePciGetProperties, (ZeDevice, &ZeDevicePciProperties));
2841-
std::stringstream ss;
2842-
ss << ZeDevicePciProperties.address.domain << ":"
2843-
<< ZeDevicePciProperties.address.bus << ":"
2844-
<< ZeDevicePciProperties.address.device << "."
2845-
<< ZeDevicePciProperties.address.function;
2846-
return ReturnValue(ss.str().c_str());
2841+
constexpr size_t AddressBufferSize = 13;
2842+
char AddressBuffer[AddressBufferSize];
2843+
std::snprintf(AddressBuffer, AddressBufferSize, "%04x:%02x:%02x.%01x",
2844+
ZeDevicePciProperties.address.domain,
2845+
ZeDevicePciProperties.address.bus,
2846+
ZeDevicePciProperties.address.device,
2847+
ZeDevicePciProperties.address.function);
2848+
return ReturnValue(AddressBuffer);
28472849
}
28482850
case PI_DEVICE_INFO_GPU_EU_COUNT: {
28492851
pi_uint32 count = Device->ZeDeviceProperties->numEUsPerSubslice *

sycl/source/detail/device_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ bool device_impl::has(aspect Aspect) const {
315315
return get_info<info::device::usm_system_allocations>();
316316
case aspect::ext_intel_pci_address:
317317
return getPlugin().call_nocheck<detail::PiApiKind::piDeviceGetInfo>(
318-
MDevice, PI_DEVICE_INFO_PCI_ADDRESS, sizeof(pi_device_type),
319-
&device_type, &return_size) == PI_SUCCESS;
318+
MDevice, PI_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, &return_size) ==
319+
PI_SUCCESS;
320320
case aspect::ext_intel_gpu_eu_count:
321321
return getPlugin().call_nocheck<detail::PiApiKind::piDeviceGetInfo>(
322322
MDevice, PI_DEVICE_INFO_GPU_EU_COUNT, sizeof(pi_device_type),

0 commit comments

Comments
 (0)