2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-12-31 21:56:03 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-11-02 22:54:01 +08:00
|
|
|
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
2021-10-21 22:50:10 +08:00
|
|
|
#include "shared/test/common/fixtures/memory_management_fixture.h"
|
2021-08-12 01:36:00 +08:00
|
|
|
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2021-10-05 20:54:33 +08:00
|
|
|
#include "shared/test/common/mocks/mock_memory_manager.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class MemoryAllocatorFixture : public MemoryManagementFixture {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
|
|
|
MemoryManagementFixture::SetUp();
|
2019-11-05 20:38:20 +08:00
|
|
|
executionEnvironment = new ExecutionEnvironment();
|
2019-11-15 16:59:48 +08:00
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
2020-03-25 00:04:08 +08:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2022-06-08 16:23:02 +08:00
|
|
|
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
|
|
|
|
|
2020-03-25 00:04:08 +08:00
|
|
|
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0u));
|
2018-12-21 17:16:27 +08:00
|
|
|
memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
2018-10-01 22:10:54 +08:00
|
|
|
executionEnvironment->memoryManager.reset(memoryManager);
|
2019-11-05 20:38:20 +08:00
|
|
|
csr = &device->getGpgpuCommandStreamReceiver();
|
2020-02-21 22:25:04 +08:00
|
|
|
auto &hwInfo = device->getHardwareInfo();
|
2020-09-15 23:29:02 +08:00
|
|
|
auto engineType = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo)[0].first;
|
2021-08-12 01:36:00 +08:00
|
|
|
auto osContext = memoryManager->createAndRegisterOsContext(csr, EngineDescriptorHelper::getDefaultDescriptor({engineType, EngineUsage::Regular},
|
|
|
|
PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo)));
|
2019-02-18 20:59:16 +08:00
|
|
|
csr->setupContext(*osContext);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2019-11-05 20:38:20 +08:00
|
|
|
device.reset();
|
2017-12-21 07:45:38 +08:00
|
|
|
MemoryManagementFixture::TearDown();
|
|
|
|
}
|
2018-10-01 22:04:12 +08:00
|
|
|
|
|
|
|
protected:
|
2019-11-05 20:38:20 +08:00
|
|
|
std::unique_ptr<MockDevice> device;
|
|
|
|
ExecutionEnvironment *executionEnvironment;
|
2019-10-22 19:29:39 +08:00
|
|
|
MockMemoryManager *memoryManager = nullptr;
|
|
|
|
CommandStreamReceiver *csr = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|