[llvm] [offload][l0] Implement context groups (PR #217562)
Kseniya Tikhomirova via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 06:26:56 PDT 2026
Jan =?utf-8?q?Trusiłło?= <jan.trusillo at intel.com>,
Jan =?utf-8?q?Trusiłło?= <jan.trusillo at intel.com>,
Jan =?utf-8?q?Trusiłło?= <jan.trusillo at intel.com>,
Jan =?utf-8?q?Trusiłło?= <jan.trusillo at intel.com>,
Jan =?utf-8?q?Trusiłło?= <jan.trusillo at intel.com>,
Jan =?utf-8?q?Trusiłło?= <jan.trusillo at intel.com>,
Jan =?utf-8?q?Trusiłło?= <jan.trusillo at intel.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/217562 at github.com>
================
@@ -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])
+ return 0;
+ if (Device == Devices[1])
+ return 1;
+ ADD_FAILURE() << "Unexpected device";
+ return 0;
+ }
+
+ unittests::UnittestsHelper Helper;
+ ol_platform_handle_t Platform{};
+ std::array<ol_device_handle_t, 3> Devices{};
+ bool FailContextGroupQuery = false;
+};
+
+TEST_F(PlatformContextGroupTest, CreatesPlatformForEachContextGroup) {
+ EXPECT_CALL(Helper.Mock.get(), olCreateContext(_, _, _))
+ .Times(2)
+ .WillRepeatedly([this](size_t NumDevices,
+ ol_device_handle_t *ContextDevices,
+ ol_context_handle_t *Context) -> ol_result_t {
+ EXPECT_GT(NumDevices, 0u);
+ if (NumDevices == 0)
+ return Helper.Mock.get().makeEmptyStrError(OL_ERRC_INVALID_SIZE);
+ const uint32_t ContextGroup = getContextGroup(ContextDevices[0]);
+ for (size_t I = 1; I < NumDevices; ++I)
+ EXPECT_EQ(getContextGroup(ContextDevices[I]), ContextGroup);
+
+ *Context = mock::createDummyHandleWithData<ol_context_handle_t>(
+ reinterpret_cast<unsigned char *>(&ContextDevices[0]),
+ sizeof(ContextDevices[0]));
+ return OL_SUCCESS;
+ });
+
+ auto Platforms = sycl::platform::get_platforms();
----------------
KseniyaTikhomirova wrote:
oh, you are right. Checks that I want to see in e2e, are not possible to implement for now (interop is needed). Please disregard this comment then. Thanks.
https://github.com/llvm/llvm-project/pull/217562
More information about the llvm-commits
mailing list