mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00

Include files are now grouped and sorted in following order: 1. Header file of the class the current file implements 2. Project files 3. Third party files 4. Standard library Change-Id: If31af05652184169f7fee1d7ad08f1b2ed602cf0 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
99 lines
2.8 KiB
C++
99 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "test.h"
|
|
#include "unit_tests/fixtures/hello_world_fixture.h"
|
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <cinttypes>
|
|
#include <memory>
|
|
#include <type_traits>
|
|
#include <unordered_map>
|
|
|
|
namespace iOpenCL {
|
|
struct SPatchExecutionEnvironment;
|
|
}
|
|
|
|
namespace OCLRT {
|
|
class DispatchInfo;
|
|
class MockCommandQueue;
|
|
class MockContext;
|
|
class MockDevice;
|
|
class MockKernel;
|
|
class MockProgram;
|
|
struct KernelInfo;
|
|
struct WorkaroundTable;
|
|
|
|
using PreemptionEnqueueKernelFixture = HelloWorldFixture<HelloWorldFixtureFactory>;
|
|
using PreemptionEnqueueKernelTest = Test<PreemptionEnqueueKernelFixture>;
|
|
} // namespace OCLRT
|
|
|
|
class DevicePreemptionTests : public ::testing::Test {
|
|
public:
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
void forceWhitelistedRegs(bool whitelisted);
|
|
|
|
DevicePreemptionTests();
|
|
~DevicePreemptionTests() override;
|
|
|
|
OCLRT::PreemptionMode preemptionMode;
|
|
OCLRT::WorkaroundTable *waTable = nullptr;
|
|
std::unique_ptr<OCLRT::DispatchInfo> dispatchInfo;
|
|
std::unique_ptr<OCLRT::MockKernel> kernel;
|
|
std::unique_ptr<OCLRT::MockCommandQueue> cmdQ;
|
|
std::unique_ptr<OCLRT::MockDevice> device;
|
|
std::unique_ptr<OCLRT::MockContext> context;
|
|
std::unique_ptr<DebugManagerStateRestore> dbgRestore;
|
|
std::unique_ptr<iOpenCL::SPatchExecutionEnvironment> executionEnvironment;
|
|
std::unique_ptr<OCLRT::MockProgram> program;
|
|
std::unique_ptr<OCLRT::KernelInfo> kernelInfo;
|
|
};
|
|
|
|
struct ThreadGroupPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest {
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
|
|
OCLRT::HardwareInfo *globalHwInfo;
|
|
OCLRT::PreemptionMode originalPreemptionMode;
|
|
|
|
std::unique_ptr<DebugManagerStateRestore> dbgRestore;
|
|
};
|
|
|
|
struct MidThreadPreemptionEnqueueKernelTest : OCLRT::PreemptionEnqueueKernelTest {
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
|
|
OCLRT::HardwareInfo *globalHwInfo;
|
|
OCLRT::PreemptionMode originalPreemptionMode;
|
|
|
|
std::unique_ptr<DebugManagerStateRestore> dbgRestore;
|
|
};
|
|
|
|
struct PreemptionTestHwDetails {
|
|
struct PreemptionModeHashT {
|
|
auto operator()(const OCLRT::PreemptionMode &preemptionMode) const -> std::underlying_type<OCLRT::PreemptionMode>::type {
|
|
return static_cast<std::underlying_type<OCLRT::PreemptionMode>::type>(preemptionMode);
|
|
}
|
|
};
|
|
|
|
bool supportsPreemptionProgramming() const {
|
|
return modeToRegValueMap.size() > 0;
|
|
}
|
|
|
|
uint32_t regAddress = 0;
|
|
std::unordered_map<OCLRT::PreemptionMode, uint32_t, PreemptionModeHashT> modeToRegValueMap;
|
|
uint32_t defaultRegValue = 0;
|
|
};
|
|
|
|
template <typename FamilyType>
|
|
PreemptionTestHwDetails GetPreemptionTestHwDetails();
|