1 /* 2 * Copyright (C) 2018-2021 Intel Corporation 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 */ 7 8 #pragma once 9 10 #include "shared/source/command_stream/preemption_mode.h" 11 #include "shared/test/common/helpers/debug_manager_state_restore.h" 12 #include "shared/test/common/test_macros/test.h" 13 14 #include "gtest/gtest.h" 15 16 #include <cinttypes> 17 #include <memory> 18 #include <type_traits> 19 #include <unordered_map> 20 21 namespace iOpenCL { 22 struct SPatchExecutionEnvironment; 23 } 24 25 namespace NEO { 26 class MockCommandQueue; 27 class MockContext; 28 class MockDevice; 29 class MockProgram; 30 struct KernelInfo; 31 struct WorkaroundTable; 32 } // namespace NEO 33 34 class DevicePreemptionTests : public ::testing::Test { 35 public: 36 void SetUp() override; 37 void TearDown() override; 38 39 DevicePreemptionTests(); 40 ~DevicePreemptionTests() override; 41 42 NEO::PreemptionMode preemptionMode; 43 NEO::WorkaroundTable *waTable = nullptr; 44 std::unique_ptr<NEO::MockDevice> device; 45 std::unique_ptr<DebugManagerStateRestore> dbgRestore; 46 std::unique_ptr<iOpenCL::SPatchExecutionEnvironment> executionEnvironment; 47 }; 48 49 struct PreemptionTestHwDetails { 50 struct PreemptionModeHashT { 51 auto operator()(const NEO::PreemptionMode &preemptionMode) const -> std::underlying_type<NEO::PreemptionMode>::type { 52 return static_cast<std::underlying_type<NEO::PreemptionMode>::type>(preemptionMode); 53 } 54 }; 55 supportsPreemptionProgrammingPreemptionTestHwDetails56 bool supportsPreemptionProgramming() const { 57 return modeToRegValueMap.size() > 0; 58 } 59 60 uint32_t regAddress = 0; 61 std::unordered_map<NEO::PreemptionMode, uint32_t, PreemptionModeHashT> modeToRegValueMap; 62 uint32_t defaultRegValue = 0; 63 }; 64 65 template <typename FamilyType> 66 PreemptionTestHwDetails GetPreemptionTestHwDetails(); 67