From 4caa10f76e1ee99250d360c6977a9735a9d6b8ff Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Mon, 20 Sep 2021 14:29:22 +0000 Subject: [PATCH] Don't use Platform class in shared tests Signed-off-by: Mateusz Jablonski --- .../enqueue_map_buffer_tests.cpp | 4 +- .../enqueue_kernel_gl_tests_windows.cpp | 2 +- .../multiple_map_buffer_tests.cpp | 4 +- .../gen12lp/kernel_tests_gen12lp.inl | 4 +- .../unit_test/helpers/hw_helper_tests.cpp | 2 +- opencl/test/unit_test/main.cpp | 1 + .../test/unit_test/mem_obj/buffer_tests.cpp | 17 ++-- .../mem_obj/buffer_tests_xehp_and_later.cpp | 7 +- .../mem_obj/image_tests_xehp_and_later.cpp | 2 +- ...nager_allocate_in_preferred_pool_tests.cpp | 5 +- .../memory_manager/memory_manager_tests.cpp | 3 +- opencl/test/unit_test/mocks/mock_gmm.h | 3 +- .../unit_test/mocks/mock_memory_manager.h | 1 + .../linux/drm_command_stream_tests_1.cpp | 6 +- .../windows/file_logger_win_tests.cpp | 6 +- .../windows/mock_wddm_allocation.h | 10 +- .../os_interface/windows/wddm20_tests.cpp | 20 ++-- .../windows/wddm_kmdaf_listener_tests.cpp | 4 +- .../windows/wddm_memory_manager_tests.cpp | 26 +++-- .../wddm_residency_controller_tests.cpp | 95 +++++++++++++------ .../windows/wddm_residency_handler_tests.cpp | 52 +++++----- .../sharings/gl/windows/gl_sharing_tests.cpp | 10 +- .../unified/unified_sharing_fixtures.h | 5 +- .../copy_engine_tests_xe_hp_core.cpp | 2 +- .../gen11/image_surface_state_tests_gen11.cpp | 12 +-- .../image_surface_state_tests_gen12lp.cpp | 16 ++-- .../gen8/image_surface_state_tests_gen8.cpp | 8 +- .../gen9/image_surface_state_tests_gen9.cpp | 12 +-- .../blit_commands_helper_tests_gen12lp.cpp | 6 +- ...st_blit_commands_helper_xehp_and_later.cpp | 30 +++--- .../image_surface_state_tests_xe_hp_core.cpp | 16 ++-- shared/test/unit_test/CMakeLists.txt | 2 - .../image/image_surface_state_fixture.h | 3 +- .../image/image_surface_state_tests.cpp | 14 +-- shared/test/unit_test/main.cpp | 8 +- .../aub_memory_operations_handler_tests.cpp | 5 +- .../unit_test/preemption/preemption_tests.cpp | 3 +- 37 files changed, 236 insertions(+), 190 deletions(-) diff --git a/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp index 0522c32afd..5af6dae8ff 100644 --- a/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp @@ -378,7 +378,7 @@ TEST_F(EnqueueMapBufferTest, givenNonReadOnlyBufferWhenMappedOnGpuThenSetValidEv buffer->setSharingHandler(new SharingHandler()); auto gfxAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex()); for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) { - gfxAllocation->setGmm(new MockGmm(), handleId); + gfxAllocation->setGmm(new MockGmm(pDevice->getGmmClientContext()), handleId); } buffer->forceDisallowCPUCopy = true; @@ -426,7 +426,7 @@ TEST_F(EnqueueMapBufferTest, givenReadOnlyBufferWhenMappedOnGpuThenSetValidEvent buffer->setSharingHandler(new SharingHandler()); auto gfxAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex()); for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) { - gfxAllocation->setGmm(new MockGmm(), handleId); + gfxAllocation->setGmm(new MockGmm(pDevice->getGmmClientContext()), handleId); } EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_NE(nullptr, buffer.get()); diff --git a/opencl/test/unit_test/command_queue/gl/windows/enqueue_kernel_gl_tests_windows.cpp b/opencl/test/unit_test/command_queue/gl/windows/enqueue_kernel_gl_tests_windows.cpp index f41f50aa64..f76b5eb028 100644 --- a/opencl/test/unit_test/command_queue/gl/windows/enqueue_kernel_gl_tests_windows.cpp +++ b/opencl/test/unit_test/command_queue/gl/windows/enqueue_kernel_gl_tests_windows.cpp @@ -30,7 +30,7 @@ TEST_F(EnqueueKernelTest, givenKernelWithSharedObjArgsWhenEnqueueIsCalledThenRes auto nonSharedBuffer = new MockBuffer; MockGlSharing glSharing; - MockGmm mockGmm; + MockGmm mockGmm(pDevice->getGmmClientContext()); glSharing.uploadDataToBufferInfo(1, 0, mockGmm.gmmResourceInfo->peekGmmResourceInfo()); pContext->setSharingFunctions(glSharing.sharingFunctions.release()); auto retVal = CL_SUCCESS; diff --git a/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp b/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp index 4be7f9dc5c..ba503c1bf3 100644 --- a/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/multiple_map_buffer_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -100,7 +100,7 @@ struct MultipleMapBufferTest : public ClDeviceFixture, public ::testing::Test { buffer->setSharingHandler(new SharingHandler()); auto gfxAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex()); for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) { - gfxAllocation->setGmm(new MockGmm(), handleId); + gfxAllocation->setGmm(new MockGmm(pDevice->getGmmClientContext()), handleId); } } return std::unique_ptr>(buffer); diff --git a/opencl/test/unit_test/gen12lp/kernel_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/kernel_tests_gen12lp.inl index 5277596c17..7d94963841 100644 --- a/opencl/test/unit_test/gen12lp/kernel_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/kernel_tests_gen12lp.inl @@ -36,7 +36,7 @@ GEN12LPTEST_F(Gen12LpKernelTest, GivenKernelWhenAtLeastOneArgIsMediaCompressedTh MockBuffer buffer; auto allocation = buffer.getGraphicsAllocation(pClDevice->getRootDeviceIndex()); - MockGmm gmm1; + MockGmm gmm1(pDevice->getGmmClientContext()); allocation->setGmm(&gmm1, 0); cl_mem clMem = &buffer; @@ -48,7 +48,7 @@ GEN12LPTEST_F(Gen12LpKernelTest, GivenKernelWhenAtLeastOneArgIsMediaCompressedTh MockBuffer bufferMediaCompressed; bufferMediaCompressed.setSharingHandler(new SharingHandler()); allocation = bufferMediaCompressed.getGraphicsAllocation(pClDevice->getRootDeviceIndex()); - MockGmm gmm2; + MockGmm gmm2(pDevice->getGmmClientContext()); allocation->setGmm(&gmm2, 0); allocation->getGmm(0)->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = 1; cl_mem clMem2 = &bufferMediaCompressed; diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index ab702fc779..b7c8628c5e 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -1287,7 +1287,7 @@ TEST_F(HwHelperTest, givenGenHelperWhenKernelArgumentIsNotPureStatefulThenRequir HWTEST_F(HwHelperTest, whenSetRenderCompressedFlagThenProperFlagSet) { auto &hwHelper = HwHelper::get(renderCoreFamily); - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); gmm->resourceParams.Flags.Info.RenderCompressed = 0; hwHelper.applyRenderCompressionFlag(*gmm, 1); diff --git a/opencl/test/unit_test/main.cpp b/opencl/test/unit_test/main.cpp index 05159aabea..cad8dcc7fe 100644 --- a/opencl/test/unit_test/main.cpp +++ b/opencl/test/unit_test/main.cpp @@ -22,6 +22,7 @@ #include "shared/test/unit_test/tests_configuration.h" #include "opencl/source/os_interface/ocl_reg_path.h" +#include "opencl/source/platform/platform.h" #include "opencl/test/unit_test/helpers/kernel_binary_helper.h" #include "opencl/test/unit_test/mocks/mock_gmm.h" #include "opencl/test/unit_test/mocks/mock_program.h" diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index d261f20de6..55bbf8c008 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -537,7 +537,7 @@ TEST(Buffer, givenZeroFlagsNoSharedContextAndRenderCompressedBuffersDisabledWhen } TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInSystemMemoryPoolThenAllocationIsWrittenByEnqueueWriteBuffer) { - ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u); auto *memoryManager = new ::testing::NiceMock(*executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); @@ -565,11 +565,13 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS } struct RenderCompressedBuffersTests : public ::testing::Test { void SetUp() override { - ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u); for (auto &rootDeviceEnvironment : executionEnvironment->rootDeviceEnvironments) { rootDeviceEnvironment->initGmm(); } - executionEnvironment->prepareRootDeviceEnvironments(1u); + SetUp(executionEnvironment); + } + void SetUp(ExecutionEnvironment *executionEnvironment) { hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); device = std::make_unique(MockDevice::create(executionEnvironment, 0u)); context = std::make_unique(device.get(), true); @@ -699,14 +701,14 @@ TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThen struct RenderCompressedBuffersSvmTests : public RenderCompressedBuffersTests { void SetUp() override { - ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u); for (auto &rootDeviceEnvironment : executionEnvironment->rootDeviceEnvironments) { rootDeviceEnvironment->initGmm(); } executionEnvironment->prepareRootDeviceEnvironments(1u); hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo(); hwInfo->capabilityTable.gpuAddressSpace = MemoryConstants::max48BitAddress; - RenderCompressedBuffersTests::SetUp(); + RenderCompressedBuffersTests::SetUp(executionEnvironment); } }; @@ -725,7 +727,7 @@ TEST_F(RenderCompressedBuffersSvmTests, givenSvmAllocationWhenCreatingBufferThen struct RenderCompressedBuffersCopyHostMemoryTests : public RenderCompressedBuffersTests { void SetUp() override { RenderCompressedBuffersTests::SetUp(); - device->injectMemoryManager(new MockMemoryManager(true, false, *platform()->peekExecutionEnvironment())); + device->injectMemoryManager(new MockMemoryManager(true, false, *device->getExecutionEnvironment())); context->memoryManager = device->getMemoryManager(); mockCmdQ = new MockCommandQueue(); context->setSpecialQueue(mockCmdQ, device->getRootDeviceIndex()); @@ -956,7 +958,6 @@ struct ValidHostPtr void TearDown() override { delete buffer; BaseClass::TearDown(); - platformsImpl->clear(); MemoryManagementFixture::TearDown(); } @@ -1838,7 +1839,7 @@ HWTEST_F(BufferUnmapTest, givenBufferWithSharingHandlerWhenUnmappingThenUseNonBl auto gfxAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex()); for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) { - gfxAllocation->setGmm(new MockGmm(), handleId); + gfxAllocation->setGmm(new MockGmm(pDevice->getGmmClientContext()), handleId); } auto mappedPtr = clEnqueueMapBuffer(&cmdQ, buffer.get(), CL_TRUE, CL_MAP_WRITE, 0, 1, 0, nullptr, nullptr, &retVal); diff --git a/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp index b0b28d4847..5dcc5f59a3 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp @@ -390,8 +390,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterBufferTests, givenBufferAllocationInDev retVal)); EXPECT_EQ(CL_SUCCESS, retVal); - auto allocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex()); - auto gmm = new MockGmm(); + auto &device = context.getDevice(0)->getDevice(); + auto allocation = buffer->getGraphicsAllocation(device.getRootDeviceIndex()); + auto gmm = new MockGmm(device.getGmmClientContext()); gmm->isCompressionEnabled = true; allocation->setDefaultGmm(gmm); @@ -399,7 +400,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterBufferTests, givenBufferAllocationInDev RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState; - buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false); + buffer->setArgStateful(&surfaceState, false, false, false, false, device, false, false); EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, surfaceState.getCoherencyType()); EXPECT_TRUE(EncodeSurfaceState::isAuxModeEnabled(&surfaceState, allocation->getDefaultGmm())); diff --git a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp index 23712dde81..6a6785efda 100644 --- a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp @@ -574,7 +574,7 @@ HWTEST2_F(XeHPAndLaterImageTests, givenRenderCompressionWhenAppendingNewAllocati gmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = true; gmm->isCompressionEnabled = true; - auto mcsGmm = new MockGmm(); + auto mcsGmm = new MockGmm(context.getDevice(0)->getGmmClientContext()); mcsGmm->isCompressionEnabled = true; mcsGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = true; mcsGmm->gmmResourceInfo->getResourceFlags()->Gpu.UnifiedAuxSurface = true; diff --git a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp index 8ac0e152d6..ed592e804c 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp @@ -1019,10 +1019,7 @@ TEST(MemoryManagerTest, givenEnabledLocalMemoryWhenAllocatingSharedResourceCopyT localPlatformDevice = *defaultHwInfo; localPlatformDevice.featureTable.ftrLocalMemory = true; - platformsImpl->clear(); - auto executionEnvironment = constructPlatform()->peekExecutionEnvironment(); - executionEnvironment->prepareRootDeviceEnvironments(1u); - executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&localPlatformDevice); + auto executionEnvironment = std::unique_ptr(MockDevice::prepareExecutionEnvironment(&localPlatformDevice, 0u)); executionEnvironment->rootDeviceEnvironments[0]->initGmm(); MockMemoryManager memoryManager(false, true, *executionEnvironment); diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index 1895b8531f..96cfaf75aa 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -2761,11 +2761,12 @@ HWTEST_F(PageTableManagerTest, givenMemoryManagerThatSupportsPageTableManagerWhe executionEnvironment->prepareRootDeviceEnvironments(2); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get()); + executionEnvironment->rootDeviceEnvironments[i]->initGmm(); } auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); MockGraphicsAllocation allocation(1u, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull); - MockGmm gmm; + MockGmm gmm(executionEnvironment->rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmClientContext()); allocation.setDefaultGmm(&gmm); bool mapped = memoryManager->mapAuxGpuVA(&allocation); auto hwInfo = executionEnvironment->rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getHardwareInfo(); diff --git a/opencl/test/unit_test/mocks/mock_gmm.h b/opencl/test/unit_test/mocks/mock_gmm.h index 1afadd1993..291ab339dc 100644 --- a/opencl/test/unit_test/mocks/mock_gmm.h +++ b/opencl/test/unit_test/mocks/mock_gmm.h @@ -14,7 +14,6 @@ #include "opencl/source/helpers/surface_formats.h" #include "opencl/source/mem_obj/image.h" #include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h" -#include "opencl/test/unit_test/mocks/mock_platform.h" namespace NEO { namespace MockGmmParams { @@ -26,7 +25,7 @@ class MockGmm : public Gmm { using Gmm::Gmm; using Gmm::setupImageResourceParams; - MockGmm() : Gmm(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, 0, false){}; + MockGmm(GmmClientContext *clientContext) : Gmm(clientContext, nullptr, 1, 0, false){}; static std::unique_ptr queryImgParams(GmmClientContext *clientContext, ImageInfo &imgInfo) { return std::unique_ptr(new Gmm(clientContext, imgInfo, {})); diff --git a/opencl/test/unit_test/mocks/mock_memory_manager.h b/opencl/test/unit_test/mocks/mock_memory_manager.h index cd56131d6a..7f66ebd34c 100644 --- a/opencl/test/unit_test/mocks/mock_memory_manager.h +++ b/opencl/test/unit_test/mocks/mock_memory_manager.h @@ -65,6 +65,7 @@ class MockMemoryManager : public MemoryManagerCreate { MockMemoryManager() : MockMemoryManager(*(new MockExecutionEnvironment(defaultHwInfo.get()))) { mockExecutionEnvironment.reset(static_cast(&executionEnvironment)); + mockExecutionEnvironment->initGmm(); }; MockMemoryManager(bool enable64pages, bool enableLocalMemory) : MemoryManagerCreate(enable64pages, enableLocalMemory, *(new MockExecutionEnvironment(defaultHwInfo.get()))) { mockExecutionEnvironment.reset(static_cast(&executionEnvironment)); diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp index 1d01e4f4d5..68ce921697 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp @@ -894,7 +894,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenLocalMemoryEnabledWhenCreatingDrmC HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPageTableManagerAndMapTrueWhenUpdateAuxTableIsCalledThenItReturnsTrue) { auto mockMngr = new MockGmmPageTableMngr(); executionEnvironment.rootDeviceEnvironments[0]->pageTableManager.reset(mockMngr); - auto gmm = std::make_unique(); + executionEnvironment.rootDeviceEnvironments[0]->initGmm(); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext()); GMM_DDI_UPDATEAUXTABLE ddiUpdateAuxTable = {}; EXPECT_CALL(*mockMngr, updateAuxTable(::testing::_)).Times(1).WillOnce(::testing::Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {ddiUpdateAuxTable = *arg; return GMM_SUCCESS; })); auto result = executionEnvironment.rootDeviceEnvironments[0]->pageTableManager->updateAuxTable(0, gmm.get(), true); @@ -909,7 +910,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPageTableManagerAndMapTrueWhenUpda HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenPageTableManagerAndMapFalseWhenUpdateAuxTableIsCalledThenItReturnsTrue) { auto mockMngr = new MockGmmPageTableMngr(); executionEnvironment.rootDeviceEnvironments[0]->pageTableManager.reset(mockMngr); - auto gmm = std::make_unique(); + executionEnvironment.rootDeviceEnvironments[0]->initGmm(); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext()); GMM_DDI_UPDATEAUXTABLE ddiUpdateAuxTable = {}; EXPECT_CALL(*mockMngr, updateAuxTable(::testing::_)).Times(1).WillOnce(::testing::Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {ddiUpdateAuxTable = *arg; return GMM_SUCCESS; })); auto result = executionEnvironment.rootDeviceEnvironments[0]->pageTableManager->updateAuxTable(0, gmm.get(), false); diff --git a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp index c3b4151b00..0ee7db0f79 100644 --- a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp @@ -28,7 +28,7 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { bool logFileCreated = fileExists(fileLogger.getLogFileName()); EXPECT_FALSE(logFileCreated); - MockWddmAllocation allocation; + MockWddmAllocation allocation(getGmmClientContext()); allocation.handle = 4; allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; @@ -72,7 +72,9 @@ TEST_F(FileLoggerTests, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIs bool logFileCreated = fileExists(fileLogger.getLogFileName()); EXPECT_FALSE(logFileCreated); - MockWddmAllocation allocation; + auto executionEnvironment = std::unique_ptr(MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u)); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + MockWddmAllocation allocation(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext()); allocation.handle = 4; allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; diff --git a/opencl/test/unit_test/os_interface/windows/mock_wddm_allocation.h b/opencl/test/unit_test/os_interface/windows/mock_wddm_allocation.h index 7e4d76d1fb..0aaa805830 100644 --- a/opencl/test/unit_test/os_interface/windows/mock_wddm_allocation.h +++ b/opencl/test/unit_test/os_interface/windows/mock_wddm_allocation.h @@ -15,12 +15,12 @@ namespace NEO { class MockWddmAllocation : public WddmAllocation { public: - MockWddmAllocation() : MockWddmAllocation(EngineLimits::maxHandleCount) {} - MockWddmAllocation(uint32_t numGmms) : WddmAllocation(0, numGmms, GraphicsAllocation::AllocationType::UNKNOWN, - nullptr, 0, nullptr, MemoryPool::MemoryNull, 0u, 3u), - gpuPtr(gpuAddress), handle(handles[0]) { + MockWddmAllocation(GmmClientContext *gmmClientContext) : MockWddmAllocation(gmmClientContext, EngineLimits::maxHandleCount) {} + MockWddmAllocation(GmmClientContext *gmmClientContext, uint32_t numGmms) : WddmAllocation(0, numGmms, GraphicsAllocation::AllocationType::UNKNOWN, + nullptr, 0, nullptr, MemoryPool::MemoryNull, 0u, 3u), + gpuPtr(gpuAddress), handle(handles[0]) { for (uint32_t i = 0; i < numGmms; i++) { - setGmm(new MockGmm, i); + setGmm(new MockGmm(gmmClientContext), i); setHandle(ALLOCATION_HANDLE, i); } } diff --git a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp index abf78da47b..011df82b91 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp @@ -707,7 +707,7 @@ TEST_F(Wddm20Tests, WhenMakingNonResidentThenEvictIsCalled) { } TEST_F(Wddm20Tests, givenDestroyAllocationWhenItIsCalledThenAllocationIsPassedToDestroyAllocation) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.getResidencyData().updateCompletionData(10, osContext->getContextId()); allocation.handle = ALLOCATION_HANDLE; @@ -733,7 +733,7 @@ TEST_F(Wddm20Tests, givenDestroyAllocationWhenItIsCalledThenAllocationIsPassedTo } TEST_F(Wddm20Tests, WhenLastFenceLessEqualThanMonitoredThenWaitFromCpuIsNotCalled) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.getResidencyData().updateCompletionData(10, osContext->getContextId()); allocation.handle = ALLOCATION_HANDLE; @@ -756,7 +756,7 @@ TEST_F(Wddm20Tests, WhenLastFenceLessEqualThanMonitoredThenWaitFromCpuIsNotCalle } TEST_F(Wddm20Tests, WhenLastFenceGreaterThanMonitoredThenWaitFromCpuIsCalled) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.getResidencyData().updateCompletionData(10, osContext->getContextId()); allocation.handle = ALLOCATION_HANDLE; @@ -926,7 +926,7 @@ TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeReside } TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.handle = 0x3; GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]); auto mockTemporaryResources = reinterpret_cast(gmockWddm.temporaryResources.get()); @@ -936,7 +936,7 @@ TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeReside } TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.handle = 0x3; GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]); auto mockTemporaryResources = reinterpret_cast(gmockWddm.temporaryResources.get()); @@ -948,7 +948,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryR } TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.handle = 0x2; GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]); auto mockTemporaryResources = reinterpret_cast(gmockWddm.temporaryResources.get()); @@ -961,7 +961,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside } TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.handle = 0x2; GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]); auto mockTemporaryResources = reinterpret_cast(gmockWddm.temporaryResources.get()); @@ -975,7 +975,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside } TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesThenStoreTemporaryResource) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.handle = 0x2; GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]); auto mockTemporaryResources = reinterpret_cast(gmockWddm.temporaryResources.get()); @@ -998,7 +998,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesThenAcqui } TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenReturnSuccess) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]); auto mockTemporaryResources = reinterpret_cast(gmockWddm.temporaryResources.get()); mockTemporaryResources->resourceHandles.push_back(allocation.handle); @@ -1085,7 +1085,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenOtherReso TEST_F(WddmLockWithMakeResidentTests, whenAlllocationNeedsBlockingMakeResidentBeforeLockThenLockWithBlockingMakeResident) { WddmMemoryManager memoryManager(*executionEnvironment); - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); allocation.needsMakeResidentBeforeLock = false; memoryManager.lockResource(&allocation); EXPECT_EQ(1u, wddm->lockResult.called); diff --git a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp index 8807b95d5d..1f20adfa55 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -110,7 +110,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenFreeGpuVirtualAddressIsCalledThenKmDa } TEST_F(WddmKmDafListenerTest, givenWddmWhenMakeResidentIsCalledThenKmDafListenerNotifyMakeResidentIsFedWithCorrectParams) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); wddmWithKmDafMock->makeResident(&allocation.handle, 1, false, nullptr, 0x1000); @@ -123,7 +123,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenMakeResidentIsCalledThenKmDafListener } TEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotifyEvictIsFedWithCorrectParams) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); uint64_t sizeToTrim; wddmWithKmDafMock->evict(&allocation.handle, 1, sizeToTrim); diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index c4c2bf9bee..6a8a860a15 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -80,7 +80,9 @@ TEST(WddmMemoryManager, WhenWddmMemoryManagerIsCreatedThenItIsNonAssignable) { } TEST(WddmAllocationTest, givenAllocationIsTrimCandidateInOneOsContextWhenGettingTrimCandidatePositionThenReturnItsPositionAndUnusedPositionInOtherContexts) { - MockWddmAllocation allocation; + auto executionEnvironment = std::unique_ptr(MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u)); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + MockWddmAllocation allocation(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext()); MockOsContext osContext(1u, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo))); allocation.setTrimCandidateListPosition(osContext.getContextId(), 700u); @@ -89,14 +91,18 @@ TEST(WddmAllocationTest, givenAllocationIsTrimCandidateInOneOsContextWhenGetting } TEST(WddmAllocationTest, givenAllocationCreatedWithOsContextCountOneWhenItIsCreatedThenMaxOsContextCountIsUsedInstead) { - MockWddmAllocation allocation; + auto executionEnvironment = std::unique_ptr(MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u)); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + MockWddmAllocation allocation(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext()); allocation.setTrimCandidateListPosition(1u, 700u); EXPECT_EQ(700u, allocation.getTrimCandidateListPosition(1u)); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(0u)); } TEST(WddmAllocationTest, givenRequestedContextIdTooLargeWhenGettingTrimCandidateListPositionThenReturnUnusedPosition) { - MockWddmAllocation allocation; + auto executionEnvironment = std::unique_ptr(MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u)); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + MockWddmAllocation allocation(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext()); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(1u)); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(1000u)); } @@ -507,7 +513,7 @@ TEST_F(WddmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationT size_t size = 0x1000; uint64_t gpuPtr = 0x123; - MockWddmAllocation gfxAllocation; + MockWddmAllocation gfxAllocation(rootDeviceEnvironment->getGmmClientContext()); HostPtrEntryKey key{cpuPtr, gfxAllocation.getRootDeviceIndex()}; gfxAllocation.cpuPtr = cpuPtr; gfxAllocation.size = size; @@ -934,7 +940,7 @@ TEST_F(WddmMemoryManagerTest, GivenOffsetsWhenAllocatingGpuMemHostThenAllocatedO if (memoryManager->isLimitedGPU(0)) { GTEST_SKIP(); } - MockWddmAllocation alloc, allocOffseted; + MockWddmAllocation alloc(rootDeviceEnvironment->getGmmClientContext()), allocOffseted(rootDeviceEnvironment->getGmmClientContext()); // three pages void *ptr = alignedMalloc(4 * 4096, 4096); ASSERT_NE(nullptr, ptr); @@ -990,7 +996,7 @@ TEST_F(WddmMemoryManagerTest, WhenAllocatingGpuMemThenOsInternalStorageIsPopulat if (memoryManager->isLimitedGPU(0)) { GTEST_SKIP(); } - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); // three pages void *ptr = alignedMalloc(3 * 4096, 4096); auto *gpuAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, false, 3 * MemoryConstants::pageSize}, ptr); @@ -1008,7 +1014,7 @@ TEST_F(WddmMemoryManagerTest, WhenAllocatingGpuMemThenOsInternalStorageIsPopulat } TEST_F(WddmMemoryManagerTest, GivenAlignedPointerWhenAllocate32BitMemoryThenGmmCalledWithCorrectPointerAndSize) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); uint32_t size = 4096; void *ptr = reinterpret_cast(4096); auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, size, ptr, GraphicsAllocation::AllocationType::BUFFER); @@ -1018,7 +1024,7 @@ TEST_F(WddmMemoryManagerTest, GivenAlignedPointerWhenAllocate32BitMemoryThenGmmC } TEST_F(WddmMemoryManagerTest, GivenUnAlignedPointerAndSizeWhenAllocate32BitMemoryThenGmmCalledWithCorrectPointerAndSize) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); uint32_t size = 0x1001; void *ptr = reinterpret_cast(0x1001); auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, size, ptr, GraphicsAllocation::AllocationType::BUFFER); @@ -2050,7 +2056,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingAllocationWithReservedGpuVirtu } TEST_F(WddmMemoryManagerSimpleTest, givenAllocationWithReservedGpuVirtualAddressWhenMapCallFailsDuringCreateWddmAllocationThenReleasePreferredAddress) { - MockWddmAllocation allocation(1); + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext(), 1); allocation.setAllocationType(GraphicsAllocation::AllocationType::KERNEL_ISA); uint64_t gpuAddress = 0x123; uint64_t sizeForFree = 0x1234; @@ -2072,7 +2078,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMultiHandleAllocationAndPreferredGpuVaI } uint32_t numGmms = 10; - MockWddmAllocation allocation(numGmms); + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext(), numGmms); allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.storageInfo.multiStorage = true; diff --git a/opencl/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp index 5c97c62e99..55fe0781ef 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp @@ -137,6 +137,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT osContext->incRefInternal(); residencyController = &static_cast(osContext)->getResidencyController(); + gmmClientContext = executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(); } void TearDown() { @@ -149,6 +150,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT ::testing::NiceMock *wddm = nullptr; OsContext *osContext; WddmResidencyController *residencyController; + GmmClientContext *gmmClientContext = nullptr; }; struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test { @@ -174,6 +176,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test { osContext->incRefInternal(); residencyController = &static_cast(osContext)->getResidencyController(); + gmmClientContext = executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext(); } void TearDown() { @@ -188,6 +191,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test { OsContext *osContext = nullptr; MockGdi *gdi = nullptr; WddmResidencyController *residencyController = nullptr; + GmmClientContext *gmmClientContext = nullptr; }; TEST(WddmResidencyController, givenWddmResidencyControllerWhenItIsConstructedThenDoNotRegisterTrimCallback) { @@ -267,7 +271,7 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenWddmResidencyControllerWhenItIsD } TEST_F(WddmResidencyControllerTest, givenUsedAllocationWhenCallingRemoveFromTrimCandidateListIfUsedThenRemoveIt) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation); residencyController->removeFromTrimCandidateListIfUsed(&allocation, false); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(osContextId)); @@ -280,13 +284,13 @@ TEST_F(WddmResidencyControllerTest, givenWddmResidencyControllerWhenIsMemoryExha } TEST_F(WddmResidencyControllerTest, givenUnusedAllocationWhenCallingRemoveFromTrimCandidateListIfUsedThenIgnore) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); residencyController->removeFromTrimCandidateListIfUsed(&allocation, false); EXPECT_EQ(trimListUnusedPosition, allocation.getTrimCandidateListPosition(osContextId)); } TEST_F(WddmResidencyControllerTest, WhenAddingToTrimCandidateListThenAllocationIsPlacedInContainerAndAssignedPosition) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation); EXPECT_NE(0u, residencyController->trimCandidateList.size()); @@ -299,7 +303,7 @@ TEST_F(WddmResidencyControllerTest, WhenAddingToTrimCandidateListThenAllocationI } TEST_F(WddmResidencyControllerTest, WhenAddingToTrimCandidateListThenDoNotInsertAllocationAlreadyOnTheList) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); residencyController->trimCandidateList.resize(0); @@ -320,7 +324,7 @@ TEST_F(WddmResidencyControllerTest, WhenAddingToTrimCandidateListThenDoNotInsert } TEST_F(WddmResidencyControllerTest, WhenRemovingFromTrimCandidateListThenUnusedPositionIsAssigned) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation); residencyController->removeFromTrimCandidateList(&allocation, false); @@ -329,7 +333,7 @@ TEST_F(WddmResidencyControllerTest, WhenRemovingFromTrimCandidateListThenUnusedP } TEST_F(WddmResidencyControllerTest, WhenRemovingFromTrimCandidateListThenAllocationInAssignedPositionIsRemoved) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation); size_t position = allocation.getTrimCandidateListPosition(osContextId); @@ -342,7 +346,7 @@ TEST_F(WddmResidencyControllerTest, WhenRemovingFromTrimCandidateListThenAllocat } TEST_F(WddmResidencyControllerTest, GivenOneAllocationWhenRemovingFromTrimCandidateListThenTrimCandidateListIsEmpty) { - MockWddmAllocation allocation; + MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext()); residencyController->trimCandidateList.resize(0); @@ -354,7 +358,8 @@ TEST_F(WddmResidencyControllerTest, GivenOneAllocationWhenRemovingFromTrimCandid } TEST_F(WddmResidencyControllerTest, WhenRemovingFromTrimCandidateListThenLastAllocationAndAllPreviousEmptyEntriesAreRemoved) { - MockWddmAllocation allocation1, allocation2; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); residencyController->trimCandidateList.resize(0); @@ -374,7 +379,9 @@ TEST_F(WddmResidencyControllerTest, WhenRemovingFromTrimCandidateListThenLastAll } TEST_F(WddmResidencyControllerTest, WhenAddingToTrimCandidateListThenSuccessivePositionIsAssigned) { - MockWddmAllocation allocation1, allocation2, allocation3; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation3(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation1); residencyController->addToTrimCandidateList(&allocation2); @@ -386,7 +393,9 @@ TEST_F(WddmResidencyControllerTest, WhenAddingToTrimCandidateListThenSuccessiveP } TEST_F(WddmResidencyControllerTest, GivenAllocationThatIsNotLastWhenRemovingFromTrimCandidateListAndCompactingThenRemoveEntry) { - MockWddmAllocation allocation1, allocation2, allocation3; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation3(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation1); residencyController->addToTrimCandidateList(&allocation2); @@ -402,7 +411,9 @@ TEST_F(WddmResidencyControllerTest, GivenAllocationThatIsNotLastWhenRemovingFrom } TEST_F(WddmResidencyControllerTest, GivenAllocationThatIsNotLastWhenRemovingFromTrimCandidateListThenReplaceWithNullEntry) { - MockWddmAllocation allocation1, allocation2, allocation3; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation3(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation1); residencyController->addToTrimCandidateList(&allocation2); @@ -418,7 +429,10 @@ TEST_F(WddmResidencyControllerTest, GivenAllocationThatIsNotLastWhenRemovingFrom } TEST_F(WddmResidencyControllerTest, WhenCompactingTrimCandidateListThenInitialNullEntriesAreRemovedAndPositionsAreUpdated) { - MockWddmAllocation allocation1, allocation2, allocation3, allocation4; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation3(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation4(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation1); residencyController->addToTrimCandidateList(&allocation2); @@ -445,7 +459,10 @@ TEST_F(WddmResidencyControllerTest, WhenCompactingTrimCandidateListThenInitialNu } TEST_F(WddmResidencyControllerTest, WhenCompactingTrimCandidateListThenNonNullEntriesAreNotRemoved) { - MockWddmAllocation allocation1, allocation2, allocation3, allocation4; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation3(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation4(rootDeviceEnvironment->getGmmClientContext()); residencyController->addToTrimCandidateList(&allocation1); residencyController->addToTrimCandidateList(&allocation2); @@ -484,7 +501,8 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenNotUsedAllocationsFromPreviousPe trimNotification.NumBytesToTrim = 0; // allocations have fence value == 0 by default - MockWddmAllocation allocation1, allocation2; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); allocation1.getResidencyData().updateCompletionData(0, osContextId); allocation2.getResidencyData().updateCompletionData(0, osContextId); @@ -519,7 +537,8 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenOneUsedAllocationFromPreviousPer trimNotification.NumBytesToTrim = 0; // allocations have fence value == 0 by default - MockWddmAllocation allocation1, allocation2; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); allocation1.getResidencyData().resident[osContextId] = true; // mark allocation used from last periodic trim allocation1.getResidencyData().updateCompletionData(0, osContextId); @@ -635,7 +654,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, GivenZeroWhenTrimmingToBudgetThenTrue TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenAllDoneAllocationsAreTrimmed) { gdi->setNonZeroNumBytesToTrimInEvict(); - MockWddmAllocation allocation1, allocation2, allocation3; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation3(rootDeviceEnvironment->getGmmClientContext()); allocation1.getResidencyData().resident[osContextId] = true; allocation1.getResidencyData().updateCompletionData(0, osContextId); @@ -672,7 +693,7 @@ TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenAllDoneAlloca TEST_F(WddmResidencyControllerWithGdiTest, GivenNumBytesToTrimIsNotZeroWhenTrimmingToBudgetThenFalseIsReturned) { gdi->setNonZeroNumBytesToTrimInEvict(); - MockWddmAllocation allocation1; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); allocation1.getResidencyData().resident[osContextId] = true; allocation1.getResidencyData().updateCompletionData(0, osContextId); @@ -730,7 +751,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, GivenNumBytesToTrimIsZeroWhenTrimming TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenEvictedAllocationIsMarkedNonResident) { gdi->setNonZeroNumBytesToTrimInEvict(); - MockWddmAllocation allocation1, allocation2, allocation3; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation2(rootDeviceEnvironment->getGmmClientContext()); + MockWddmAllocation allocation3(rootDeviceEnvironment->getGmmClientContext()); allocation1.getResidencyData().resident[osContextId] = true; allocation1.getResidencyData().updateCompletionData(0, osContextId); @@ -761,7 +784,7 @@ TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenEvictedAlloca TEST_F(WddmResidencyControllerWithGdiTest, GivenLastFenceIsGreaterThanMonitoredWhenTrimmingToBudgetThenWaitForCpu) { gdi->setNonZeroNumBytesToTrimInEvict(); - MockWddmAllocation allocation1; + MockWddmAllocation allocation1(rootDeviceEnvironment->getGmmClientContext()); allocation1.getResidencyData().resident[osContextId] = true; allocation1.getResidencyData().updateCompletionData(2, osContextId); @@ -912,7 +935,10 @@ TEST_F(WddmResidencyControllerLockTest, givenPeriodicTrimAndTrimToBudgetWhenTrim } TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, WhenMakingResidentResidencyAllocationsThenAllAllocationsAreMarked) { - MockWddmAllocation allocation1, allocation2, allocation3, allocation4; + MockWddmAllocation allocation1(gmmClientContext); + MockWddmAllocation allocation2(gmmClientContext); + MockWddmAllocation allocation3(gmmClientContext); + MockWddmAllocation allocation4(gmmClientContext); ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4}; residencyController->makeResidentResidencyAllocations(residencyPack); @@ -924,7 +950,10 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, WhenMakingResidentRes } TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, WhenMakingResidentResidencyAllocationsThenLastFenceIsUpdated) { - MockWddmAllocation allocation1, allocation2, allocation3, allocation4; + MockWddmAllocation allocation1(gmmClientContext); + MockWddmAllocation allocation2(gmmClientContext); + MockWddmAllocation allocation3(gmmClientContext); + MockWddmAllocation allocation4(gmmClientContext); ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4}; residencyController->getMonitoredFence().currentFenceValue = 20; @@ -941,7 +970,8 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, GivenTripleAllocation if (executionEnvironment->memoryManager.get()->isLimitedGPU(0)) { GTEST_SKIP(); } - MockWddmAllocation allocation1, allocation2; + MockWddmAllocation allocation1(gmmClientContext); + MockWddmAllocation allocation2(gmmClientContext); void *ptr = reinterpret_cast(wddm->virtualAllocAddress + 0x1500); WddmAllocation *allocationTriple = (WddmAllocation *)memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, 2 * MemoryConstants::pageSize}, ptr); @@ -959,7 +989,8 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, GivenTripleAllocation } TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, GivenTripleAllocationsWhenMakingResidentResidencyAllocationsThenLastFencePlusOneIsSet) { - MockWddmAllocation allocation1, allocation2; + MockWddmAllocation allocation1(gmmClientContext); + MockWddmAllocation allocation2(gmmClientContext); WddmAllocation *allocationTriple = static_cast(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, 2 * MemoryConstants::pageSize}, reinterpret_cast(0x1500))); @@ -976,7 +1007,10 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, GivenTripleAllocation } TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenDontMarkAllocationsAsResident) { - MockWddmAllocation allocation1, allocation2, allocation3, allocation4; + MockWddmAllocation allocation1(gmmClientContext); + MockWddmAllocation allocation2(gmmClientContext); + MockWddmAllocation allocation3(gmmClientContext); + MockWddmAllocation allocation4(gmmClientContext); auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; }; @@ -995,7 +1029,8 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin } TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenDontMarkTripleAllocationsAsResident) { - MockWddmAllocation allocation1, allocation2; + MockWddmAllocation allocation1(gmmClientContext); + MockWddmAllocation allocation2(gmmClientContext); void *ptr = reinterpret_cast(wddm->getWddmMinAddress() + 0x1500); WddmAllocation *allocationTriple = static_cast(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, 2 * MemoryConstants::pageSize}, ptr)); ASSERT_NE(nullptr, allocationTriple); @@ -1018,7 +1053,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin } TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenCallItAgainWithCantTrimFurtherSetToTrue) { - MockWddmAllocation allocation1; + MockWddmAllocation allocation1(gmmClientContext); auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; }; @@ -1033,8 +1068,8 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin } TEST_F(WddmResidencyControllerWithMockWddmTest, givenAllocationPackPassedWhenCallingMakeResidentResidencyAllocationsThenItIsUsed) { - MockWddmAllocation allocation1; - MockWddmAllocation allocation2; + MockWddmAllocation allocation1(gmmClientContext); + MockWddmAllocation allocation2(gmmClientContext); allocation1.handle = 1; allocation2.handle = 2; ResidencyContainer residencyPack{&allocation1, &allocation2}; @@ -1052,7 +1087,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenAllocationPackPassedWhenCal } TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToBudgetSuceedsWhenCallingMakeResidentResidencyAllocationsThenSucceed) { - MockWddmAllocation allocation1; + MockWddmAllocation allocation1(gmmClientContext); void *cpuPtr = reinterpret_cast(wddm->getWddmMinAddress() + 0x1000); size_t allocationSize = 0x1000; WddmAllocation allocationToTrim(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, allocationSize, nullptr, MemoryPool::MemoryNull, 0u, 1u); @@ -1074,7 +1109,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB } TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenMemoryBudgetExhaustedIsSetToTrue) { - MockWddmAllocation allocation1; + MockWddmAllocation allocation1(gmmClientContext); ResidencyContainer residencyPack{&allocation1}; auto makeResidentThatFails = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { return false; }; diff --git a/opencl/test/unit_test/os_interface/windows/wddm_residency_handler_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_residency_handler_tests.cpp index b49040a8b9..934c759e9a 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_residency_handler_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_residency_handler_tests.cpp @@ -27,26 +27,28 @@ struct WddmMemoryOperationsHandlerTest : public WddmTest { void SetUp() override { WddmTest::SetUp(); wddmMemoryOperationsHandler = std::make_unique(wddm); - wddmAllocation.handle = 0x2u; + wddmAllocation = std::make_unique(rootDeviceEnvironment->getGmmClientContext()); + wddmFragmentedAllocation = std::make_unique(rootDeviceEnvironment->getGmmClientContext()); + wddmAllocation->handle = 0x2u; osHandleStorageFirst = std::make_unique(); osHandleStorageSecond = std::make_unique(); - wddmFragmentedAllocation.fragmentsStorage.fragmentCount = 2; - wddmFragmentedAllocation.fragmentsStorage.fragmentStorageData[0].osHandleStorage = osHandleStorageFirst.get(); - static_cast(wddmFragmentedAllocation.fragmentsStorage.fragmentStorageData[0].osHandleStorage)->handle = 0x3u; - wddmFragmentedAllocation.fragmentsStorage.fragmentStorageData[1].osHandleStorage = osHandleStorageSecond.get(); - static_cast(wddmFragmentedAllocation.fragmentsStorage.fragmentStorageData[1].osHandleStorage)->handle = 0x4u; + wddmFragmentedAllocation->fragmentsStorage.fragmentCount = 2; + wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[0].osHandleStorage = osHandleStorageFirst.get(); + static_cast(wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[0].osHandleStorage)->handle = 0x3u; + wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[1].osHandleStorage = osHandleStorageSecond.get(); + static_cast(wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[1].osHandleStorage)->handle = 0x4u; - allocationPtr = &wddmAllocation; + allocationPtr = wddmAllocation.get(); - allocationData.push_back(&wddmAllocation); - allocationData.push_back(&wddmFragmentedAllocation); + allocationData.push_back(wddmAllocation.get()); + allocationData.push_back(wddmFragmentedAllocation.get()); } std::unique_ptr wddmMemoryOperationsHandler; - MockWddmAllocation wddmAllocation; - MockWddmAllocation wddmFragmentedAllocation; + std::unique_ptr wddmAllocation; + std::unique_ptr wddmFragmentedAllocation; std::unique_ptr osHandleStorageFirst; std::unique_ptr osHandleStorageSecond; GraphicsAllocation *allocationPtr; @@ -55,42 +57,42 @@ struct WddmMemoryOperationsHandlerTest : public WddmTest { TEST_F(WddmMemoryOperationsHandlerTest, givenRegularAllocationWhenMakingResidentAllocationThenMakeResidentCalled) { EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS); } TEST_F(WddmMemoryOperationsHandlerTest, givenFragmentedAllocationWhenMakingResidentAllocationThenMakeResidentCalled) { - allocationPtr = &wddmFragmentedAllocation; + allocationPtr = wddmFragmentedAllocation.get(); EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); } TEST_F(WddmMemoryOperationsHandlerTest, givenVariousAllocationsWhenMakingResidentAllocationThenMakeResidentCalled) { EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef(allocationData)), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); } TEST_F(WddmMemoryOperationsHandlerTest, givenRegularAllocationWhenEvictingResidentAllocationThenEvictCalled) { EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); + EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); } TEST_F(WddmMemoryOperationsHandlerTest, givenFragmentedAllocationWhenEvictingResidentAllocationThenEvictCalled) { - allocationPtr = &wddmFragmentedAllocation; + allocationPtr = wddmFragmentedAllocation.get(); EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); + EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); } TEST_F(WddmMemoryOperationsHandlerTest, givenVariousAllocationsWhenEvictingResidentAllocationThenEvictCalled) { EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef(allocationData)), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); - EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); - EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); + EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); + EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS); + EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND); } TEST(WddmResidentBufferTests, whenBuffersIsCreatedWithMakeResidentFlagSetThenItIsMadeResidentUponCreation) { diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp index b2fe9a2788..9b31b7b8c8 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp @@ -900,11 +900,12 @@ TEST_F(glSharingTests, givenClGLBufferWhenMapAndUnmapBufferIsCalledThenCopyOnGpu auto buffer = castToObject(glBuffer); EXPECT_EQ(buffer->getCpuAddressForMemoryTransfer(), nullptr); // no cpu ptr auto gfxAllocation = buffer->getGraphicsAllocation(rootDeviceIndex); + auto pClDevice = context.getDevice(0); for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) { - gfxAllocation->setGmm(new MockGmm(), handleId); + gfxAllocation->setGmm(new MockGmm(pClDevice->getGmmClientContext()), handleId); } - auto commandQueue = CommandQueue::create(&context, context.getDevice(0), 0, false, retVal); + auto commandQueue = CommandQueue::create(&context, pClDevice, 0, false, retVal); ASSERT_EQ(CL_SUCCESS, retVal); size_t offset = 1; @@ -943,11 +944,12 @@ TEST_F(glSharingTests, givenClGLBufferWhenMapAndUnmapBufferIsCalledTwiceThenReus auto buffer = castToObject(glBuffer); EXPECT_EQ(buffer->getCpuAddressForMemoryTransfer(), nullptr); // no cpu ptr auto gfxAllocation = buffer->getGraphicsAllocation(rootDeviceIndex); + auto pClDevice = context.getDevice(0); for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) { - gfxAllocation->setGmm(new MockGmm(), handleId); + gfxAllocation->setGmm(new MockGmm(pClDevice->getGmmClientContext()), handleId); } - auto commandQueue = CommandQueue::create(&context, context.getDevice(0), 0, false, retVal); + auto commandQueue = CommandQueue::create(&context, pClDevice, 0, false, retVal); ASSERT_EQ(CL_SUCCESS, retVal); auto mappedPtr = clEnqueueMapBuffer(commandQueue, glBuffer, CL_TRUE, CL_MAP_READ, 0, buffer->getSize(), diff --git a/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h b/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h index 7550a57d24..91678a742f 100644 --- a/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h +++ b/opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h @@ -57,6 +57,7 @@ struct UnifiedSharingContextFixture : ::testing::Test { template struct UnifiedSharingMockMemoryManager : MockMemoryManager { + using MockMemoryManager::MockMemoryManager; GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, GraphicsAllocation::AllocationType allocType) override { if (!validMemoryManager) { return nullptr; @@ -67,7 +68,7 @@ struct UnifiedSharingMockMemoryManager : MockMemoryManager { rootDeviceIndex, false, false, false); graphicsAllocation->setSharedHandle(static_cast(reinterpret_cast(handle))); graphicsAllocation->set32BitAllocation(false); - graphicsAllocation->setDefaultGmm(new MockGmm()); + graphicsAllocation->setDefaultGmm(new MockGmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmClientContext())); return graphicsAllocation; } }; @@ -76,7 +77,7 @@ template struct UnifiedSharingFixture : UnifiedSharingContextFixture { void SetUp() override { UnifiedSharingContextFixture::SetUp(); - this->memoryManager = std::make_unique>(); + this->memoryManager = std::make_unique>(*this->device->getExecutionEnvironment()); this->memoryManagerBackup = std::make_unique>(&this->context->memoryManager, this->memoryManager.get()); } diff --git a/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp b/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp index aede2fb682..527c6d9c67 100644 --- a/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp +++ b/opencl/test/unit_test/xe_hp_core/copy_engine_tests_xe_hp_core.cpp @@ -562,7 +562,7 @@ XE_HP_CORE_TEST_F(BlitXE_HP_CORETests, givenDebugFlagSetWhenCompressionIsUsedThe using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; auto blitCmd = FamilyType::cmdInitXyCopyBlt; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(clDevice->getGmmClientContext()); gmm->isCompressionEnabled = true; MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::System4KBPages, mockMaxOsContextCount); diff --git a/shared/test/common/gen11/image_surface_state_tests_gen11.cpp b/shared/test/common/gen11/image_surface_state_tests_gen11.cpp index 614afe0141..def43de685 100644 --- a/shared/test/common/gen11/image_surface_state_tests_gen11.cpp +++ b/shared/test/common/gen11/image_surface_state_tests_gen11.cpp @@ -17,11 +17,11 @@ GEN11TEST_F(ImageSurfaceStateTestsGen11, givenGmmWithMediaCompressedWhenSetFlags auto castSurfaceState = reinterpret_cast(surfaceState.get()); castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); } @@ -34,7 +34,7 @@ GEN11TEST_F(ImageSurfaceStateTestsGen11, givenGmmWithMediaCompressedWhenSetMipTa EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u); - setMipTailStartLod(castSurfaceState, &mockGmm); + setMipTailStartLod(castSurfaceState, mockGmm.get()); - EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState()); + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm->gmmResourceInfo->getMipTailStartLodSurfaceState()); } diff --git a/shared/test/common/gen12lp/image_surface_state_tests_gen12lp.cpp b/shared/test/common/gen12lp/image_surface_state_tests_gen12lp.cpp index d91f5e4e98..9c31c124b3 100644 --- a/shared/test/common/gen12lp/image_surface_state_tests_gen12lp.cpp +++ b/shared/test/common/gen12lp/image_surface_state_tests_gen12lp.cpp @@ -17,12 +17,12 @@ GEN12LPTEST_F(ImageSurfaceStateTestsGen12LP, givenGmmWithMediaCompressedWhenSetF auto castSurfaceState = reinterpret_cast(surfaceState.get()); castSurfaceState->setAuxiliarySurfaceMode(TGLLPFamily::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), TGLLPFamily::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), false); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), TGLLPFamily::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), true); } @@ -32,8 +32,8 @@ GEN12LPTEST_F(ImageSurfaceStateTestsGen12LP, givenGmmWhenSetClearColorParamsThen auto surfaceState = std::make_unique(size); auto castSurfaceState = reinterpret_cast(surfaceState.get()); - mockGmm.gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = true; - EncodeSurfaceState::setClearColorParams(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = true; + EncodeSurfaceState::setClearColorParams(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getClearValueAddressEnable(), true); } @@ -46,7 +46,7 @@ GEN12LPTEST_F(ImageSurfaceStateTestsGen12LP, givenGmmWithMediaCompressedWhenSetM EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u); - setMipTailStartLod(castSurfaceState, &mockGmm); + setMipTailStartLod(castSurfaceState, mockGmm.get()); - EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState()); + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm->gmmResourceInfo->getMipTailStartLodSurfaceState()); } diff --git a/shared/test/common/gen8/image_surface_state_tests_gen8.cpp b/shared/test/common/gen8/image_surface_state_tests_gen8.cpp index 4b05efe32e..3626b7ca0a 100644 --- a/shared/test/common/gen8/image_surface_state_tests_gen8.cpp +++ b/shared/test/common/gen8/image_surface_state_tests_gen8.cpp @@ -17,11 +17,11 @@ GEN8TEST_F(ImageSurfaceStateTestsGen8, givenGmmWithMediaCompressedWhenSetFlagsFo auto castSurfaceState = reinterpret_cast(surfaceState.get()); castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); } diff --git a/shared/test/common/gen9/image_surface_state_tests_gen9.cpp b/shared/test/common/gen9/image_surface_state_tests_gen9.cpp index 8d462b3466..7f0fb91324 100644 --- a/shared/test/common/gen9/image_surface_state_tests_gen9.cpp +++ b/shared/test/common/gen9/image_surface_state_tests_gen9.cpp @@ -17,11 +17,11 @@ GEN9TEST_F(ImageSurfaceStateTestsGen9, givenGmmWithMediaCompressedWhenSetFlagsFo auto castSurfaceState = reinterpret_cast(surfaceState.get()); castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); } @@ -34,7 +34,7 @@ GEN9TEST_F(ImageSurfaceStateTestsGen9, givenGmmWithMediaCompressedWhenSetMipTail EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u); - setMipTailStartLod(castSurfaceState, &mockGmm); + setMipTailStartLod(castSurfaceState, mockGmm.get()); - EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState()); + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm->gmmResourceInfo->getMipTailStartLodSurfaceState()); } diff --git a/shared/test/common/helpers/blit_commands_helper_tests_gen12lp.cpp b/shared/test/common/helpers/blit_commands_helper_tests_gen12lp.cpp index 9c01e346b2..d4ef0e6f4d 100644 --- a/shared/test/common/helpers/blit_commands_helper_tests_gen12lp.cpp +++ b/shared/test/common/helpers/blit_commands_helper_tests_gen12lp.cpp @@ -77,7 +77,7 @@ HWTEST2_F(BlitTests, givenIncorrectBytePerPixelWhenAppendColorDepthThenAbortIsTh HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdressAreCorectOffseted, IsGen12LP) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::System4KBPages); @@ -174,7 +174,7 @@ struct MyMockResourecInfo : public GmmResourceInfo { HWTEST2_F(BlitTests, givenTiledSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromGmm, IsGen12LP) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); GMM_RESCREATE_PARAMS gmmParams = {}; auto myResourecInfo = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams); myResourecInfo->pitch = 0x100; @@ -205,7 +205,7 @@ HWTEST2_F(BlitTests, givenTiledSrcAndDestinationImagesWhenAppendImageCommandsThe HWTEST2_F(BlitTests, givenLinearSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromProperties, IsGen12LP) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); GMM_RESCREATE_PARAMS gmmParams = {}; auto myResourecInfo = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams); myResourecInfo->pitch = 0x100; diff --git a/shared/test/common/helpers/test_blit_commands_helper_xehp_and_later.cpp b/shared/test/common/helpers/test_blit_commands_helper_xehp_and_later.cpp index d57e3a2f59..910050183a 100644 --- a/shared/test/common/helpers/test_blit_commands_helper_xehp_and_later.cpp +++ b/shared/test/common/helpers/test_blit_commands_helper_xehp_and_later.cpp @@ -48,7 +48,7 @@ HWTEST2_F(BlitTests, givenDeviceWithoutDefaultGmmWhenAppendBlitCommandsForFillBu HWTEST2_F(BlitTests, givenGmmWithDisabledCompresionWhenAppendBlitCommandsForFillBufferThenDstCompressionDisabled, CompressionParamsSupportedMatcher) { using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT; auto blitCmd = FamilyType::cmdInitXyColorBlt; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); gmm->isCompressionEnabled = false; MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), @@ -62,7 +62,7 @@ HWTEST2_F(BlitTests, givenGmmWithDisabledCompresionWhenAppendBlitCommandsForFill HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionWhenAppendBlitCommandsForFillBufferThenDstCompressionEnabled, CompressionParamsSupportedMatcher) { using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT; auto blitCmd = FamilyType::cmdInitXyColorBlt; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); gmm->isCompressionEnabled = true; MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), @@ -77,13 +77,13 @@ HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionWhenAppendBlitCommandsForFillB using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT; auto blitCmd = FamilyType::cmdInitXyColorBlt; - auto gmm = std::make_unique(); + auto gmmContext = pDevice->getGmmClientContext(); + auto gmm = std::make_unique(gmmContext); gmm->isCompressionEnabled = true; MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::LocalMemory); mockAllocation.setGmm(gmm.get(), 0); - auto gmmContext = pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(); uint32_t compressionFormat = gmmContext->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT); BlitCommandsHelper::appendBlitCommandsForFillBuffer(&mockAllocation, blitCmd, *pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]); @@ -98,7 +98,7 @@ HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionAndDebugFlagSetWhenAppendBlitC uint32_t newCompressionFormat = 1; DebugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); gmm->isCompressionEnabled = true; MockGraphicsAllocation mockAllocation(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::LocalMemory); @@ -419,7 +419,7 @@ HWTEST2_F(BlitTests, givenTiled64SrcAndDestinationAppendTilingTypeThenCorrectTil HWTEST2_F(BlitTests, givenTiled4SrcAndDestinationAppendImageCommandsThenCorrectTiledIsSet, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); auto flags = gmm->gmmResourceInfo->getResourceFlags(); flags->Info.Tile4 = true; MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, @@ -445,7 +445,7 @@ HWTEST2_F(BlitTests, givenTiled4SrcAndDestinationAppendImageCommandsThenCorrectT HWTEST2_F(BlitTests, givenNotTiled64SrcAndDestinationAppendImageCommandsThenCorrectTiledIsSet, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); auto flags = gmm->gmmResourceInfo->getResourceFlags(); flags->Info.Tile64 = true; MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, @@ -471,7 +471,7 @@ HWTEST2_F(BlitTests, givenNotTiled64SrcAndDestinationAppendImageCommandsThenCorr HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationAppendImageCommandsThenCorrectTiledIsSet, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); auto flags = gmm->gmmResourceInfo->getResourceFlags(); flags->Info.Tile64 = false; MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, @@ -505,7 +505,7 @@ HWTEST2_F(BlitTests, givenGmmParamsWhenAppendSurfaceTypeThenCorrectSurfaceTypeIs {GMM_RESOURCE_TYPE::RESOURCE_1D, XY_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D, 10u}}; for (const auto &[resourceType, expectedSurfaceType, arraySize] : testParams) { - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->mockResourceCreateParams.Type = resourceType; resourceInfo->mockResourceCreateParams.ArraySize = arraySize; @@ -530,7 +530,7 @@ HWTEST2_F(BlitTests, givenGmmParamsWhenAppendSurfaceTypeThenCorrectSurfaceTypeIs HWTEST2_F(BlitTests, givenInvalidResourceWhenAppendSurfaceTypeThenSurfaceTypeDoesNotChange, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->mockResourceCreateParams.Type = GMM_RESOURCE_TYPE::RESOURCE_INVALID; @@ -586,7 +586,7 @@ HWTEST2_F(BlitTests, givenGmmParamsWhenGetBlitAllocationPropertiesIsCalledThenCo {true, false, true}}; for (auto &[mediaCompressed, renderCompressed, compressionExpected] : params) { - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); auto &resInfo = resourceInfo->getResourceFlags()->Info; resInfo.MediaCompressed = mediaCompressed; @@ -696,7 +696,7 @@ HWTEST2_F(BlitTests, givenInputAndDefaultSlicePitchWhenAppendBlitCommandsForImag HWTEST2_F(BlitTests, givenResourceInfoWithZeroPitchWhenAppendImageCommandsThenPitchEqualPropertiesValue, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); GMM_RESCREATE_PARAMS gmmParams = {}; gmm->gmmResourceInfo.reset(new MyMockResourecInfo(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams)); MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, @@ -725,7 +725,7 @@ HWTEST2_F(BlitTests, givenResourceInfoWithZeroPitchWhenAppendImageCommandsThenPi HWTEST2_F(BlitTests, givenTiledAllocationWhenAppendBlitCommandsForImagesThenBlitCmdIsCorrect, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); GMM_RESCREATE_PARAMS gmmParams = {}; auto myResourecInfo = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams); myResourecInfo->pitch = 0x100; @@ -760,7 +760,7 @@ HWTEST2_F(BlitTests, givenTiledAllocationWhenAppendBlitCommandsForImagesThenBlit HWTEST2_F(BlitTests, givenAlocationsWhenAppendBlitCommandsForImagesThenSurfaceSizesAreProgrammedCorrectly, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::System4KBPages, mockMaxOsContextCount); @@ -793,7 +793,7 @@ HWTEST2_F(BlitTests, givenAlocationsWhenAppendBlitCommandsForImagesThenSurfaceSi HWTEST2_F(BlitTests, givenLinearResourceInfoWithNotZeroPitchWhenAppendImageCommandsThenPitchEqualValueFromProperties, IsXeHpCore) { using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT; - auto gmm = std::make_unique(); + auto gmm = std::make_unique(pDevice->getGmmClientContext()); GMM_RESCREATE_PARAMS gmmParams = {}; auto myResourecInfo = std::make_unique(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams); myResourecInfo->pitch = 0x100; diff --git a/shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp b/shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp index 1aa54ab78d..50fde8a616 100644 --- a/shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp +++ b/shared/test/common/xe_hp_core/image_surface_state_tests_xe_hp_core.cpp @@ -17,12 +17,12 @@ XE_HP_CORE_TEST_F(ImageSurfaceStateTestsXeHpCore, givenGmmWithMediaCompressedWhe auto castSurfaceState = reinterpret_cast(surfaceState.get()); castSurfaceState->setAuxiliarySurfaceMode(FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), false); - mockGmm.gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; - EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; + EncodeSurfaceState::setFlagsForMediaCompression(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getAuxiliarySurfaceMode(), FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); EXPECT_EQ(castSurfaceState->getMemoryCompressionEnable(), true); } @@ -32,8 +32,8 @@ XE_HP_CORE_TEST_F(ImageSurfaceStateTestsXeHpCore, givenGmmWhenSetClearColorParam auto surfaceState = std::make_unique(size); auto castSurfaceState = reinterpret_cast(surfaceState.get()); - mockGmm.gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = true; - EncodeSurfaceState::setClearColorParams(castSurfaceState, &mockGmm); + mockGmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = true; + EncodeSurfaceState::setClearColorParams(castSurfaceState, mockGmm.get()); EXPECT_EQ(castSurfaceState->getClearValueAddressEnable(), true); } @@ -46,7 +46,7 @@ XE_HP_CORE_TEST_F(ImageSurfaceStateTestsXeHpCore, givenGmmWithMediaCompressedWhe EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u); - setMipTailStartLod(castSurfaceState, &mockGmm); + setMipTailStartLod(castSurfaceState, mockGmm.get()); - EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm.gmmResourceInfo->getMipTailStartLodSurfaceState()); + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm->gmmResourceInfo->getMipTailStartLodSurfaceState()); } diff --git a/shared/test/unit_test/CMakeLists.txt b/shared/test/unit_test/CMakeLists.txt index c84a668975..d63f5339e2 100644 --- a/shared/test/unit_test/CMakeLists.txt +++ b/shared/test/unit_test/CMakeLists.txt @@ -31,9 +31,7 @@ if(NOT SKIP_UNIT_TESTS) ${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/kernel_binary_helper_hash_value.cpp ${NEO_SOURCE_DIR}/opencl/test/unit_test/libult/create_command_stream.cpp ${NEO_SOURCE_DIR}/opencl/test/unit_test/libult/io_functions.cpp - ${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_platform.cpp ${NEO_SOURCE_DIR}/opencl/test/unit_test/test_macros/test_checks_ocl.cpp - ${NEO_SOURCE_DIR}/opencl/test/unit_test/ult_config_listener.cpp ${NEO_SHARED_DIRECTORY}/helpers/allow_deferred_deleter.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/helpers/api_specific_config_shared_tests.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/test_checks_shared.cpp diff --git a/shared/test/unit_test/image/image_surface_state_fixture.h b/shared/test/unit_test/image/image_surface_state_fixture.h index c998025442..c5421fd985 100644 --- a/shared/test/unit_test/image/image_surface_state_fixture.h +++ b/shared/test/unit_test/image/image_surface_state_fixture.h @@ -27,6 +27,7 @@ class ImageSurfaceStateTests : public DeviceFixture, ImageSurfaceStateTests() = default; void SetUp() override { DeviceFixture::SetUp(); + mockGmm = std::make_unique(pDevice->getGmmClientContext()); gmmHelper = pDevice->getGmmHelper(); } @@ -34,7 +35,7 @@ class ImageSurfaceStateTests : public DeviceFixture, DeviceFixture::TearDown(); } - MockGmm mockGmm; + std::unique_ptr mockGmm; GmmHelper *gmmHelper = nullptr; NEO::ImageInfo imageInfo; }; diff --git a/shared/test/unit_test/image/image_surface_state_tests.cpp b/shared/test/unit_test/image/image_surface_state_tests.cpp index f661a67eb2..3b1a819e52 100644 --- a/shared/test/unit_test/image/image_surface_state_tests.cpp +++ b/shared/test/unit_test/image/image_surface_state_tests.cpp @@ -36,7 +36,7 @@ HWTEST_F(ImageSurfaceStateTests, givenImageInfoWhenSetImageSurfaceStateThenPrope const uint64_t gpuAddress = 0x000001a78a8a8000; - setImageSurfaceState(castSurfaceState, imageInfo, &mockGmm, *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true); + setImageSurfaceState(castSurfaceState, imageInfo, mockGmm.get(), *gmmHelper, cubeFaceIndex, gpuAddress, surfaceOffsets, true); using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT; @@ -46,9 +46,9 @@ HWTEST_F(ImageSurfaceStateTests, givenImageInfoWhenSetImageSurfaceStateThenPrope EXPECT_EQ(castSurfaceState->getMinimumArrayElement(), cubeFaceIndex); EXPECT_EQ(castSurfaceState->getSurfaceQpitch(), imageInfo.qPitch >> RENDER_SURFACE_STATE::tagSURFACEQPITCH::SURFACEQPITCH_BIT_SHIFT); EXPECT_EQ(castSurfaceState->getSurfaceArray(), true); - EXPECT_EQ(castSurfaceState->getSurfaceHorizontalAlignment(), static_cast(mockGmm.gmmResourceInfo->getHAlignSurfaceState())); - EXPECT_EQ(castSurfaceState->getSurfaceVerticalAlignment(), static_cast(mockGmm.gmmResourceInfo->getVAlignSurfaceState())); - EXPECT_EQ(castSurfaceState->getTileMode(), mockGmm.gmmResourceInfo->getTileModeSurfaceState()); + EXPECT_EQ(castSurfaceState->getSurfaceHorizontalAlignment(), static_cast(mockGmm->gmmResourceInfo->getHAlignSurfaceState())); + EXPECT_EQ(castSurfaceState->getSurfaceVerticalAlignment(), static_cast(mockGmm->gmmResourceInfo->getVAlignSurfaceState())); + EXPECT_EQ(castSurfaceState->getTileMode(), mockGmm->gmmResourceInfo->getTileModeSurfaceState()); EXPECT_EQ(castSurfaceState->getMemoryObjectControlState(), gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE)); EXPECT_EQ(castSurfaceState->getCoherencyType(), RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT); EXPECT_EQ(castSurfaceState->getMultisampledSurfaceStorageFormat(), RENDER_SURFACE_STATE::MULTISAMPLED_SURFACE_STORAGE_FORMAT::MULTISAMPLED_SURFACE_STORAGE_FORMAT_MSS); @@ -101,8 +101,8 @@ HWTEST_F(ImageSurfaceStateTests, givenGmmWhenSetAuxParamsForCCSThenAuxiliarySurf auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); auto surfaceState = std::make_unique(size); auto castSurfaceState = reinterpret_cast(surfaceState.get()); - EncodeSurfaceState::setImageAuxParamsForCCS(castSurfaceState, &mockGmm); + EncodeSurfaceState::setImageAuxParamsForCCS(castSurfaceState, mockGmm.get()); - mockGmm.isCompressionEnabled = true; - EXPECT_TRUE(EncodeSurfaceState::isAuxModeEnabled(castSurfaceState, &mockGmm)); + mockGmm->isCompressionEnabled = true; + EXPECT_TRUE(EncodeSurfaceState::isAuxModeEnabled(castSurfaceState, mockGmm.get())); } \ No newline at end of file diff --git a/shared/test/unit_test/main.cpp b/shared/test/unit_test/main.cpp index 0a0fe3716e..7a33eb4a9a 100644 --- a/shared/test/unit_test/main.cpp +++ b/shared/test/unit_test/main.cpp @@ -20,13 +20,13 @@ #include "shared/test/common/mocks/mock_gmm_client_context.h" #include "shared/test/common/mocks/mock_sip.h" #include "shared/test/common/test_macros/test_checks_shared.h" +#include "shared/test/unit_test/base_ult_config_listener.h" #include "shared/test/unit_test/tests_configuration.h" #include "opencl/source/os_interface/ocl_reg_path.h" #include "opencl/test/unit_test/helpers/kernel_binary_helper.h" #include "opencl/test/unit_test/mocks/mock_gmm.h" #include "opencl/test/unit_test/mocks/mock_program.h" -#include "opencl/test/unit_test/ult_config_listener.h" #include "gmock/gmock.h" @@ -75,8 +75,6 @@ extern std::string lastTest; bool generateRandomInput = false; void applyWorkarounds() { - platformsImpl = new std::vector>; - platformsImpl->reserve(1); { std::ofstream f; const std::string fileName("_tmp_"); @@ -381,7 +379,7 @@ int main(int argc, char **argv) { } listeners.Append(new MemoryLeakListener); - listeners.Append(new UltConfigListener); + listeners.Append(new BaseUltConfigListener); gEnvironment = reinterpret_cast(::testing::AddGlobalTestEnvironment(new TestEnvironment)); @@ -451,7 +449,5 @@ int main(int argc, char **argv) { retVal = RUN_ALL_TESTS(); - delete platformsImpl; - return retVal; } diff --git a/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp b/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp index b0e01224b4..172ad7f23e 100644 --- a/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp +++ b/shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp @@ -35,8 +35,9 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnC getMemoryOperationsHandler()->setAubManager(&aubManager); auto memoryOperationsInterface = getMemoryOperationsHandler(); - - MockGmm gmm; + auto executionEnvironment = std::unique_ptr(MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u)); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + MockGmm gmm(executionEnvironment->rootDeviceEnvironments[0]->getGmmClientContext()); gmm.isCompressionEnabled = true; allocPtr->setDefaultGmm(&gmm); diff --git a/shared/test/unit_test/preemption/preemption_tests.cpp b/shared/test/unit_test/preemption/preemption_tests.cpp index 203695203f..48fee3e481 100644 --- a/shared/test/unit_test/preemption/preemption_tests.cpp +++ b/shared/test/unit_test/preemption/preemption_tests.cpp @@ -19,7 +19,6 @@ #include "opencl/test/unit_test/libult/ult_command_stream_receiver.h" #include "opencl/test/unit_test/mocks/mock_builtins.h" #include "opencl/test/unit_test/mocks/mock_kernel.h" -#include "opencl/test/unit_test/mocks/mock_platform.h" #include "gmock/gmock.h" @@ -275,7 +274,7 @@ HWTEST_F(MidThreadPreemptionTests, givenMidThreadPreemptionWhenFailingOnCsrSurfa uint32_t allocateGraphicsMemoryCount = 0; }; - ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); + ExecutionEnvironment *executionEnvironment = MockDevice::prepareExecutionEnvironment(nullptr, 0u); executionEnvironment->memoryManager = std::make_unique(*executionEnvironment); if (executionEnvironment->memoryManager.get()->isLimitedGPU(0)) { GTEST_SKIP();