diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index f61b3f46c2..fe3baaaed8 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -135,7 +135,7 @@ ze_result_t CommandListCoreFamily::initialize(Device *device, NEO commandContainer.setReservedSshSize(getReserveSshSize()); DeviceImp *deviceImp = static_cast(device); - auto returnValue = commandContainer.initialize(deviceImp->getActiveDevice(), deviceImp->allocationsForReuse.get()); + auto returnValue = commandContainer.initialize(deviceImp->getActiveDevice(), deviceImp->allocationsForReuse.get(), !isCopyOnly()); ze_result_t returnType = parseErrorCode(returnValue); if (returnType == ZE_RESULT_SUCCESS) { if (!isCopyOnly()) { diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index a76de02371..e76d2a48f2 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -1549,7 +1549,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandListCreate, whenBindlessModeEnabledWhenComman ASSERT_EQ(cmdList.end(), itor); } -HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenCreatedThenStateBaseAddressCmdIsNotProgrammed) { +HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenCreatedThenStateBaseAddressCmdIsNotProgrammedAndHeapIsNotAllocated) { using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; ze_result_t returnValue; @@ -1562,6 +1562,11 @@ HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenCreatedThenStateBase auto itor = find(cmdList.begin(), cmdList.end()); EXPECT_EQ(cmdList.end(), itor); + + for (uint32_t i = 0; i < NEO::HeapType::NUM_TYPES; i++) { + ASSERT_EQ(commandList->commandContainer.getIndirectHeap(static_cast(i)), nullptr); + ASSERT_EQ(commandList->commandContainer.getIndirectHeapAllocation(static_cast(i)), nullptr); + } } HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenSetBarrierThenMiFlushDWIsProgrammed) { diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp index 9e2c0fecc6..77e609f86d 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp @@ -775,18 +775,21 @@ HWTEST_F(CommandQueueIndirectAllocations, givenCommandQueueWhenExecutingCommandL MockCsrHw2 csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield()); csr.initializeTagAllocation(); csr.setupContext(*neoDevice->getDefaultEngine().osContext); + if (device->getNEODevice()->getPreemptionMode() == PreemptionMode::MidThread || device->getNEODevice()->isDebuggerActive()) { + csr.createPreemptionAllocation(); + } ze_result_t returnValue; L0::CommandQueue *commandQueue = CommandQueue::create(productFamily, device, &csr, &desc, - true, + false, false, returnValue); ASSERT_NE(nullptr, commandQueue); - std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Copy, 0u, returnValue)); + std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, 0u, returnValue)); void *deviceAlloc = nullptr; ze_device_mem_alloc_desc_t deviceDesc = {}; @@ -834,18 +837,21 @@ HWTEST_F(CommandQueueIndirectAllocations, givenDebugModeToTreatIndirectAllocatio MockCsrHw2 csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield()); csr.initializeTagAllocation(); csr.setupContext(*neoDevice->getDefaultEngine().osContext); + if (device->getNEODevice()->getPreemptionMode() == PreemptionMode::MidThread || device->getNEODevice()->isDebuggerActive()) { + csr.createPreemptionAllocation(); + } ze_result_t returnValue; L0::CommandQueue *commandQueue = CommandQueue::create(productFamily, device, &csr, &desc, - true, + false, false, returnValue); ASSERT_NE(nullptr, commandQueue); - std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Copy, 0u, returnValue)); + std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, 0u, returnValue)); void *deviceAlloc = nullptr; ze_device_mem_alloc_desc_t deviceDesc = {}; @@ -892,18 +898,21 @@ HWTEST_F(CommandQueueIndirectAllocations, givenDeviceThatSupportsSubmittingIndir MockCsrHw2 csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield()); csr.initializeTagAllocation(); csr.setupContext(*neoDevice->getDefaultEngine().osContext); + if (device->getNEODevice()->getPreemptionMode() == PreemptionMode::MidThread || device->getNEODevice()->isDebuggerActive()) { + csr.createPreemptionAllocation(); + } ze_result_t returnValue; L0::CommandQueue *commandQueue = CommandQueue::create(productFamily, device, &csr, &desc, - true, + false, false, returnValue); ASSERT_NE(nullptr, commandQueue); - std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Copy, 0u, returnValue)); + std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, 0u, returnValue)); void *deviceAlloc = nullptr; ze_device_mem_alloc_desc_t deviceDesc = {}; diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_1.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_1.cpp index 5ce64ba404..3af14f7d96 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_1.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_1.cpp @@ -1020,7 +1020,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenNotChangedSurfaceStateWhenCapturingSBAThenNo debugger->sbaTrackingGpuVa.address = 0x45670000; NEO::CommandContainer container; - container.initialize(neoDevice, nullptr); + container.initialize(neoDevice, nullptr, true); NEO::Debugger::SbaAddresses sba = {}; sba.SurfaceStateBaseAddress = 0x123456000; @@ -1043,7 +1043,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenChangedBaseAddressesWhenCapturingSBAThenNoTr debugger->sbaTrackingGpuVa.address = 0x45670000; { NEO::CommandContainer container; - container.initialize(neoDevice, nullptr); + container.initialize(neoDevice, nullptr, true); NEO::Debugger::SbaAddresses sba = {}; sba.SurfaceStateBaseAddress = 0x123456000; @@ -1056,7 +1056,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenChangedBaseAddressesWhenCapturingSBAThenNoTr { NEO::CommandContainer container; - container.initialize(neoDevice, nullptr); + container.initialize(neoDevice, nullptr, true); NEO::Debugger::SbaAddresses sba = {}; sba.GeneralStateBaseAddress = 0x123456000; @@ -1069,7 +1069,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenChangedBaseAddressesWhenCapturingSBAThenNoTr { NEO::CommandContainer container; - container.initialize(neoDevice, nullptr); + container.initialize(neoDevice, nullptr, true); NEO::Debugger::SbaAddresses sba = {}; sba.BindlessSurfaceStateBaseAddress = 0x123456000; diff --git a/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp b/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp index 1c894c0a9a..7b913f94d0 100644 --- a/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp +++ b/opencl/test/unit_test/source_level_debugger/source_level_debugger_tests.cpp @@ -702,7 +702,7 @@ TEST(SourceLevelDebugger, whenCaptureSBACalledThenNoCommandsAreAddedToStream) { MockSourceLevelDebugger debugger; CommandContainer container; - container.initialize(device.get(), nullptr); + container.initialize(device.get(), nullptr, true); NEO::Debugger::SbaAddresses sbaAddresses = {}; debugger.captureStateBaseAddress(container, sbaAddresses); diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index 631db7c88c..a3f44b7034 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -55,7 +55,7 @@ CommandContainer::CommandContainer(uint32_t maxNumAggregatedIdds) : CommandConta numIddsPerBlock = maxNumAggregatedIdds; } -ErrorCode CommandContainer::initialize(Device *device, AllocationsList *reusableAllocationList) { +ErrorCode CommandContainer::initialize(Device *device, AllocationsList *reusableAllocationList, bool requireHeaps) { this->device = device; this->reusableAllocationList = reusableAllocationList; @@ -79,37 +79,38 @@ ErrorCode CommandContainer::initialize(Device *device, AllocationsList *reusable if (!getFlushTaskUsedForImmediate()) { addToResidencyContainer(cmdBufferAllocation); } + if (requireHeaps) { + constexpr size_t heapSize = 65536u; + heapHelper = std::unique_ptr(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumGenericSubDevices() > 1u)); - constexpr size_t heapSize = 65536u; - heapHelper = std::unique_ptr(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumGenericSubDevices() > 1u)); + for (uint32_t i = 0; i < IndirectHeap::Type::NUM_TYPES; i++) { + if (NEO::ApiSpecificConfig::getBindlessConfiguration() && i != IndirectHeap::Type::INDIRECT_OBJECT) { + continue; + } + allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i, + heapSize, + alignedSize, + device->getRootDeviceIndex()); + if (!allocationIndirectHeaps[i]) { + return ErrorCode::OUT_OF_DEVICE_MEMORY; + } + residencyContainer.push_back(allocationIndirectHeaps[i]); - for (uint32_t i = 0; i < IndirectHeap::Type::NUM_TYPES; i++) { - if (NEO::ApiSpecificConfig::getBindlessConfiguration() && i != IndirectHeap::Type::INDIRECT_OBJECT) { - continue; + bool requireInternalHeap = (IndirectHeap::Type::INDIRECT_OBJECT == i); + indirectHeaps[i] = std::make_unique(allocationIndirectHeaps[i], requireInternalHeap); + if (i == IndirectHeap::Type::SURFACE_STATE) { + indirectHeaps[i]->getSpace(reservedSshSize); + } } - allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i, - heapSize, - alignedSize, - device->getRootDeviceIndex()); - if (!allocationIndirectHeaps[i]) { - return ErrorCode::OUT_OF_DEVICE_MEMORY; - } - residencyContainer.push_back(allocationIndirectHeaps[i]); - bool requireInternalHeap = (IndirectHeap::Type::INDIRECT_OBJECT == i); - indirectHeaps[i] = std::make_unique(allocationIndirectHeaps[i], requireInternalHeap); - if (i == IndirectHeap::Type::SURFACE_STATE) { - indirectHeaps[i]->getSpace(reservedSshSize); - } + indirectObjectHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), allocationIndirectHeaps[IndirectHeap::Type::INDIRECT_OBJECT]->isAllocatedInLocalMemoryPool()); + + instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), device->getMemoryManager()->isLocalMemoryUsedForIsa(device->getRootDeviceIndex())); + + iddBlock = nullptr; + nextIddInBlock = this->getNumIddPerBlock(); } - indirectObjectHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), allocationIndirectHeaps[IndirectHeap::Type::INDIRECT_OBJECT]->isAllocatedInLocalMemoryPool()); - - instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), device->getMemoryManager()->isLocalMemoryUsedForIsa(device->getRootDeviceIndex())); - - iddBlock = nullptr; - nextIddInBlock = this->getNumIddPerBlock(); - return ErrorCode::SUCCESS; } diff --git a/shared/source/command_container/cmdcontainer.h b/shared/source/command_container/cmdcontainer.h index 367fffae3e..346c057f08 100644 --- a/shared/source/command_container/cmdcontainer.h +++ b/shared/source/command_container/cmdcontainer.h @@ -69,7 +69,7 @@ class CommandContainer : public NonCopyableOrMovableClass { void *getHeapSpaceAllowGrow(HeapType heapType, size_t size); - ErrorCode initialize(Device *device, AllocationsList *reusableAllocationList); + ErrorCode initialize(Device *device, AllocationsList *reusableAllocationList, bool requireHeaps); void prepareBindfulSsh(); diff --git a/shared/test/common/fixtures/command_container_fixture.h b/shared/test/common/fixtures/command_container_fixture.h index 13edff3d49..f7e6519e3d 100644 --- a/shared/test/common/fixtures/command_container_fixture.h +++ b/shared/test/common/fixtures/command_container_fixture.h @@ -23,7 +23,7 @@ class CommandEncodeStatesFixture : public DeviceFixture { void SetUp() { DeviceFixture::SetUp(); cmdContainer = std::make_unique(); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); } void TearDown() { diff --git a/shared/test/common/gen11/test_encode_math_gen11.cpp b/shared/test/common/gen11/test_encode_math_gen11.cpp index e1c934e990..948dff1932 100644 --- a/shared/test/common/gen11/test_encode_math_gen11.cpp +++ b/shared/test/common/gen11/test_encode_math_gen11.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -23,7 +23,7 @@ GEN11TEST_F(CommandEncoderMathTestGen11, WhenAppendsAGreaterThanThenPredicateCor using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeMathMMIO::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); diff --git a/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp b/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp index 6dcbb2bc64..e749263339 100644 --- a/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp +++ b/shared/test/common/gen12lp/test_command_encoder_gen12lp.cpp @@ -25,7 +25,7 @@ GEN12LPTEST_F(CommandEncoderTest, WhenAdjustComputeModeIsCalledThenStateComputeM CommandContainer cmdContainer; - auto ret = cmdContainer.initialize(pDevice, nullptr); + auto ret = cmdContainer.initialize(pDevice, nullptr, true); ASSERT_EQ(ErrorCode::SUCCESS, ret); auto usedSpaceBefore = cmdContainer.getCommandStream()->getUsed(); @@ -53,7 +53,7 @@ GEN12LPTEST_F(CommandEncoderTest, WhenAdjustComputeModeIsCalledThenStateComputeM GEN12LPTEST_F(CommandEncoderTest, givenCommandContainerWhenEncodeL3StateThenDoNotDispatchMMIOCommand) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeL3State::encode(cmdContainer, false); GenCmdList commands; @@ -75,7 +75,7 @@ GEN12LPTEST_F(CommandEncoderTest, givenVariousEngineTypesWhenEncodeSBAThenAdditi CommandContainer cmdContainer; - auto ret = cmdContainer.initialize(pDevice, nullptr); + auto ret = cmdContainer.initialize(pDevice, nullptr, true); ASSERT_EQ(ErrorCode::SUCCESS, ret); { @@ -111,7 +111,7 @@ GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOnThenExpect using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeL3State::encode(cmdContainer, true); @@ -125,7 +125,7 @@ GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOnThenExpect GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOffThenExpectNoCommandsDispatched) { using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeL3State::encode(cmdContainer, false); diff --git a/shared/test/common/gen12lp/test_encode_math_gen12lp.cpp b/shared/test/common/gen12lp/test_encode_math_gen12lp.cpp index 2200213c9f..77426a12c0 100644 --- a/shared/test/common/gen12lp/test_encode_math_gen12lp.cpp +++ b/shared/test/common/gen12lp/test_encode_math_gen12lp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -23,7 +23,7 @@ GEN12LPTEST_F(CommandEncoderMathTestGen12Lp, WhenAppendsAGreaterThanThenPredicat using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeMathMMIO::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); diff --git a/shared/test/common/gen8/test_encode_math_gen8.cpp b/shared/test/common/gen8/test_encode_math_gen8.cpp index 5837ade430..9f4fef8779 100644 --- a/shared/test/common/gen8/test_encode_math_gen8.cpp +++ b/shared/test/common/gen8/test_encode_math_gen8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -23,7 +23,7 @@ GEN8TEST_F(CommandEncoderMathTestGen8, WhenAppendsAGreaterThanThenPredicateCorre using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeMathMMIO::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); diff --git a/shared/test/common/gen9/test_command_encoder_gen9.cpp b/shared/test/common/gen9/test_command_encoder_gen9.cpp index 1d11101fed..b91fabbe38 100644 --- a/shared/test/common/gen9/test_command_encoder_gen9.cpp +++ b/shared/test/common/gen9/test_command_encoder_gen9.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -19,7 +19,7 @@ using CommandEncoderTest = Test; GEN9TEST_F(CommandEncoderTest, WhenProgrammingThenLoadRegisterImmIsUsed) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeL3State::encode(cmdContainer, false); GenCmdList commands; @@ -32,7 +32,7 @@ GEN9TEST_F(CommandEncoderTest, WhenProgrammingThenLoadRegisterImmIsUsed) { GEN9TEST_F(CommandEncoderTest, givenNoSlmThenCorrectMmioIsSet) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeL3State::encode(cmdContainer, false); GenCmdList commands; @@ -49,7 +49,7 @@ GEN9TEST_F(CommandEncoderTest, givenNoSlmThenCorrectMmioIsSet) { GEN9TEST_F(CommandEncoderTest, givenSlmThenCorrectMmioIsSet) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeL3State::encode(cmdContainer, true); GenCmdList commands; diff --git a/shared/test/common/gen9/test_encode_math_gen9.cpp b/shared/test/common/gen9/test_encode_math_gen9.cpp index 4983845362..e72e731da0 100644 --- a/shared/test/common/gen9/test_encode_math_gen9.cpp +++ b/shared/test/common/gen9/test_encode_math_gen9.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -23,7 +23,7 @@ GEN9TEST_F(CommandEncoderMathTestGen9, WhenAppendsAGreaterThanThenPredicateCorre using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeMathMMIO::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); diff --git a/shared/test/unit_test/command_container/command_container_tests.cpp b/shared/test/unit_test/command_container/command_container_tests.cpp index 63bd964e09..b12511c0a0 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -88,7 +88,7 @@ TEST_F(CommandContainerHeapStateTests, givenDirtyHeapsWhenSettingStateForSingleH TEST_F(CommandContainerTest, givenCmdContainerWhenCreatingCommandBufferThenCorrectAllocationTypeIsSet) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); ASSERT_NE(0u, cmdContainer.getCmdBufferAllocations().size()); EXPECT_EQ(AllocationType::COMMAND_BUFFER, cmdContainer.getCmdBufferAllocations()[0]->getAllocationType()); @@ -101,7 +101,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenCreatingCommandBufferThenCorre TEST_F(CommandContainerTest, givenCmdContainerWhenAllocatingHeapsThenSetCorrectAllocationTypes) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); for (uint32_t i = 0; i < HeapType::NUM_TYPES; i++) { HeapType heapType = static_cast(i); @@ -119,7 +119,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenAllocatingHeapsThenSetCorrectA TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIsInitialized) { CommandContainer cmdContainer; - auto status = cmdContainer.initialize(pDevice, nullptr); + auto status = cmdContainer.initialize(pDevice, nullptr, true); EXPECT_EQ(ErrorCode::SUCCESS, status); EXPECT_EQ(pDevice, cmdContainer.getDevice()); @@ -142,6 +142,27 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIs pDevice->getMemoryManager()->getInternalHeapBaseAddress(0, !hwHelper.useSystemMemoryPlacementForISA(pDevice->getHardwareInfo()))); } +TEST_F(CommandContainerTest, givenCommandContainerWhenHeapNotRequiredThenHeapIsNotInitialized) { + CommandContainer cmdContainer; + auto status = cmdContainer.initialize(pDevice, nullptr, false); + EXPECT_EQ(ErrorCode::SUCCESS, status); + + EXPECT_EQ(pDevice, cmdContainer.getDevice()); + EXPECT_EQ(cmdContainer.getHeapHelper(), nullptr); + EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 1u); + EXPECT_NE(cmdContainer.getCommandStream(), nullptr); + + for (uint32_t i = 0; i < HeapType::NUM_TYPES; i++) { + auto indirectHeap = cmdContainer.getIndirectHeap(static_cast(i)); + EXPECT_EQ(indirectHeap, nullptr); + } + + EXPECT_EQ(cmdContainer.getIddBlock(), nullptr); + EXPECT_EQ(cmdContainer.getNumIddPerBlock(), defaultNumIddsPerBlock); + + EXPECT_EQ(cmdContainer.getInstructionHeapBaseAddress(), 0u); +} + TEST_F(CommandContainerTest, givenEnabledLocalMemoryAndIsaInSystemMemoryWhenCmdContainerIsInitializedThenInstructionBaseAddressIsSetToInternalHeap) { DebugManagerStateRestore dbgRestore; DebugManager.flags.ForceSystemMemoryPlacement.set(1 << (static_cast(AllocationType::KERNEL_ISA) - 1)); @@ -159,7 +180,7 @@ TEST_F(CommandContainerTest, givenEnabledLocalMemoryAndIsaInSystemMemoryWhenCmdC auto instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(0, false); CommandContainer cmdContainer; - auto status = cmdContainer.initialize(device.get(), nullptr); + auto status = cmdContainer.initialize(device.get(), nullptr, true); EXPECT_EQ(ErrorCode::SUCCESS, status); EXPECT_EQ(instructionHeapBaseAddress, cmdContainer.getInstructionHeapBaseAddress()); @@ -168,14 +189,14 @@ TEST_F(CommandContainerTest, givenEnabledLocalMemoryAndIsaInSystemMemoryWhenCmdC TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateGfxMemoryFailsThenErrorIsReturned) { CommandContainer cmdContainer; pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(0, *pDevice->executionEnvironment)); - auto status = cmdContainer.initialize(pDevice, nullptr); + auto status = cmdContainer.initialize(pDevice, nullptr, true); EXPECT_EQ(ErrorCode::OUT_OF_DEVICE_MEMORY, status); } TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndResetThenCmdBufferAllocIsReused) { AllocationsList allocList; auto cmdContainer = std::make_unique(); - cmdContainer->initialize(pDevice, &allocList); + cmdContainer->initialize(pDevice, &allocList, true); auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations(); auto memoryManager = static_cast(pDevice->getMemoryManager()); EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u); @@ -210,7 +231,7 @@ TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateHeapMemo CommandContainer cmdContainer; auto temp_memoryManager = pDevice->executionEnvironment->memoryManager.release(); pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(1, *pDevice->executionEnvironment)); - auto status = cmdContainer.initialize(pDevice, nullptr); + auto status = cmdContainer.initialize(pDevice, nullptr, true); EXPECT_EQ(ErrorCode::OUT_OF_DEVICE_MEMORY, status); delete temp_memoryManager; } @@ -225,10 +246,10 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenSettingIndirectHeapAllocat TEST_F(CommandContainerTest, givenHeapAllocationsWhenDestroyCommandContainerThenHeapAllocationsAreReused) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); auto heapAllocationsAddress = cmdContainer->getIndirectHeapAllocation(HeapType::DYNAMIC_STATE)->getUnderlyingBuffer(); cmdContainer.reset(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); bool status = false; for (uint32_t i = 0; i < HeapType::NUM_TYPES && !status; i++) { status = cmdContainer->getIndirectHeapAllocation(static_cast(i))->getUnderlyingBuffer() == heapAllocationsAddress; @@ -238,7 +259,7 @@ TEST_F(CommandContainerTest, givenHeapAllocationsWhenDestroyCommandContainerThen TEST_F(CommandContainerTest, givenCommandContainerWhenResetThenStateIsReset) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); LinearStream stream; uint32_t usedSize = 1; cmdContainer.getCommandStream()->getSpace(usedSize); @@ -252,7 +273,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenResetThenStateIsReset) { TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddNullPtrToResidencyContainerThenNothingIsAdded) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto size = cmdContainer.getResidencyContainer().size(); cmdContainer.addToResidencyContainer(nullptr); EXPECT_EQ(cmdContainer.getResidencyContainer().size(), size); @@ -260,7 +281,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddNullPtrToResidenc TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddAlreadyAddedAllocationAndDuplicatesRemovedThenExpectedSizeIsReturned) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); MockGraphicsAllocation mockAllocation; auto sizeBefore = cmdContainer.getResidencyContainer().size(); @@ -285,7 +306,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerWhenInitializeCalledThenSSHHeapH using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; std::unique_ptr cmdContainer(new CommandContainer); cmdContainer->setReservedSshSize(4 * MemoryConstants::pageSize); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); @@ -298,7 +319,7 @@ HWTEST_F(CommandContainerTest, givenNotEnoughSpaceInSSHWhenGettingHeapWithRequir using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; std::unique_ptr cmdContainer(new CommandContainer); cmdContainer->setReservedSshSize(4 * MemoryConstants::pageSize); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); @@ -313,7 +334,7 @@ HWTEST_F(CommandContainerTest, givenNotEnoughSpaceInSSHWhenGettingHeapWithRequir TEST_F(CommandContainerTest, givenAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenExistingAllocationIsReturned) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); HeapType types[] = {HeapType::SURFACE_STATE, HeapType::DYNAMIC_STATE}; @@ -344,7 +365,7 @@ TEST_F(CommandContainerTest, givenAvailableSpaceWhenGetHeapWithRequiredSizeAndAl TEST_F(CommandContainerTest, givenUnalignedAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenHeapReturnedIsCorrectlyAligned) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); auto heapAllocation = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); @@ -368,7 +389,7 @@ TEST_F(CommandContainerTest, givenUnalignedAvailableSpaceWhenGetHeapWithRequired TEST_F(CommandContainerTest, givenNoAlignmentAndAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenHeapReturnedIsNotAligned) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); auto heapAllocation = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); @@ -392,7 +413,7 @@ TEST_F(CommandContainerTest, givenNoAlignmentAndAvailableSpaceWhenGetHeapWithReq TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenNewAllocationIsReturned) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); HeapType types[] = {HeapType::SURFACE_STATE, HeapType::DYNAMIC_STATE}; @@ -426,7 +447,7 @@ TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenGetHeapWithRequiredSizeAndAl TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenCreatedAlocationHaveDifferentBaseThenHeapIsDirty) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); HeapType type = HeapType::INDIRECT_OBJECT; @@ -458,7 +479,7 @@ TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenCreatedAlocationHaveDifferen TEST_F(CommandContainerTest, whenAllocateNextCmdBufferIsCalledThenNewAllocationIsCreatedAndCommandStreamReplaced) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); auto stream = cmdContainer->getCommandStream(); ASSERT_NE(nullptr, stream); @@ -486,7 +507,7 @@ TEST_F(CommandContainerTest, whenAllocateNextCmdBufferIsCalledThenNewAllocationI TEST_F(CommandContainerTest, whenResettingCommandContainerThenStoredCmdBuffersAreFreedAndStreamIsReplacedWithInitialBuffer) { std::unique_ptr cmdContainer(new CommandContainer); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->allocateNextCommandBuffer(); cmdContainer->allocateNextCommandBuffer(); @@ -531,7 +552,7 @@ TEST_P(CommandContainerHeaps, givenCommandContainerWhenGetAllowHeapGrowCalledThe HeapType heap = GetParam(); CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto usedSpaceBefore = cmdContainer.getIndirectHeap(heap)->getUsed(); size_t size = 5000; void *ptr = cmdContainer.getHeapSpaceAllowGrow(heap, size); @@ -545,7 +566,7 @@ TEST_P(CommandContainerHeaps, givenCommandContainerWhenGetingMoreThanAvailableSi HeapType heap = GetParam(); CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.setDirtyStateForAllHeaps(false); auto usedSpaceBefore = cmdContainer.getIndirectHeap(heap)->getUsed(); @@ -573,12 +594,12 @@ TEST_P(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenHe auto device1 = std::unique_ptr(Device::create(executionEnvironment, 1u)); CommandContainer cmdContainer0; - cmdContainer0.initialize(device0.get(), nullptr); + cmdContainer0.initialize(device0.get(), nullptr, true); uint32_t heapRootDeviceIndex0 = cmdContainer0.getIndirectHeap(heap)->getGraphicsAllocation()->getRootDeviceIndex(); EXPECT_EQ(device0->getRootDeviceIndex(), heapRootDeviceIndex0); CommandContainer cmdContainer1; - cmdContainer1.initialize(device1.get(), nullptr); + cmdContainer1.initialize(device1.get(), nullptr, true); uint32_t heapRootDeviceIndex1 = cmdContainer1.getIndirectHeap(heap)->getGraphicsAllocation()->getRootDeviceIndex(); EXPECT_EQ(device1->getRootDeviceIndex(), heapRootDeviceIndex1); } @@ -594,13 +615,13 @@ TEST_F(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenCm auto device1 = std::unique_ptr(Device::create(executionEnvironment, 1u)); CommandContainer cmdContainer0; - cmdContainer0.initialize(device0.get(), nullptr); + cmdContainer0.initialize(device0.get(), nullptr, true); EXPECT_EQ(1u, cmdContainer0.getCmdBufferAllocations().size()); uint32_t cmdBufferAllocationIndex0 = cmdContainer0.getCmdBufferAllocations().front()->getRootDeviceIndex(); EXPECT_EQ(device0->getRootDeviceIndex(), cmdBufferAllocationIndex0); CommandContainer cmdContainer1; - cmdContainer1.initialize(device1.get(), nullptr); + cmdContainer1.initialize(device1.get(), nullptr, true); EXPECT_EQ(1u, cmdContainer1.getCmdBufferAllocations().size()); uint32_t cmdBufferAllocationIndex1 = cmdContainer1.getCmdBufferAllocations().front()->getRootDeviceIndex(); EXPECT_EQ(device1->getRootDeviceIndex(), cmdBufferAllocationIndex1); @@ -620,13 +641,13 @@ TEST_F(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenIn auto &hwHelper1 = HwHelper::get(device1->getHardwareInfo().platform.eRenderCoreFamily); CommandContainer cmdContainer0; - cmdContainer0.initialize(device0.get(), nullptr); + cmdContainer0.initialize(device0.get(), nullptr, true); bool useLocalMemory0 = !hwHelper0.useSystemMemoryPlacementForISA(device0->getHardwareInfo()); uint64_t baseAddressHeapDevice0 = device0.get()->getMemoryManager()->getInternalHeapBaseAddress(device0->getRootDeviceIndex(), useLocalMemory0); EXPECT_EQ(cmdContainer0.getInstructionHeapBaseAddress(), baseAddressHeapDevice0); CommandContainer cmdContainer1; - cmdContainer1.initialize(device1.get(), nullptr); + cmdContainer1.initialize(device1.get(), nullptr, true); bool useLocalMemory1 = !hwHelper1.useSystemMemoryPlacementForISA(device0->getHardwareInfo()); uint64_t baseAddressHeapDevice1 = device1.get()->getMemoryManager()->getInternalHeapBaseAddress(device1->getRootDeviceIndex(), useLocalMemory1); EXPECT_EQ(cmdContainer1.getInstructionHeapBaseAddress(), baseAddressHeapDevice1); @@ -637,7 +658,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenDestructionThenNonHeapAllo MockGraphicsAllocation alloc; size_t size = 0x1000; alloc.setSize(size); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->getDeallocationContainer().push_back(&alloc); cmdContainer.reset(); EXPECT_EQ(alloc.getUnderlyingBufferSize(), size); @@ -645,7 +666,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenDestructionThenNonHeapAllo TEST_F(CommandContainerTest, givenContainerAllocatesNextCommandBufferWhenResetingContainerThenExpectFirstCommandBufferAllocationIsReused) { auto cmdContainer = std::make_unique(); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); auto stream = cmdContainer->getCommandStream(); ASSERT_NE(nullptr, stream); @@ -690,21 +711,21 @@ class MyLinearStreamMock : public LinearStream { TEST_F(CommandContainerTest, givenCmdContainerWhenContainerIsInitializedThenStreamContainsContainerPtr) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EXPECT_EQ(reinterpret_cast(cmdContainer.getCommandStream())->cmdContainer, &cmdContainer); } TEST_F(CommandContainerTest, givenCmdContainerWhenContainerIsInitializedThenStreamSizeEqualAlignedTotalCmdBuffSizeDecreasedOfReservedSize) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); size_t alignedSize = alignUp(CommandContainer::totalCmdBufferSize, MemoryConstants::pageSize64k); EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - CommandContainer::cmdBufferReservedSize); } TEST_F(CommandContainerTest, givenCmdContainerWhenAlocatingNextCmdBufferThenStreamSizeEqualAlignedTotalCmdBuffSizeDecreasedOfReservedSize) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.allocateNextCommandBuffer(); size_t alignedSize = alignUp(CommandContainer::totalCmdBufferSize, MemoryConstants::pageSize64k); EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - CommandContainer::cmdBufferReservedSize); @@ -712,7 +733,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenAlocatingNextCmdBufferThenStre TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBufferCalledThenBBEndPlacedAtEndOfLinearStream) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto &hwInfo = pDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto ptr = cmdContainer.getCommandStream()->getSpace(0u); @@ -722,7 +743,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBuf TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBufferCalledThenNewCmdBufferAllocationCreated) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 1u); cmdContainer.closeAndAllocateNextCommandBuffer(); EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 2u); diff --git a/shared/test/unit_test/command_stream/linear_stream_tests.cpp b/shared/test/unit_test/command_stream/linear_stream_tests.cpp index 417ee1b144..d07aea904b 100644 --- a/shared/test/unit_test/command_stream/linear_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/linear_stream_tests.cpp @@ -134,7 +134,7 @@ TEST_F(LinearStreamTest, givenLinearStreamWithoutCmdContainerWhenOneByteLeftInSt using CommandContainerLinearStreamTest = Test; TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenOneByteLeftInStreamThenGetSpaceThrowAbort) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto stream = reinterpret_cast(cmdContainer.getCommandStream()); stream->sizeUsed = stream->getMaxAvailableSpace() - 1; EXPECT_THROW(stream->getSpace(1), std::exception); @@ -142,7 +142,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenOn TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenNewCmdBufferAllocated) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto &hwInfo = pDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto stream = reinterpret_cast(cmdContainer.getCommandStream()); @@ -155,7 +155,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenLinearStreamHasNewAllocation) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto &hwInfo = pDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto stream = reinterpret_cast(cmdContainer.getCommandStream()); @@ -169,7 +169,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenGetSpaceReturnPtrFromNewAllocation) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto &hwInfo = pDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto stream = reinterpret_cast(cmdContainer.getCommandStream()); @@ -182,7 +182,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsSpaceForCommandAndBBEndThenNewCmdBufferIsNotAllocated) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto &hwInfo = pDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto stream = reinterpret_cast(cmdContainer.getCommandStream()); @@ -195,7 +195,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenBBEndAddedAtEndOfStream) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto &hwInfo = pDevice->getHardwareInfo(); auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto stream = reinterpret_cast(cmdContainer.getCommandStream()); diff --git a/shared/test/unit_test/encoders/test_encode_command_buffer.cpp b/shared/test/unit_test/encoders/test_encode_command_buffer.cpp index c51eec2167..25105c8833 100644 --- a/shared/test/unit_test/encoders/test_encode_command_buffer.cpp +++ b/shared/test/unit_test/encoders/test_encode_command_buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -17,7 +17,7 @@ using EncodeBatchBufferStartOrEndTest = Test; HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBEndThenCommandIsAdded) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeBatchBufferStartOrEnd::programBatchBufferEnd(cmdContainer); GenCmdList commands; @@ -30,7 +30,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBEndTh HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartThenCommandIsAdded) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeBatchBufferStartOrEnd::programBatchBufferStart(cmdContainer.getCommandStream(), 0, true); GenCmdList commands; @@ -43,7 +43,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStart HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartWithSecondLevelParameterThenCommandIsProgrammedCorrectly) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeBatchBufferStartOrEnd::programBatchBufferStart(cmdContainer.getCommandStream(), 0, true); GenCmdList commands; @@ -60,7 +60,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStart HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartWithFirstLevelParameterThenCommandIsProgrammedCorrectly) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeBatchBufferStartOrEnd::programBatchBufferStart(cmdContainer.getCommandStream(), 0, false); GenCmdList commands; @@ -77,7 +77,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStart HWTEST_F(EncodeBatchBufferStartOrEndTest, givenGpuAddressWhenEncodeBBStartThenAddressIsProgrammedCorrectly) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); uint64_t gpuAddress = 12 * MemoryConstants::pageSize; EncodeBatchBufferStartOrEnd::programBatchBufferStart(cmdContainer.getCommandStream(), gpuAddress, false); @@ -98,7 +98,7 @@ using EncodeNoopTest = Test; HWTEST_F(EncodeNoopTest, WhenAligningLinearStreamToCacheLineSizeThenItIsAlignedCorrectly) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto commandStream = cmdContainer.getCommandStream(); EncodeNoop::alignToCacheLine(*commandStream); @@ -111,7 +111,7 @@ HWTEST_F(EncodeNoopTest, WhenAligningLinearStreamToCacheLineSizeThenItIsAlignedC HWTEST_F(EncodeNoopTest, WhenEmittingNoopsThenExpectCorrectNumberOfBytesNooped) { CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); auto commandStream = cmdContainer.getCommandStream(); size_t usedBefore = commandStream->getUsed(); diff --git a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp index 4f31626a33..3fa1648993 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp @@ -462,7 +462,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe { DebugManager.flags.ForceBtpPrefetchMode.set(-1); cmdContainer.reset(new MyMockCommandContainer()); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); bool requiresUncachedMocs = false; EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); @@ -493,7 +493,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe { DebugManager.flags.ForceBtpPrefetchMode.set(0); cmdContainer.reset(new MyMockCommandContainer()); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); bool requiresUncachedMocs = false; EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); @@ -520,7 +520,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe { DebugManager.flags.ForceBtpPrefetchMode.set(1); cmdContainer.reset(new MyMockCommandContainer()); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); bool requiresUncachedMocs = false; EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); @@ -1045,7 +1045,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindles DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); auto commandContainer = std::make_unique(); - commandContainer->initialize(pDevice, nullptr); + commandContainer->initialize(pDevice, nullptr, true); commandContainer->setDirtyStateForAllHeaps(false); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, @@ -1081,7 +1081,7 @@ HWTEST2_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindle DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); auto commandContainer = std::make_unique(); - commandContainer->initialize(pDevice, nullptr); + commandContainer->initialize(pDevice, nullptr, true); commandContainer->setDirtyStateForAllHeaps(false); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, @@ -1120,7 +1120,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindfulKernelWhenBindles DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); auto commandContainer = std::make_unique(); - commandContainer->initialize(pDevice, nullptr); + commandContainer->initialize(pDevice, nullptr, true); commandContainer->setDirtyStateForAllHeaps(false); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, @@ -1156,7 +1156,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessModeEnabledWhenD DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); auto commandContainer = std::make_unique(); - commandContainer->initialize(pDevice, nullptr); + commandContainer->initialize(pDevice, nullptr, true); commandContainer->setDirtyStateForAllHeaps(false); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, @@ -1194,7 +1194,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchin DebugManagerStateRestore restorer; DebugManager.flags.UseBindlessMode.set(1); auto cmdContainer = std::make_unique(); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->setDirtyStateForAllHeaps(false); using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; @@ -1241,7 +1241,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenBindlessModeDisabledelWithSampler DebugManagerStateRestore restorer; DebugManager.flags.UseBindlessMode.set(0); auto cmdContainer = std::make_unique(); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; uint32_t numSamplers = 1; diff --git a/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp b/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp index 354261d824..c882d97748 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp @@ -364,7 +364,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD { DebugManager.flags.ForceBtpPrefetchMode.set(-1); cmdContainer.reset(new MyMockCommandContainer()); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); bool requiresUncachedMocs = false; EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); @@ -395,7 +395,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD { DebugManager.flags.ForceBtpPrefetchMode.set(0); cmdContainer.reset(new MyMockCommandContainer()); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); bool requiresUncachedMocs = false; EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); @@ -417,7 +417,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD { DebugManager.flags.ForceBtpPrefetchMode.set(1); cmdContainer.reset(new MyMockCommandContainer()); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); bool requiresUncachedMocs = false; EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); diff --git a/shared/test/unit_test/encoders/test_encode_math.cpp b/shared/test/unit_test/encoders/test_encode_math.cpp index 0fca66b0c4..3e018221d4 100644 --- a/shared/test/unit_test/encoders/test_encode_math.cpp +++ b/shared/test/unit_test/encoders/test_encode_math.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -146,7 +146,7 @@ HWTEST_F(CommandEncoderMathTest, WhenReservingCommandThenBitfieldSetCorrectly) { GenCmdList commands; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeMath::commandReserve(cmdContainer); @@ -176,7 +176,7 @@ HWTEST_F(CommandEncoderMathTest, givenOffsetAndValueWhenEncodeBitwiseAndValIsCal GenCmdList commands; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); constexpr uint32_t regOffset = 0x2000u; constexpr uint32_t immVal = 0xbaau; constexpr uint64_t dstAddress = 0xDEADCAF0u; @@ -222,7 +222,7 @@ HWTEST_F(CommandEncoderMathTest, WhenSettingGroupSizeIndirectThenCommandsAreCorr using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); CrossThreadDataOffset offsets[3] = {0, sizeof(uint32_t), 2 * sizeof(uint32_t)}; uint32_t crossThreadAdress[3] = {}; @@ -248,7 +248,7 @@ HWTEST_F(CommandEncoderMathTest, WhenSettingGroupCountIndirectThenCommandsAreCor using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); CrossThreadDataOffset offsets[3] = {0, sizeof(uint32_t), 2 * sizeof(uint32_t)}; uint32_t crossThreadAdress[3] = {}; diff --git a/shared/test/unit_test/encoders/test_encode_math_xehp_and_later.cpp b/shared/test/unit_test/encoders/test_encode_math_xehp_and_later.cpp index 7087ca615b..d9a78d6caf 100644 --- a/shared/test/unit_test/encoders/test_encode_math_xehp_and_later.cpp +++ b/shared/test/unit_test/encoders/test_encode_math_xehp_and_later.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -23,7 +23,7 @@ HWTEST2_F(XeHPAndLaterCommandEncoderMathTest, WhenAppendsAGreaterThanThenPredica using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; CommandContainer cmdContainer; - cmdContainer.initialize(pDevice, nullptr); + cmdContainer.initialize(pDevice, nullptr, true); EncodeMathMMIO::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); diff --git a/shared/test/unit_test/encoders/test_encode_set_mmio.cpp b/shared/test/unit_test/encoders/test_encode_set_mmio.cpp index ca59c50bbc..d65de669bc 100644 --- a/shared/test/unit_test/encoders/test_encode_set_mmio.cpp +++ b/shared/test/unit_test/encoders/test_encode_set_mmio.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -17,7 +17,7 @@ class CommandSetMMIOFixture : public DeviceFixture { void SetUp() { DeviceFixture::SetUp(); cmdContainer = std::make_unique(); - cmdContainer->initialize(pDevice, nullptr); + cmdContainer->initialize(pDevice, nullptr, true); } void TearDown() { cmdContainer.reset();