Skip to content

Commit 0ebe555

Browse files
authored
[Offload] Add specifier for the host type (#141635)
Summary: We use this sepcial type to indicate a host value, this will be refined later but for now it's used as a stand-in device for transfers and queues. It needs a special kind because it is not a device target as the other ones so we need to differentiate it between a CPU and GPU type. Fixes: #141436
1 parent 06ee672 commit 0ebe555

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

offload/liboffload/API/Device.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def : Enum {
1818
Etor<"ALL", "Devices of all types">,
1919
Etor<"GPU", "GPU device type">,
2020
Etor<"CPU", "CPU device type">,
21+
Etor<"Host", "Host device type">,
2122
];
2223
}
2324

offload/liboffload/include/generated/OffloadAPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ typedef enum ol_device_type_t {
320320
OL_DEVICE_TYPE_GPU = 2,
321321
/// CPU device type
322322
OL_DEVICE_TYPE_CPU = 3,
323+
/// Host device type
324+
OL_DEVICE_TYPE_HOST = 4,
323325
/// @cond
324326
OL_DEVICE_TYPE_FORCE_UINT32 = 0x7fffffff
325327
/// @endcond

offload/liboffload/include/generated/OffloadPrint.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
224224
case OL_DEVICE_TYPE_CPU:
225225
os << "OL_DEVICE_TYPE_CPU";
226226
break;
227+
case OL_DEVICE_TYPE_HOST:
228+
os << "OL_DEVICE_TYPE_HOST";
229+
break;
227230
default:
228231
os << "unknown enumerator";
229232
break;

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
258258
case OL_DEVICE_INFO_PLATFORM:
259259
return ReturnValue(Device->Platform);
260260
case OL_DEVICE_INFO_TYPE:
261-
return ReturnValue(OL_DEVICE_TYPE_GPU);
261+
return Device == HostDevice() ? ReturnValue(OL_DEVICE_TYPE_HOST)
262+
: ReturnValue(OL_DEVICE_TYPE_GPU);
262263
case OL_DEVICE_INFO_NAME:
263264
return ReturnValue(GetInfo({"Device Name"}).c_str());
264265
case OL_DEVICE_INFO_VENDOR:

offload/unittests/OffloadAPI/device/olGetDeviceInfo.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ TEST_P(olGetDeviceInfoTest, SuccessType) {
1919
sizeof(ol_device_type_t), &DeviceType));
2020
}
2121

22+
TEST_P(olGetDeviceInfoTest, HostSuccessType) {
23+
ol_device_type_t DeviceType;
24+
ASSERT_SUCCESS(olGetDeviceInfo(Host, OL_DEVICE_INFO_TYPE,
25+
sizeof(ol_device_type_t), &DeviceType));
26+
ASSERT_EQ(DeviceType, OL_DEVICE_TYPE_HOST);
27+
}
28+
2229
TEST_P(olGetDeviceInfoTest, SuccessPlatform) {
2330
ol_platform_handle_t Platform = nullptr;
2431
ASSERT_SUCCESS(olGetDeviceInfo(Device, OL_DEVICE_INFO_PLATFORM,

0 commit comments

Comments
 (0)