[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: https://github.com/llvm/llvm-project/issues/141436
This commit is contained in:
parent
06ee672fc5
commit
0ebe5557d9
@ -18,6 +18,7 @@ def : Enum {
|
|||||||
Etor<"ALL", "Devices of all types">,
|
Etor<"ALL", "Devices of all types">,
|
||||||
Etor<"GPU", "GPU device type">,
|
Etor<"GPU", "GPU device type">,
|
||||||
Etor<"CPU", "CPU device type">,
|
Etor<"CPU", "CPU device type">,
|
||||||
|
Etor<"Host", "Host device type">,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +320,8 @@ typedef enum ol_device_type_t {
|
|||||||
OL_DEVICE_TYPE_GPU = 2,
|
OL_DEVICE_TYPE_GPU = 2,
|
||||||
/// CPU device type
|
/// CPU device type
|
||||||
OL_DEVICE_TYPE_CPU = 3,
|
OL_DEVICE_TYPE_CPU = 3,
|
||||||
|
/// Host device type
|
||||||
|
OL_DEVICE_TYPE_HOST = 4,
|
||||||
/// @cond
|
/// @cond
|
||||||
OL_DEVICE_TYPE_FORCE_UINT32 = 0x7fffffff
|
OL_DEVICE_TYPE_FORCE_UINT32 = 0x7fffffff
|
||||||
/// @endcond
|
/// @endcond
|
||||||
|
@ -224,6 +224,9 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
|
|||||||
case OL_DEVICE_TYPE_CPU:
|
case OL_DEVICE_TYPE_CPU:
|
||||||
os << "OL_DEVICE_TYPE_CPU";
|
os << "OL_DEVICE_TYPE_CPU";
|
||||||
break;
|
break;
|
||||||
|
case OL_DEVICE_TYPE_HOST:
|
||||||
|
os << "OL_DEVICE_TYPE_HOST";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
os << "unknown enumerator";
|
os << "unknown enumerator";
|
||||||
break;
|
break;
|
||||||
|
@ -258,7 +258,8 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
|
|||||||
case OL_DEVICE_INFO_PLATFORM:
|
case OL_DEVICE_INFO_PLATFORM:
|
||||||
return ReturnValue(Device->Platform);
|
return ReturnValue(Device->Platform);
|
||||||
case OL_DEVICE_INFO_TYPE:
|
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:
|
case OL_DEVICE_INFO_NAME:
|
||||||
return ReturnValue(GetInfo({"Device Name"}).c_str());
|
return ReturnValue(GetInfo({"Device Name"}).c_str());
|
||||||
case OL_DEVICE_INFO_VENDOR:
|
case OL_DEVICE_INFO_VENDOR:
|
||||||
|
@ -19,6 +19,13 @@ TEST_P(olGetDeviceInfoTest, SuccessType) {
|
|||||||
sizeof(ol_device_type_t), &DeviceType));
|
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) {
|
TEST_P(olGetDeviceInfoTest, SuccessPlatform) {
|
||||||
ol_platform_handle_t Platform = nullptr;
|
ol_platform_handle_t Platform = nullptr;
|
||||||
ASSERT_SUCCESS(olGetDeviceInfo(Device, OL_DEVICE_INFO_PLATFORM,
|
ASSERT_SUCCESS(olGetDeviceInfo(Device, OL_DEVICE_INFO_PLATFORM,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user