1 /* 2 * Copyright (C) 2020-2021 Intel Corporation 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 */ 7 8 #pragma once 9 10 #include "shared/source/command_container/implicit_scaling.h" 11 #include "shared/test/common/helpers/variable_backup.h" 12 #include "shared/test/common/test_macros/test.h" 13 14 #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" 15 #include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" 16 17 namespace L0 { 18 namespace ult { 19 20 class CommandListFixture : public DeviceFixture { 21 public: SetUp()22 void SetUp() { 23 DeviceFixture::SetUp(); 24 ze_result_t returnValue; 25 commandList.reset(whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue))); 26 27 ze_event_pool_desc_t eventPoolDesc = {}; 28 eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; 29 eventPoolDesc.count = 2; 30 31 ze_event_desc_t eventDesc = {}; 32 eventDesc.index = 0; 33 eventDesc.wait = 0; 34 eventDesc.signal = 0; 35 36 eventPool = std::unique_ptr<EventPool>(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue)); 37 event = std::unique_ptr<Event>(Event::create<uint32_t>(eventPool.get(), &eventDesc, device)); 38 } 39 TearDown()40 void TearDown() { 41 DeviceFixture::TearDown(); 42 } 43 44 std::unique_ptr<L0::ult::CommandList> commandList; 45 std::unique_ptr<EventPool> eventPool; 46 std::unique_ptr<Event> event; 47 }; 48 49 template <bool createImmediate, bool createInternal> 50 struct MultiTileCommandListFixture : public SingleRootMultiSubDeviceFixture { SetUpMultiTileCommandListFixture51 void SetUp() { 52 osLocalMemoryBackup = std::make_unique<VariableBackup<bool>>(&NEO::OSInterface::osEnableLocalMemory, true); 53 apiSupportBackup = std::make_unique<VariableBackup<bool>>(&NEO::ImplicitScaling::apiSupport, true); 54 55 SingleRootMultiSubDeviceFixture::SetUp(); 56 ze_result_t returnValue; 57 if (!createImmediate) { 58 commandList.reset(whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue))); 59 } else { 60 const ze_command_queue_desc_t desc = {}; 61 commandList.reset(whitebox_cast(CommandList::createImmediate(productFamily, device, &desc, createInternal, NEO::EngineGroupType::RenderCompute, returnValue))); 62 } 63 ASSERT_EQ(ZE_RESULT_SUCCESS, returnValue); 64 65 ze_event_pool_desc_t eventPoolDesc = {}; 66 eventPoolDesc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; 67 eventPoolDesc.count = 2; 68 69 ze_event_desc_t eventDesc = {}; 70 eventDesc.index = 0; 71 eventDesc.wait = 0; 72 eventDesc.signal = 0; 73 74 eventPool = std::unique_ptr<EventPool>(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue)); 75 event = std::unique_ptr<Event>(Event::create<uint32_t>(eventPool.get(), &eventDesc, device)); 76 } 77 TearDownMultiTileCommandListFixture78 void TearDown() { 79 SingleRootMultiSubDeviceFixture::TearDown(); 80 } 81 82 std::unique_ptr<L0::ult::CommandList> commandList; 83 std::unique_ptr<EventPool> eventPool; 84 std::unique_ptr<Event> event; 85 std::unique_ptr<VariableBackup<bool>> apiSupportBackup; 86 std::unique_ptr<VariableBackup<bool>> osLocalMemoryBackup; 87 }; 88 89 } // namespace ult 90 } // namespace L0 91