Skip to content

[SYCL][CUDA][HIP] Add support for sycl::aspect::ext_intel_pci_address #9624

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 2 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2147,8 +2147,19 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
static_cast<uint32_t>(max_registers));
}

// TODO: Investigate if this information is available on CUDA.
case PI_DEVICE_INFO_PCI_ADDRESS:
case PI_DEVICE_INFO_PCI_ADDRESS: {
constexpr size_t AddressBufferSize = 13;
char AddressBuffer[AddressBufferSize];
sycl::detail::pi::assertion(
cuDeviceGetPCIBusId(AddressBuffer, AddressBufferSize, device->get()) ==
CUDA_SUCCESS);
// CUDA API (8.x - 12.1) guarantees 12 bytes + \0 are written
sycl::detail::pi::assertion(strnlen(AddressBuffer, AddressBufferSize) == 12);
return getInfoArray(strnlen(AddressBuffer, AddressBufferSize - 1) + 1,
param_value_size, param_value, param_value_size_ret,
AddressBuffer);
}
// TODO: Investigate if this information is available on CUDA.
case PI_DEVICE_INFO_GPU_EU_COUNT:
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
case PI_DEVICE_INFO_GPU_SLICES:
Expand Down
16 changes: 15 additions & 1 deletion sycl/plugins/hip/pi_hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1986,8 +1986,22 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
static_cast<uint32_t>(max_registers));
}

case PI_DEVICE_INFO_PCI_ADDRESS: {
constexpr size_t AddressBufferSize = 13;
char AddressBuffer[AddressBufferSize];
sycl::detail::pi::assertion(
hipDeviceGetPCIBusId(AddressBuffer, AddressBufferSize, device->get()) ==
hipSuccess);
// A typical PCI address is 12 bytes + \0: "1234:67:90.2", but the HIP API is not
// guaranteed to use this format. In practice, it uses this format, at least
// in 5.3-5.5. To be on the safe side, we make sure the terminating \0 is set.
AddressBuffer[AddressBufferSize - 1] = '\0';
sycl::detail::pi::assertion(strnlen(AddressBuffer, AddressBufferSize) > 0);
return getInfoArray(strnlen(AddressBuffer, AddressBufferSize - 1) + 1,
param_value_size, param_value, param_value_size_ret,
AddressBuffer);
}
// TODO: Investigate if this information is available on HIP.
case PI_DEVICE_INFO_PCI_ADDRESS:
case PI_DEVICE_INFO_GPU_EU_COUNT:
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
case PI_DEVICE_INFO_GPU_SLICES:
Expand Down