2020-06-10 18:47:58 +08:00
|
|
|
/*
|
2023-01-11 23:32:55 +08:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2020-06-10 18:47:58 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-09-23 06:24:59 +08:00
|
|
|
#include "opencl/source/helpers/cl_preemption_helper.h"
|
2023-01-11 23:32:55 +08:00
|
|
|
#include "opencl/source/helpers/dispatch_info.h"
|
2020-06-10 18:47:58 +08:00
|
|
|
#include "opencl/test/unit_test/fixtures/cl_preemption_fixture.h"
|
|
|
|
|
2022-03-14 18:15:57 +08:00
|
|
|
#include "gtest/gtest.h"
|
2020-06-10 18:47:58 +08:00
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
class ThreadGroupPreemptionTests : public DevicePreemptionTests {
|
|
|
|
void SetUp() override {
|
|
|
|
dbgRestore.reset(new DebugManagerStateRestore());
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::ThreadGroup));
|
|
|
|
preemptionMode = PreemptionMode::ThreadGroup;
|
|
|
|
DevicePreemptionTests::SetUp();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class MidThreadPreemptionTests : public DevicePreemptionTests {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
|
|
|
dbgRestore.reset(new DebugManagerStateRestore());
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
|
|
|
|
preemptionMode = PreemptionMode::MidThread;
|
|
|
|
DevicePreemptionTests::SetUp();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-22 00:48:37 +08:00
|
|
|
TEST_F(ThreadGroupPreemptionTests, GivenZeroSizedMdiThenThreadGroupPreemptioIsEnabled) {
|
2020-06-10 18:47:58 +08:00
|
|
|
MultiDispatchInfo multiDispatchInfo;
|
2021-09-23 06:24:59 +08:00
|
|
|
EXPECT_EQ(PreemptionMode::ThreadGroup, ClPreemptionHelper::taskPreemptionMode(device->getDevice(), multiDispatchInfo));
|
2020-06-10 18:47:58 +08:00
|
|
|
}
|
|
|
|
|
2020-12-22 00:48:37 +08:00
|
|
|
TEST_F(ThreadGroupPreemptionTests, GivenValidKernelsInMdiThenThreadGroupPreemptioIsEnabled) {
|
2020-06-10 18:47:58 +08:00
|
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
|
|
multiDispatchInfo.push(*dispatchInfo);
|
|
|
|
multiDispatchInfo.push(*dispatchInfo);
|
2021-09-23 06:24:59 +08:00
|
|
|
EXPECT_EQ(PreemptionMode::ThreadGroup, ClPreemptionHelper::taskPreemptionMode(device->getDevice(), multiDispatchInfo));
|
2020-06-10 18:47:58 +08:00
|
|
|
}
|
|
|
|
|
2020-12-22 00:48:37 +08:00
|
|
|
TEST_F(ThreadGroupPreemptionTests, GivenValidKernelsInMdiAndDisabledPremptionThenPreemptionIsDisabled) {
|
2020-06-10 18:47:58 +08:00
|
|
|
device->setPreemptionMode(PreemptionMode::Disabled);
|
|
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
|
|
multiDispatchInfo.push(*dispatchInfo);
|
|
|
|
multiDispatchInfo.push(*dispatchInfo);
|
2021-09-23 06:24:59 +08:00
|
|
|
EXPECT_EQ(PreemptionMode::Disabled, ClPreemptionHelper::taskPreemptionMode(device->getDevice(), multiDispatchInfo));
|
2020-06-10 18:47:58 +08:00
|
|
|
}
|
|
|
|
|
2021-09-23 21:06:18 +08:00
|
|
|
TEST_F(MidThreadPreemptionTests, GivenMultiDispatchWithoutKernelWhenDevicePreemptionIsMidThreadThenTaskPreemptionIsMidThread) {
|
|
|
|
dispatchInfo.reset(new DispatchInfo(device.get(), nullptr, 1, Vec3<size_t>(1, 1, 1), Vec3<size_t>(1, 1, 1), Vec3<size_t>(0, 0, 0)));
|
|
|
|
|
|
|
|
MultiDispatchInfo multiDispatchInfo;
|
|
|
|
multiDispatchInfo.push(*dispatchInfo);
|
|
|
|
|
|
|
|
EXPECT_EQ(PreemptionMode::MidThread, ClPreemptionHelper::taskPreemptionMode(device->getDevice(), multiDispatchInfo));
|
|
|
|
}
|