[llvm] [offload][l0] Implement context groups (PR #217562)

Jan Trusiłło via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 04:15:53 PDT 2026


================
@@ -36,3 +48,134 @@ TEST(PlatformTest, APIGetPlatformsDefaultMock) {
   ASSERT_EQ(CtxDevices[0], Devices[0]);
 #endif
 }
+
+namespace {
+
+class PlatformContextGroupTest : public Test {
+protected:
+  void SetUp() override {
+    Platform = mock::createDummyHandle<ol_platform_handle_t>();
+    for (ol_device_handle_t &Device : Devices) {
+      Device = mock::createDummyHandleWithData<ol_device_handle_t>(
+          reinterpret_cast<unsigned char *>(&Platform), sizeof(Platform));
+    }
+
+    EXPECT_CALL(Helper.Mock.get(), olIterateDevices(_, _))
+        .WillRepeatedly([this](ol_device_iterate_cb_t Callback,
+                               void *UserData) -> ol_result_t {
+          for (ol_device_handle_t Device : Devices)
+            std::ignore = Callback(Device, UserData);
+          return OL_SUCCESS;
+        });
+
+    ON_CALL(Helper.Mock.get(),
+            olGetDeviceInfo(_, OL_DEVICE_INFO_CONTEXT_GROUP_INDEX, _, _))
+        .WillByDefault([this](ol_device_handle_t Device,
+                              ol_device_info_t /*PropName*/, size_t PropSize,
+                              void *PropValue) -> ol_result_t {
+          EXPECT_EQ(PropSize, sizeof(uint32_t));
+          if (FailContextGroupQuery)
+            return Helper.Mock.get().makeEmptyStrError(OL_ERRC_UNIMPLEMENTED);
+
+          *static_cast<uint32_t *>(PropValue) = getContextGroup(Device);
+          return OL_SUCCESS;
+        });
+  }
+
+  void TearDown() override {
+    detail::getPlatformCache().clear();
+    detail::getOffloadTopologies() = {};
+    mock::releaseDummyHandles(Devices[0], Devices[1], Devices[2], Platform);
+  }
+
+  uint32_t getContextGroup(ol_device_handle_t Device) const {
+    if (Device == Devices[0] || Device == Devices[2])
----------------
311Volt wrote:

See https://github.com/llvm/llvm-project/pull/217562#discussion_r3852396392

https://github.com/llvm/llvm-project/pull/217562


More information about the llvm-commits mailing list