mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
test: allocate sip allocation for all contexts in initSipKernel
- some tests initialize sip kernel but do not free it - this is causing memory leaks - as a solution mock sip listener is added that will release allocated sip kernel Related-To: NEO-13789 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
df39f27334
commit
850e6c02eb
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2021-2024 Intel Corporation
|
||||
# Copyright (C) 2021-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -14,6 +14,7 @@ if(NOT NEO_SKIP_AUB_TESTS AND DEFINED AUB_STREAM_PROJECT_NAME)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_hello_world_test.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/common_main.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/mock_sip_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/tests_configuration.h
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020-2024 Intel Corporation
|
||||
# Copyright (C) 2020-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -28,6 +28,7 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/white_box.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/common_main.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/mock_sip_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/tests_configuration.h
|
||||
${NEO_SOURCE_DIR}/level_zero/core/test/common/test_modules/gen_kernel.cmake
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2023-2024 Intel Corporation
|
||||
# Copyright (C) 2023-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -32,6 +32,7 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${NEO_SOURCE_DIR}/level_zero/core/source/dll/create_builtin_functions_lib.cpp
|
||||
${NEO_SOURCE_DIR}/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/common_main.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/mock_sip_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/tests_configuration.h
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020-2024 Intel Corporation
|
||||
# Copyright (C) 2020-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -32,6 +32,7 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/sources/builtin/create_ult_builtin_functions_lib.cpp
|
||||
${NEO_SOURCE_DIR}/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/common_main.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/mock_sip_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/tests_configuration.h
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018-2024 Intel Corporation
|
||||
# Copyright (C) 2018-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -37,6 +37,7 @@ set(IGDRCL_SRCS_LIB_ULT_ENV
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_queue_ult.cpp
|
||||
${NEO_SOURCE_DIR}/shared/test/common/helpers/custom_event_listener.h
|
||||
${NEO_SOURCE_DIR}/shared/test/common/common_main.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/mock_sip_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/command_queue/command_queue_fixture.cpp
|
||||
${NEO_SOURCE_DIR}/opencl/test/unit_test/command_queue/command_queue_fixture.h
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "shared/test/common/helpers/default_hw_info.inl"
|
||||
#include "shared/test/common/helpers/kernel_binary_helper.h"
|
||||
#include "shared/test/common/helpers/memory_leak_listener.h"
|
||||
#include "shared/test/common/helpers/mock_sip_listener.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/helpers/ult_hw_config.inl"
|
||||
#include "shared/test/common/helpers/virtual_file_system_listener.h"
|
||||
@@ -387,6 +388,7 @@ int main(int argc, char **argv) {
|
||||
listeners.Append(customEventListener);
|
||||
}
|
||||
|
||||
listeners.Append(new MockSipListener);
|
||||
listeners.Append(new MemoryLeakListener);
|
||||
listeners.Append(new NEO::VirtualFileSystemListener);
|
||||
|
||||
|
||||
25
shared/test/common/helpers/mock_sip_listener.cpp
Normal file
25
shared/test/common/helpers/mock_sip_listener.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/mock_sip_listener.h"
|
||||
|
||||
#include "shared/source/memory_manager/memory_allocation.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void MockSipListener::OnTestEnd(const testing::TestInfo &) {
|
||||
if (MockSipData::mockSipKernel) {
|
||||
if (MockSipData::mockSipKernel->tempSipMemoryAllocation) {
|
||||
printf("*** WARNING: test did not free sip kernels ***\n");
|
||||
MockSipData::mockSipKernel->tempSipMemoryAllocation.reset(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
31
shared/test/common/helpers/mock_sip_listener.h
Normal file
31
shared/test/common/helpers/mock_sip_listener.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MockSipListener : public ::testing::TestEventListener {
|
||||
private:
|
||||
void OnTestStart(const testing::TestInfo &) override{};
|
||||
void OnTestEnd(const testing::TestInfo &) override;
|
||||
|
||||
void OnTestProgramStart(const testing::UnitTest &) override{};
|
||||
void OnTestIterationStart(const testing::UnitTest &, int) override{};
|
||||
void OnEnvironmentsSetUpStart(const testing::UnitTest &) override{};
|
||||
void OnEnvironmentsSetUpEnd(const testing::UnitTest &) override{};
|
||||
void OnTestPartResult(const testing::TestPartResult &) override{};
|
||||
void OnEnvironmentsTearDownStart(const testing::UnitTest &) override{};
|
||||
void OnEnvironmentsTearDownEnd(const testing::UnitTest &) override{};
|
||||
void OnTestIterationEnd(const testing::UnitTest &, int) override{};
|
||||
void OnTestProgramEnd(const testing::UnitTest &) override{};
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
@@ -237,6 +237,8 @@ bool SipKernel::initSipKernel(SipKernelType type, Device &device) {
|
||||
MockSipData::called = true;
|
||||
|
||||
MockSipData::mockSipKernel->mockSipMemoryAllocation->clearUsageInfo();
|
||||
MockSipData::mockSipKernel->createTempSipAllocation(MemoryManager::maxOsContextCount);
|
||||
|
||||
return MockSipData::returned;
|
||||
} else {
|
||||
return SipKernel::initSipKernelImpl(type, device, nullptr);
|
||||
@@ -244,6 +246,11 @@ bool SipKernel::initSipKernel(SipKernelType type, Device &device) {
|
||||
}
|
||||
|
||||
void SipKernel::freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager) {
|
||||
|
||||
if (MockSipData::mockSipKernel) {
|
||||
MockSipData::mockSipKernel->tempSipMemoryAllocation.reset(nullptr);
|
||||
}
|
||||
|
||||
for (auto &sipKernel : rootDeviceEnvironment->sipKernels) {
|
||||
if (sipKernel.get()) {
|
||||
memoryManager->freeGraphicsMemory(sipKernel->getSipAllocation());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -31,6 +31,9 @@ std::vector<char> MockSipKernel::getDummyGenBinary() {
|
||||
}
|
||||
|
||||
GraphicsAllocation *MockSipKernel::getSipAllocation() const {
|
||||
if (tempSipMemoryAllocation) {
|
||||
return tempSipMemoryAllocation.get();
|
||||
}
|
||||
return mockSipMemoryAllocation.get();
|
||||
}
|
||||
|
||||
@@ -50,5 +53,17 @@ void MockSipKernel::createMockSipAllocation() {
|
||||
MemoryPool::system4KBPages,
|
||||
256u);
|
||||
}
|
||||
void MockSipKernel::createTempSipAllocation(size_t osContextCount) {
|
||||
this->tempSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
1u /*num gmms*/,
|
||||
AllocationType::kernelIsaInternal,
|
||||
nullptr,
|
||||
MemoryConstants::pageSize * 10u,
|
||||
0u,
|
||||
MemoryConstants::pageSize,
|
||||
MemoryPool::system4KBPages,
|
||||
osContextCount);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -32,8 +32,10 @@ class MockSipKernel : public SipKernel {
|
||||
const std::vector<char> &getStateSaveAreaHeader() const override;
|
||||
|
||||
void createMockSipAllocation();
|
||||
void createTempSipAllocation(size_t osContextCount);
|
||||
|
||||
std::unique_ptr<MemoryAllocation> mockSipMemoryAllocation;
|
||||
std::unique_ptr<MemoryAllocation> tempSipMemoryAllocation;
|
||||
std::vector<char> mockStateSaveAreaHeader = {'s', 's', 'a', 'h'};
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2019-2024 Intel Corporation
|
||||
# Copyright (C) 2019-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -21,6 +21,7 @@ add_executable(neo_shared_tests
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_specific_config.cpp
|
||||
${NEO_SHARED_DIRECTORY}/helpers/allow_deferred_deleter.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/common_main.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/mock_sip_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/virtual_file_system_listener.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/tests_configuration.h
|
||||
$<TARGET_OBJECTS:mock_aubstream>
|
||||
|
||||
Reference in New Issue
Block a user