-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[Offload] Add specifier for the host type #141635
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
Conversation
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: llvm#141436
@callumfare you should apply for access. |
@llvm/pr-subscribers-offload Author: Joseph Huber (jhuber6) ChangesSummary: Fixes: #141436 Full diff: https://github.com/llvm/llvm-project/pull/141635.diff 5 Files Affected:
diff --git a/offload/liboffload/API/Device.td b/offload/liboffload/API/Device.td
index 28c96bb5d2910..4abc24f3ba27f 100644
--- a/offload/liboffload/API/Device.td
+++ b/offload/liboffload/API/Device.td
@@ -18,6 +18,7 @@ def : Enum {
Etor<"ALL", "Devices of all types">,
Etor<"GPU", "GPU device type">,
Etor<"CPU", "CPU device type">,
+ Etor<"Host", "Host device type">,
];
}
diff --git a/offload/liboffload/include/generated/OffloadAPI.h b/offload/liboffload/include/generated/OffloadAPI.h
index f7ec749f6efa3..a1d7540519e32 100644
--- a/offload/liboffload/include/generated/OffloadAPI.h
+++ b/offload/liboffload/include/generated/OffloadAPI.h
@@ -320,6 +320,8 @@ typedef enum ol_device_type_t {
OL_DEVICE_TYPE_GPU = 2,
/// CPU device type
OL_DEVICE_TYPE_CPU = 3,
+ /// Host device type
+ OL_DEVICE_TYPE_HOST = 4,
/// @cond
OL_DEVICE_TYPE_FORCE_UINT32 = 0x7fffffff
/// @endcond
diff --git a/offload/liboffload/include/generated/OffloadPrint.hpp b/offload/liboffload/include/generated/OffloadPrint.hpp
index 9b916543eec0d..3aad6223d4dea 100644
--- a/offload/liboffload/include/generated/OffloadPrint.hpp
+++ b/offload/liboffload/include/generated/OffloadPrint.hpp
@@ -224,6 +224,9 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
case OL_DEVICE_TYPE_CPU:
os << "OL_DEVICE_TYPE_CPU";
break;
+ case OL_DEVICE_TYPE_HOST:
+ os << "OL_DEVICE_TYPE_HOST";
+ break;
default:
os << "unknown enumerator";
break;
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index ea65282e3ba52..d311251ee088f 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -252,7 +252,8 @@ ol_impl_result_t olGetDeviceInfoImplDetail(ol_device_handle_t Device,
case OL_DEVICE_INFO_PLATFORM:
return ReturnValue(Device->Platform);
case OL_DEVICE_INFO_TYPE:
- return ReturnValue(OL_DEVICE_TYPE_GPU);
+ return Device == HostDevice() ? ReturnValue(OL_DEVICE_TYPE_HOST)
+ : ReturnValue(OL_DEVICE_TYPE_GPU);
case OL_DEVICE_INFO_NAME:
return ReturnValue(GetInfo({"Device Name"}).c_str());
case OL_DEVICE_INFO_VENDOR:
diff --git a/offload/unittests/OffloadAPI/device/olGetDeviceInfo.cpp b/offload/unittests/OffloadAPI/device/olGetDeviceInfo.cpp
index 46ed622fa8b81..243bedddea6fe 100644
--- a/offload/unittests/OffloadAPI/device/olGetDeviceInfo.cpp
+++ b/offload/unittests/OffloadAPI/device/olGetDeviceInfo.cpp
@@ -19,6 +19,13 @@ TEST_P(olGetDeviceInfoTest, SuccessType) {
sizeof(ol_device_type_t), &DeviceType));
}
+TEST_P(olGetDeviceInfoTest, HostSuccessType) {
+ ol_device_type_t DeviceType;
+ ASSERT_SUCCESS(olGetDeviceInfo(Host, OL_DEVICE_INFO_TYPE,
+ sizeof(ol_device_type_t), &DeviceType));
+ ASSERT_EQ(DeviceType, OL_DEVICE_TYPE_HOST);
+}
+
TEST_P(olGetDeviceInfoTest, SuccessPlatform) {
ol_platform_handle_t Platform = nullptr;
ASSERT_SUCCESS(olGetDeviceInfo(Device, OL_DEVICE_INFO_PLATFORM,
|
Thanks, LGTM
I've just applied - #141729 |
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: llvm#141436
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