Skip to content

Commit 41fed2d

Browse files
authored
[Offload] Add PRODUCT_NAME device info (#155632)
On my system, this will be "Radeon RX 7900 GRE" rather than "gfx1100". For Nvidia, the product name and device name are identical.
1 parent 691f231 commit 41fed2d

File tree

8 files changed

+37
-6
lines changed

8 files changed

+37
-6
lines changed

offload/liboffload/API/Device.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def ol_device_info_t : Enum {
2828
TaggedEtor<"TYPE", "ol_device_type_t", "type of the device">,
2929
TaggedEtor<"PLATFORM", "ol_platform_handle_t", "the platform associated with the device">,
3030
TaggedEtor<"NAME", "char[]", "Device name">,
31+
TaggedEtor<"PRODUCT_NAME", "char[]", "Device user-facing marketing name">,
3132
TaggedEtor<"VENDOR", "char[]", "Device vendor">,
3233
TaggedEtor<"DRIVER_VERSION", "char[]", "Driver version">,
3334
TaggedEtor<"MAX_WORK_GROUP_SIZE", "uint32_t", "Maximum total work group size in work items">,

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
367367
// Retrieve properties from the plugin interface
368368
switch (PropName) {
369369
case OL_DEVICE_INFO_NAME:
370+
case OL_DEVICE_INFO_PRODUCT_NAME:
370371
case OL_DEVICE_INFO_VENDOR:
371372
case OL_DEVICE_INFO_DRIVER_VERSION: {
372373
// String values
@@ -438,6 +439,8 @@ Error olGetDeviceInfoImplDetailHost(ol_device_handle_t Device,
438439
return Info.write<ol_device_type_t>(OL_DEVICE_TYPE_HOST);
439440
case OL_DEVICE_INFO_NAME:
440441
return Info.writeString("Virtual Host Device");
442+
case OL_DEVICE_INFO_PRODUCT_NAME:
443+
return Info.writeString("Virtual Host Device");
441444
case OL_DEVICE_INFO_VENDOR:
442445
return Info.writeString("Liboffload");
443446
case OL_DEVICE_INFO_DRIVER_VERSION:

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2807,7 +2807,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
28072807

28082808
Status = getDeviceAttrRaw(HSA_AMD_AGENT_INFO_PRODUCT_NAME, TmpChar);
28092809
if (Status == HSA_STATUS_SUCCESS)
2810-
Info.add("Product Name", TmpChar);
2810+
Info.add("Product Name", TmpChar, "", DeviceInfo::PRODUCT_NAME);
28112811

28122812
Status = getDeviceAttrRaw(HSA_AGENT_INFO_NAME, TmpChar);
28132813
if (Status == HSA_STATUS_SUCCESS)

offload/plugins-nextgen/cuda/src/rtl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,10 @@ struct CUDADeviceTy : public GenericDeviceTy {
10601060
Info.add("CUDA OpenMP Device Number", DeviceId);
10611061

10621062
Res = cuDeviceGetName(TmpChar, 1000, Device);
1063-
if (Res == CUDA_SUCCESS)
1063+
if (Res == CUDA_SUCCESS) {
10641064
Info.add("Device Name", TmpChar, "", DeviceInfo::NAME);
1065+
Info.add("Product Name", TmpChar, "", DeviceInfo::PRODUCT_NAME);
1066+
}
10651067

10661068
Info.add("Vendor Name", "NVIDIA", "", DeviceInfo::VENDOR);
10671069

offload/unittests/Conformance/lib/DeviceContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ static OffloadInitWrapper Wrapper{};
5555

5656
[[nodiscard]] std::string getDeviceName(ol_device_handle_t DeviceHandle) {
5757
std::size_t PropSize = 0;
58-
OL_CHECK(olGetDeviceInfoSize(DeviceHandle, OL_DEVICE_INFO_NAME, &PropSize));
58+
OL_CHECK(olGetDeviceInfoSize(DeviceHandle, OL_DEVICE_INFO_PRODUCT_NAME,
59+
&PropSize));
5960

6061
if (PropSize == 0)
6162
return "";
6263

6364
std::string PropValue(PropSize, '\0');
64-
OL_CHECK(olGetDeviceInfo(DeviceHandle, OL_DEVICE_INFO_NAME, PropSize,
65+
OL_CHECK(olGetDeviceInfo(DeviceHandle, OL_DEVICE_INFO_PRODUCT_NAME, PropSize,
6566
PropValue.data()));
6667
PropValue.pop_back(); // Remove the null terminator
6768

offload/unittests/OffloadAPI/common/Environment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ raw_ostream &operator<<(raw_ostream &Out,
4141

4242
raw_ostream &operator<<(raw_ostream &Out, const ol_device_handle_t &Device) {
4343
size_t Size;
44-
olGetDeviceInfoSize(Device, OL_DEVICE_INFO_NAME, &Size);
44+
olGetDeviceInfoSize(Device, OL_DEVICE_INFO_PRODUCT_NAME, &Size);
4545
std::vector<char> Name(Size);
46-
olGetDeviceInfo(Device, OL_DEVICE_INFO_NAME, Size, Name.data());
46+
olGetDeviceInfo(Device, OL_DEVICE_INFO_PRODUCT_NAME, Size, Name.data());
4747
Out << Name.data();
4848
return Out;
4949
}

offload/unittests/OffloadAPI/device/olGetDeviceInfo.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,29 @@ TEST_P(olGetDeviceInfoTest, HostName) {
8686
ASSERT_EQ(std::strlen(Name.data()), Size - 1);
8787
}
8888

89+
TEST_P(olGetDeviceInfoTest, SuccessProductName) {
90+
size_t Size = 0;
91+
ASSERT_SUCCESS(
92+
olGetDeviceInfoSize(Device, OL_DEVICE_INFO_PRODUCT_NAME, &Size));
93+
ASSERT_GT(Size, 0ul);
94+
std::vector<char> Name;
95+
Name.resize(Size);
96+
ASSERT_SUCCESS(
97+
olGetDeviceInfo(Device, OL_DEVICE_INFO_PRODUCT_NAME, Size, Name.data()));
98+
ASSERT_EQ(std::strlen(Name.data()), Size - 1);
99+
}
100+
101+
TEST_P(olGetDeviceInfoTest, HostProductName) {
102+
size_t Size = 0;
103+
ASSERT_SUCCESS(olGetDeviceInfoSize(Host, OL_DEVICE_INFO_PRODUCT_NAME, &Size));
104+
ASSERT_GT(Size, 0ul);
105+
std::vector<char> Name;
106+
Name.resize(Size);
107+
ASSERT_SUCCESS(
108+
olGetDeviceInfo(Host, OL_DEVICE_INFO_PRODUCT_NAME, Size, Name.data()));
109+
ASSERT_EQ(std::strlen(Name.data()), Size - 1);
110+
}
111+
89112
TEST_P(olGetDeviceInfoTest, SuccessVendor) {
90113
size_t Size = 0;
91114
ASSERT_SUCCESS(olGetDeviceInfoSize(Device, OL_DEVICE_INFO_VENDOR, &Size));

offload/unittests/OffloadAPI/device/olGetDeviceInfoSize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ OL_DEVICE_INFO_SIZE_TEST_EQ(Type, ol_device_type_t, OL_DEVICE_INFO_TYPE);
3131
OL_DEVICE_INFO_SIZE_TEST_EQ(Platform, ol_platform_handle_t,
3232
OL_DEVICE_INFO_PLATFORM);
3333
OL_DEVICE_INFO_SIZE_TEST_NONZERO(Name, OL_DEVICE_INFO_NAME);
34+
OL_DEVICE_INFO_SIZE_TEST_NONZERO(ProductName, OL_DEVICE_INFO_PRODUCT_NAME);
3435
OL_DEVICE_INFO_SIZE_TEST_NONZERO(Vendor, OL_DEVICE_INFO_VENDOR);
3536
OL_DEVICE_INFO_SIZE_TEST_NONZERO(DriverVersion, OL_DEVICE_INFO_DRIVER_VERSION);
3637
OL_DEVICE_INFO_SIZE_TEST_EQ(MaxWorkGroupSize, uint32_t,

0 commit comments

Comments
 (0)