L0Debug - capture SurfaceState heaps

Related-To: NEO-7103

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2022-06-24 11:45:34 +00:00
committed by Compute-Runtime-Automation
parent 94f3e54261
commit 31dbc04f23
5 changed files with 53 additions and 7 deletions

View File

@ -17,6 +17,7 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_usage_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_allocate_in_device_pool_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_multi_device_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_pool_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/multi_graphics_allocation_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/page_table_tests.cpp

View File

@ -0,0 +1,21 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(MemoryManagerTest, WhenCallingIsAllocationTypeToCaptureThenScratchAndPrivateTypesReturnTrue) {
MockMemoryManager mockMemoryManager;
EXPECT_TRUE(mockMemoryManager.isAllocationTypeToCapture(AllocationType::SCRATCH_SURFACE));
EXPECT_TRUE(mockMemoryManager.isAllocationTypeToCapture(AllocationType::PRIVATE_SURFACE));
EXPECT_TRUE(mockMemoryManager.isAllocationTypeToCapture(AllocationType::LINEAR_STREAM));
EXPECT_TRUE(mockMemoryManager.isAllocationTypeToCapture(AllocationType::INTERNAL_HEAP));
}

View File

@ -3421,6 +3421,35 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenFreeingThenRegisteredHandle
EXPECT_EQ(1u, mockDrm->unregisterCalledCount);
}
TEST(DrmMemoryManager, givenEnabledResourceRegistrationWhenSshIsAllocatedThenItIsMarkedForCapture) {
auto executionEnvironment = new MockExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1u);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockDrm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mockDrm, 0u);
executionEnvironment->memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
mockDrm->classHandles.push_back(i);
}
EXPECT_TRUE(mockDrm->resourceRegistrationEnabled());
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
CommandContainer cmdContainer;
cmdContainer.initialize(device.get(), nullptr, true);
auto *ssh = cmdContainer.getIndirectHeap(NEO::HeapType::SURFACE_STATE);
auto bo = static_cast<DrmAllocation *>(ssh->getGraphicsAllocation())->getBO();
ASSERT_NE(nullptr, bo);
EXPECT_TRUE(bo->isMarkedForCapture());
}
TEST(DrmMemoryManager, givenNullBoWhenRegisteringBindExtHandleThenEarlyReturn) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1u);