Skip to content

[SYCL][CUDA] Support device ID and UUID in the CUDA Plugin #8203

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Feb 9, 2023
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
33 changes: 28 additions & 5 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,8 +1994,35 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
pi_int32{1});
}

case PI_DEVICE_INFO_DEVICE_ID: {
int value = 0;
sycl::detail::pi::assertion(
cuDeviceGetAttribute(&value, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID,
device->get()) == CUDA_SUCCESS);
sycl::detail::pi::assertion(value >= 0);
return getInfo(param_value_size, param_value, param_value_size_ret, value);
}

case PI_DEVICE_INFO_UUID: {
int driver_version = 0;
cuDriverGetVersion(&driver_version);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zjin-lcf @npmiller Do we need a API check for this. Also would you suggest to replace sycl::detail::pi::assertion to PI_CHECK_ERROR ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the CUDA docs it looks like this can only return an error if the parameter is nullptr, so I think this should be fine, see:

int major = driver_version / 1000;
int minor = driver_version % 1000 / 10;
CUuuid uuid;
if ((major > 11) || (major == 11 && minor >= 4)) {
sycl::detail::pi::assertion(cuDeviceGetUuid_v2(&uuid, device->get()) ==
CUDA_SUCCESS);
} else {
sycl::detail::pi::assertion(cuDeviceGetUuid(&uuid, device->get()) ==
CUDA_SUCCESS);
}
std::array<unsigned char, 16> name;
std::copy(uuid.bytes, uuid.bytes + 16, name.begin());
return getInfoArray(16, param_value_size, param_value, param_value_size_ret,
name.data());
}

// TODO: Investigate if this information is available on CUDA.
case PI_DEVICE_INFO_DEVICE_ID:
case PI_DEVICE_INFO_PCI_ADDRESS:
case PI_DEVICE_INFO_GPU_EU_COUNT:
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
Expand All @@ -2004,10 +2031,6 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE:
case PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH:
// TODO: Check if Intel device UUID extension is utilized for CUDA.
// For details about this extension, see
// sycl/doc/extensions/supported/sycl_ext_intel_device_info.md
case PI_DEVICE_INFO_UUID:
return PI_ERROR_INVALID_VALUE;

default:
Expand Down