[llvm] [Offload] Implement the remaining initial Offload API (PR #122106)
Callum Fare via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 09:00:51 PDT 2025
================
@@ -104,3 +104,15 @@ def : Function {
Return<"OL_ERRC_INVALID_DEVICE">
];
}
+
+def : Function {
+ let name = "olGetHostDevice";
----------------
callumfare wrote:
With the current API a user can already filter out specific devices:
```cpp
// For each platform:
size_t NumDevices;
olGetDeviceCount(Platform, &NumDevices);
std::vector<ol_device_handle_t> Devices(NumDevices);
olGetDevices(Platform, NumDevices, Devices.data());
for (auto Device : Devices) {
ol_device_type_t DeviceType;
olGetDeviceInfo(Device, OL_DEVICE_INFO_TYPE, sizeof(DeviceType), &DeviceType);
// Filter out anything that isn't a GPU
if (DeviceType == OL_DEVICE_TYPE_GPU) {
FilteredDevices.push_back(Device);
}
}
```
Similarly platforms (as they're implemented now) can be filtered out based on their `ol_platform_backend_t` property (e.g. only `OL_PLATFORM_BACKEND_AMDGPU`).
All that said we could add a filter parameter to `olGetDevices` like you said, as long as we can add `OL_DEVICE_TYPE_ANY` to allow getting all the devices. It would avoid the need for the above code but wouldn't cover filtering the backends, which we couldn't easily add a filter for if we get rid of `olGetPlatforms`. I'm more in favor of letting the user do the filtering according to their needs with all the information available to them rather than trying to cover all bases with the API, but I'm happy to add the device filter if you'd prefer it.
https://github.com/llvm/llvm-project/pull/122106
More information about the llvm-commits
mailing list