mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Move memory fixtures to shared
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
997d28f6b2
commit
0cbc320e57
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# Copyright (C) 2018-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@ -32,10 +32,6 @@ set(IGDRCL_SRCS_tests_fixtures
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_data_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_work_group_info_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/media_kernel_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_multi_device_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_fixture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/multi_root_device_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/multi_tile_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/one_mip_level_image_fixture.h
|
||||
|
@ -1,15 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(IGDRCL_SRCS_tests_fixtures_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_multi_device_fixture_linux.cpp
|
||||
)
|
||||
if(UNIX)
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_fixtures_linux})
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY IGDRCL_SRCS_tests_fixtures_linux ${IGDRCL_SRCS_tests_fixtures_linux})
|
||||
add_subdirectories()
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/memory_allocator_multi_device_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment &executionEnvironment) {
|
||||
auto memoryManager = static_cast<TestedDrmMemoryManager *>(executionEnvironment.memoryManager.get());
|
||||
auto bufferObject = new (std::nothrow) BufferObject(&memoryManager->getDrm(0u), 0, 10, MemoryManager::maxOsContextCount);
|
||||
memoryManager->pushSharedBufferObject(bufferObject);
|
||||
}
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::TearDown(ExecutionEnvironment &executionEnvironment) {
|
||||
auto memoryManager = static_cast<TestedDrmMemoryManager *>(executionEnvironment.memoryManager.get());
|
||||
auto bufferObject = memoryManager->sharingBufferObjects.back();
|
||||
memoryManager->eraseSharedBufferObject(bufferObject);
|
||||
delete bufferObject;
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "shared/test/common/fixtures/memory_management_fixture.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
using namespace NEO;
|
||||
|
||||
class MemoryAllocatorFixture : public MemoryManagementFixture {
|
||||
public:
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
executionEnvironment = new ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0u));
|
||||
memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
csr = &device->getGpgpuCommandStreamReceiver();
|
||||
auto &hwInfo = device->getHardwareInfo();
|
||||
auto engineType = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo)[0].first;
|
||||
auto osContext = memoryManager->createAndRegisterOsContext(csr, EngineDescriptorHelper::getDefaultDescriptor({engineType, EngineUsage::Regular},
|
||||
PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo)));
|
||||
csr->setupContext(*osContext);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
device.reset();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<MockDevice> device;
|
||||
ExecutionEnvironment *executionEnvironment;
|
||||
MockMemoryManager *memoryManager = nullptr;
|
||||
CommandStreamReceiver *csr = nullptr;
|
||||
};
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/test/common/fixtures/memory_management_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/ult_hw_config.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MemoryAllocatorMultiDeviceSystemSpecificFixture {
|
||||
public:
|
||||
void SetUp(ExecutionEnvironment &executionEnvironment);
|
||||
void TearDown(ExecutionEnvironment &executionEnvironment);
|
||||
|
||||
std::unique_ptr<Gmm> gmm;
|
||||
};
|
||||
|
||||
template <uint32_t numRootDevices>
|
||||
class MemoryAllocatorMultiDeviceFixture : public MemoryManagementFixture, public MemoryAllocatorMultiDeviceSystemSpecificFixture, public ::testing::TestWithParam<bool> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
|
||||
isOsAgnosticMemoryManager = GetParam();
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
ultHwConfig.forceOsAgnosticMemoryManager = isOsAgnosticMemoryManager;
|
||||
|
||||
initPlatform();
|
||||
executionEnvironment = platform()->peekExecutionEnvironment();
|
||||
memoryManager = executionEnvironment->memoryManager.get();
|
||||
|
||||
if (!isOsAgnosticMemoryManager) {
|
||||
MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(*executionEnvironment);
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!isOsAgnosticMemoryManager) {
|
||||
MemoryAllocatorMultiDeviceSystemSpecificFixture::TearDown(*executionEnvironment);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getNumRootDevices() { return numRootDevices; }
|
||||
|
||||
protected:
|
||||
ExecutionEnvironment *executionEnvironment = nullptr;
|
||||
MemoryManager *memoryManager = nullptr;
|
||||
DebugManagerStateRestore restorer;
|
||||
bool isOsAgnosticMemoryManager;
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/memory_manager_fixture.h"
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/mocks/mock_csr.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryManagerWithCsrFixture::SetUp() {
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
csr = std::make_unique<MockCommandStreamReceiver>(this->executionEnvironment, 0, 1);
|
||||
memoryManager = new MockMemoryManager(executionEnvironment);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
csr->tagAddress = ¤tGpuTag;
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
auto engine = HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
|
||||
auto osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor({engine.first, EngineUsage::Regular},
|
||||
PreemptionHelper::getDefaultPreemptionMode(*hwInfo)));
|
||||
csr->setupContext(*osContext);
|
||||
}
|
||||
|
||||
void MemoryManagerWithCsrFixture::TearDown() {
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/helpers/options.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MockCommandStreamReceiver;
|
||||
namespace NEO {
|
||||
class MockMemoryManager;
|
||||
}; // namespace NEO
|
||||
|
||||
class MemoryManagerWithCsrFixture {
|
||||
public:
|
||||
MockMemoryManager *memoryManager;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<MockCommandStreamReceiver> csr;
|
||||
uint32_t taskCount = 0;
|
||||
uint32_t currentGpuTag = initialHardwareTag;
|
||||
|
||||
~MemoryManagerWithCsrFixture() = default;
|
||||
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
@ -1,15 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(IGDRCL_SRCS_tests_fixtures_windows
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_multi_device_fixture_windows.cpp
|
||||
)
|
||||
if(WIN32)
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_fixtures_windows})
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY IGDRCL_SRCS_tests_fixtures_windows ${IGDRCL_SRCS_tests_fixtures_windows})
|
||||
add_subdirectories()
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/gmm_helper/resource_info.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/os_environment_win.h"
|
||||
#include "shared/test/common/mock_gdi/mock_gdi.h"
|
||||
#include "shared/test/common/mocks/mock_wddm.h"
|
||||
#include "shared/test/unit_test/os_interface/windows/mock_gdi_interface.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/memory_allocator_multi_device_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::SetUp(ExecutionEnvironment &executionEnvironment) {
|
||||
static D3DDDI_OPENALLOCATIONINFO allocationInfo;
|
||||
auto gdi = new MockGdi();
|
||||
gdi->getQueryResourceInfoArgOut().NumAllocations = 1;
|
||||
gdi->getOpenResourceArgOut().pOpenAllocationInfo = &allocationInfo;
|
||||
auto osEnvironment = new OsEnvironmentWin();
|
||||
osEnvironment->gdi.reset(gdi);
|
||||
for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) {
|
||||
gmm = std::make_unique<Gmm>(executionEnvironment.rootDeviceEnvironments[i]->getGmmClientContext(), nullptr, 0, 0, false);
|
||||
auto wddm = static_cast<WddmMock *>(executionEnvironment.rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<Wddm>());
|
||||
wddm->hwDeviceId = std::make_unique<HwDeviceIdWddm>(ADAPTER_HANDLE, LUID{}, osEnvironment, std::make_unique<UmKmDataTranslator>());
|
||||
wddm->callBaseMapGpuVa = false;
|
||||
|
||||
allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
|
||||
allocationInfo.hAllocation = ALLOCATION_HANDLE;
|
||||
allocationInfo.PrivateDriverDataSize = sizeof(GMM_RESOURCE_INFO);
|
||||
}
|
||||
executionEnvironment.osEnvironment.reset(osEnvironment);
|
||||
}
|
||||
|
||||
void MemoryAllocatorMultiDeviceSystemSpecificFixture::TearDown(ExecutionEnvironment &executionEnvironment) {}
|
Reference in New Issue
Block a user