From 767f27a48357f038ef8e2a6d090066f914b17552 Mon Sep 17 00:00:00 2001 From: "Zdanowicz, Zbigniew" Date: Thu, 3 Jan 2019 17:52:08 +0100 Subject: [PATCH] Add calculation of default SSH size in ULTs Change-Id: I682f7cc671ab18de7a9976e0034842df0f6134bf --- .../command_queue/command_queue_hw_tests.cpp | 11 +++++++--- .../command_queue/command_queue_tests.cpp | 8 ++++--- .../command_stream_receiver_hw_tests.cpp | 6 ++--- .../parent_kernel_dispatch_tests.cpp | 22 +++++++++++-------- unit_tests/fixtures/device_fixture.cpp | 4 ++-- unit_tests/helpers/unit_test_helper.h | 4 ++++ unit_tests/helpers/unit_test_helper.inl | 10 +++++++++ 7 files changed, 45 insertions(+), 20 deletions(-) diff --git a/unit_tests/command_queue/command_queue_hw_tests.cpp b/unit_tests/command_queue/command_queue_hw_tests.cpp index 0012c55f3e..3e0ee15ff3 100644 --- a/unit_tests/command_queue/command_queue_hw_tests.cpp +++ b/unit_tests/command_queue/command_queue_hw_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,7 @@ #include "unit_tests/fixtures/context_fixture.h" #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/helpers/debug_manager_state_restore.h" +#include "unit_tests/helpers/unit_test_helper.h" #include "unit_tests/mocks/mock_buffer.h" #include "unit_tests/mocks/mock_command_queue.h" #include "unit_tests/mocks/mock_csr.h" @@ -381,9 +382,11 @@ HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWhenBlockedCommandIsBeingSubm auto &dsh = pCmdQ->getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 4096u); auto &ssh = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 4096u); + uint32_t defaultSshUse = UnitTestHelper::getDefaultSshUsage(); + EXPECT_EQ(0u, ioh.getUsed()); EXPECT_EQ(0u, dsh.getUsed()); - EXPECT_EQ(0u, ssh.getUsed()); + EXPECT_EQ(defaultSshUse, ssh.getUsed()); } HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWithUsedHeapsWhenBlockedCommandIsBeingSubmittedThenQueueHeapsAreNotUsed) { @@ -409,9 +412,11 @@ HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWithUsedHeapsWhenBlockedComma pCmdQ->enqueueKernel(mockKernel, 1, &offset, &size, &size, 1, &blockedEvent, nullptr); userEvent.setStatus(CL_COMPLETE); + uint32_t sshSpaceUse = spaceToUse + UnitTestHelper::getDefaultSshUsage(); + EXPECT_EQ(spaceToUse, ioh.getUsed()); EXPECT_EQ(spaceToUse, dsh.getUsed()); - EXPECT_EQ(spaceToUse, ssh.getUsed()); + EXPECT_EQ(sshSpaceUse, ssh.getUsed()); } HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWhichHasSomeUnusedHeapsWhenBlockedCommandIsBeingSubmittedThenThoseHeapsAreBeingUsed) { diff --git a/unit_tests/command_queue/command_queue_tests.cpp b/unit_tests/command_queue/command_queue_tests.cpp index 1edec7ba35..252bb82629 100644 --- a/unit_tests/command_queue/command_queue_tests.cpp +++ b/unit_tests/command_queue/command_queue_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -22,6 +22,7 @@ #include "unit_tests/fixtures/image_fixture.h" #include "unit_tests/fixtures/memory_management_fixture.h" #include "unit_tests/fixtures/buffer_fixture.h" +#include "unit_tests/helpers/unit_test_helper.h" #include "unit_tests/libult/ult_command_stream_receiver.h" #include "unit_tests/mocks/mock_memory_manager.h" #include "unit_tests/mocks/mock_command_queue.h" @@ -419,13 +420,14 @@ TEST_P(CommandQueueIndirectHeapTest, givenIndirectObjectHeapWhenItIsQueriedForIn } } -TEST_P(CommandQueueIndirectHeapTest, IndirectHeapContainsAtLeast64KB) { +HWTEST_P(CommandQueueIndirectHeapTest, IndirectHeapContainsAtLeast64KB) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; CommandQueue cmdQ(context.get(), pDevice, props); auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), sizeof(uint32_t)); if (this->GetParam() == IndirectHeap::SURFACE_STATE) { - EXPECT_EQ(cmdQ.getCommandStreamReceiver().defaultSshSize - MemoryConstants::pageSize, indirectHeap.getAvailableSpace()); + size_t expectedSshUse = cmdQ.getCommandStreamReceiver().defaultSshSize - MemoryConstants::pageSize - UnitTestHelper::getDefaultSshUsage(); + EXPECT_EQ(expectedSshUse, indirectHeap.getAvailableSpace()); } else { EXPECT_EQ(64 * KB, indirectHeap.getAvailableSpace()); } diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index 299da2fc71..e9c40cae94 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,6 +27,7 @@ #include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h" #include "unit_tests/helpers/hw_parse.h" #include "unit_tests/helpers/debug_manager_state_restore.h" +#include "unit_tests/helpers/unit_test_helper.h" #include "unit_tests/mocks/mock_buffer.h" #include "unit_tests/mocks/mock_command_queue.h" #include "unit_tests/mocks/mock_context.h" @@ -247,6 +248,5 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsRequiredThenCorrectAddre uint64_t expectedScratchAddress = 0xAAABBBCCCDDD000ull; scratchController->getScratchSpaceAllocation()->setCpuPtrAndGpuAddress(scratchController->getScratchSpaceAllocation()->getUnderlyingBuffer(), expectedScratchAddress); - - EXPECT_EQ(expectedScratchAddress - MemoryConstants::pageSize, scratchController->calculateNewGSH()); + EXPECT_TRUE(UnitTestHelper::evaluateGshAddressForScratchSpace((expectedScratchAddress - MemoryConstants::pageSize), scratchController->calculateNewGSH())); } \ No newline at end of file diff --git a/unit_tests/execution_model/parent_kernel_dispatch_tests.cpp b/unit_tests/execution_model/parent_kernel_dispatch_tests.cpp index e2bd9069e1..dd18438fc1 100644 --- a/unit_tests/execution_model/parent_kernel_dispatch_tests.cpp +++ b/unit_tests/execution_model/parent_kernel_dispatch_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,6 +12,7 @@ #include "runtime/sampler/sampler.h" #include "unit_tests/fixtures/execution_model_fixture.h" #include "unit_tests/helpers/hw_parse.h" +#include "unit_tests/helpers/unit_test_helper.h" #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_program.h" #include "unit_tests/mocks/mock_context.h" @@ -177,12 +178,14 @@ HWTEST_P(ParentKernelDispatchTest, givenParentKernelWhenQueueIsBlockedThenSSHSiz true); ASSERT_NE(nullptr, blockedCommandsData); - size_t minRequiredSize = KernelCommandsHelper::getTotalSizeRequiredSSH(multiDispatchInfo); + size_t minRequiredSize = KernelCommandsHelper::getTotalSizeRequiredSSH(multiDispatchInfo) + UnitTestHelper::getDefaultSshUsage(); size_t minRequiredSizeForEM = KernelCommandsHelper::template getSizeRequiredForExecutionModel(*pKernel); size_t sshUsed = blockedCommandsData->ssh->getUsed(); - size_t expectedSizeSSH = pKernel->getNumberOfBindingTableStates() * sizeof(RENDER_SURFACE_STATE) + pKernel->getKernelInfo().patchInfo.bindingTableState->Count * sizeof(BINDING_TABLE_STATE); + size_t expectedSizeSSH = pKernel->getNumberOfBindingTableStates() * sizeof(RENDER_SURFACE_STATE) + + pKernel->getKernelInfo().patchInfo.bindingTableState->Count * sizeof(BINDING_TABLE_STATE) + + UnitTestHelper::getDefaultSshUsage(); if ((pKernel->requiresSshForBuffers()) || (pKernel->getKernelInfo().patchInfo.imageMemObjKernelArgs.size() > 0)) { EXPECT_EQ(expectedSizeSSH, sshUsed); @@ -343,9 +346,10 @@ HWTEST_F(MockParentKernelDispatch, GivenUsedSSHHeapWhenParentKernelIsDispatchedT auto &ssh = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 100); - ssh.getSpace(20); - - EXPECT_EQ(20u, ssh.getUsed()); + uint32_t testSshUse = 20u; + uint32_t expectedSshUse = testSshUse + UnitTestHelper::getDefaultSshUsage(); + ssh.getSpace(testSshUse); + EXPECT_EQ(expectedSshUse, ssh.getUsed()); // Assuming parent is not using SSH, this is becuase storing allocation on reuse list and allocating // new one by obtaining from reuse list returns the same allocation and heap buffer does not differ @@ -368,7 +372,7 @@ HWTEST_F(MockParentKernelDispatch, GivenUsedSSHHeapWhenParentKernelIsDispatchedT pDevice->getPreemptionMode(), false); - EXPECT_EQ(0u, ssh.getUsed()); + EXPECT_EQ(UnitTestHelper::getDefaultSshUsage(), ssh.getUsed()); delete mockParentKernel; } @@ -384,8 +388,8 @@ HWTEST_F(MockParentKernelDispatch, GivenNotUsedSSHHeapWhenParentKernelIsDispatch const size_t workItems[3] = {1, 1, 1}; auto &ssh = pCmdQ->getIndirectHeap(IndirectHeap::SURFACE_STATE, 100); - - EXPECT_EQ(0u, ssh.getUsed()); + auto defaultSshUsage = UnitTestHelper::getDefaultSshUsage(); + EXPECT_EQ(defaultSshUsage, ssh.getUsed()); auto *bufferMemory = ssh.getCpuBase(); diff --git a/unit_tests/fixtures/device_fixture.cpp b/unit_tests/fixtures/device_fixture.cpp index a5e4db403c..c74a5f4d65 100644 --- a/unit_tests/fixtures/device_fixture.cpp +++ b/unit_tests/fixtures/device_fixture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -34,4 +34,4 @@ MockDevice *DeviceFixture::createWithUsDeviceId(unsigned short usDeviceId) { hwInfoHelper.pPlatform = &platformHelper; return MockDevice::createWithNewExecutionEnvironment(&hwInfoHelper); } -} // namespace OCLRT \ No newline at end of file +} // namespace OCLRT diff --git a/unit_tests/helpers/unit_test_helper.h b/unit_tests/helpers/unit_test_helper.h index 77c3aedf46..3cab0dbcfb 100644 --- a/unit_tests/helpers/unit_test_helper.h +++ b/unit_tests/helpers/unit_test_helper.h @@ -23,5 +23,9 @@ struct UnitTestHelper { static bool isTimestampPacketWriteSupported(); static bool isExpectMemoryNotEqualSupported(); + + static uint32_t getDefaultSshUsage(); + + static bool evaluateGshAddressForScratchSpace(uint64_t usedScratchGpuAddress, uint64_t retrievedGshAddress); }; } // namespace OCLRT diff --git a/unit_tests/helpers/unit_test_helper.inl b/unit_tests/helpers/unit_test_helper.inl index aa7c3dbaae..1e49181444 100644 --- a/unit_tests/helpers/unit_test_helper.inl +++ b/unit_tests/helpers/unit_test_helper.inl @@ -34,4 +34,14 @@ template bool UnitTestHelper::isExpectMemoryNotEqualSupported() { return false; } + +template +uint32_t UnitTestHelper::getDefaultSshUsage() { + return 0; +} + +template +bool UnitTestHelper::evaluateGshAddressForScratchSpace(uint64_t usedScratchGpuAddress, uint64_t retrievedGshAddress) { + return usedScratchGpuAddress == retrievedGshAddress; +} } // namespace OCLRT