Reverse logic of creating Memory Manager - part 2
-remove MM initialization from Device::CreateEngines method Change-Id: Iaee268b002cb0f0a4edd07907c12da6dd6076b3a Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
parent
8e49c8f67a
commit
4386d10e40
|
@ -164,15 +164,12 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo) {
|
||||||
|
|
||||||
bool Device::createEngines(const HardwareInfo *pHwInfo) {
|
bool Device::createEngines(const HardwareInfo *pHwInfo) {
|
||||||
auto defaultEngineType = getChosenEngineType(*pHwInfo);
|
auto defaultEngineType = getChosenEngineType(*pHwInfo);
|
||||||
auto &hwHelper = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily);
|
auto &gpgpuEngines = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances();
|
||||||
auto &gpgpuEngines = hwHelper.getGpgpuEngineInstances();
|
|
||||||
auto enableLocalMemory = hwHelper.getEnableLocalMemory(*pHwInfo);
|
|
||||||
|
|
||||||
for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngines.size(); deviceCsrIndex++) {
|
for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngines.size(); deviceCsrIndex++) {
|
||||||
if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, getDeviceIndex(), deviceCsrIndex)) {
|
if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, getDeviceIndex(), deviceCsrIndex)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
executionEnvironment->initializeMemoryManager(getEnabled64kbPages(), enableLocalMemory);
|
|
||||||
|
|
||||||
auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[getDeviceIndex()][deviceCsrIndex].get();
|
auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[getDeviceIndex()][deviceCsrIndex].get();
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
using namespace OCLRT;
|
using namespace OCLRT;
|
||||||
|
|
||||||
TEST(CheckVerifyMemoryRelatedApiConstants, givenVerifyMemoryRelatedApiConstantsWhenVerifyingTheirValueThenCorrectValuesAreReturned) {
|
TEST(CheckVerifyMemoryRelatedApiConstants, givenVerifyMemoryRelatedApiConstantsWhenVerifyingTheirValueThenCorrectValuesAreReturned) {
|
||||||
EXPECT_EQ(CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual, CL_MEM_COMPARE_EQUAL);
|
EXPECT_EQ(AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual, CL_MEM_COMPARE_EQUAL);
|
||||||
EXPECT_EQ(CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual, CL_MEM_COMPARE_NOT_EQUAL);
|
EXPECT_EQ(AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual, CL_MEM_COMPARE_NOT_EQUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct clEnqueueVerifyMemorySettings {
|
struct clEnqueueVerifyMemorySettings {
|
||||||
|
|
|
@ -49,12 +49,10 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo
|
||||||
|
|
||||||
if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) {
|
if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) {
|
||||||
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
|
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
|
||||||
executionEnvironment->initializeMemoryManager(false, false);
|
|
||||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager.get());
|
|
||||||
} else {
|
} else {
|
||||||
EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
|
EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
|
||||||
EXPECT_EQ(nullptr, executionEnvironment->memoryManager.get());
|
|
||||||
}
|
}
|
||||||
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
static CommandStreamReceiverType commandStreamReceiverTypes[] = {
|
static CommandStreamReceiverType commandStreamReceiverTypes[] = {
|
||||||
|
|
|
@ -159,8 +159,8 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqu
|
||||||
const size_t numDevices = 2;
|
const size_t numDevices = 2;
|
||||||
const auto &numGpgpuEngines = static_cast<uint32_t>(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size());
|
const auto &numGpgpuEngines = static_cast<uint32_t>(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size());
|
||||||
|
|
||||||
auto device1 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 0u));
|
auto device1 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
|
||||||
auto device2 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 1u));
|
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
|
||||||
|
|
||||||
auto ®isteredEngines = executionEnvironment.memoryManager->getRegisteredEngines();
|
auto ®isteredEngines = executionEnvironment.memoryManager->getRegisteredEngines();
|
||||||
EXPECT_EQ(numGpgpuEngines * numDevices, registeredEngines.size());
|
EXPECT_EQ(numGpgpuEngines * numDevices, registeredEngines.size());
|
||||||
|
@ -182,8 +182,8 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqu
|
||||||
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
|
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
|
||||||
ExecutionEnvironment executionEnvironment;
|
ExecutionEnvironment executionEnvironment;
|
||||||
executionEnvironment.incRefInternal();
|
executionEnvironment.incRefInternal();
|
||||||
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 0u));
|
auto device = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
|
||||||
auto device2 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 1u));
|
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
|
||||||
|
|
||||||
EXPECT_EQ(0u, device->getDeviceIndex());
|
EXPECT_EQ(0u, device->getDeviceIndex());
|
||||||
EXPECT_EQ(1u, device2->getDeviceIndex());
|
EXPECT_EQ(1u, device2->getDeviceIndex());
|
||||||
|
|
|
@ -104,6 +104,7 @@ TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManage
|
||||||
TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillAvailable) {
|
TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillAvailable) {
|
||||||
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
|
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
|
||||||
executionEnvironment->incRefInternal();
|
executionEnvironment->incRefInternal();
|
||||||
|
executionEnvironment->initializeMemoryManager(false, false);
|
||||||
std::unique_ptr<Device> device(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 0u));
|
std::unique_ptr<Device> device(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 0u));
|
||||||
device.reset(nullptr);
|
device.reset(nullptr);
|
||||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include "unit_tests/helpers/execution_environment_helper.h"
|
#include "unit_tests/helpers/execution_environment_helper.h"
|
||||||
|
|
||||||
|
#include "runtime/device/device.h"
|
||||||
|
#include "runtime/helpers/hw_helper.h"
|
||||||
#include "runtime/os_interface/device_factory.h"
|
#include "runtime/os_interface/device_factory.h"
|
||||||
|
|
||||||
namespace OCLRT {
|
namespace OCLRT {
|
||||||
|
@ -16,6 +18,9 @@ ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo) {
|
||||||
size_t numDevicesReturned = 0;
|
size_t numDevicesReturned = 0;
|
||||||
hwInfo = nullptr;
|
hwInfo = nullptr;
|
||||||
DeviceFactory::getDevices(&hwInfo, numDevicesReturned, *executionEnvironment);
|
DeviceFactory::getDevices(&hwInfo, numDevicesReturned, *executionEnvironment);
|
||||||
|
bool enableLocalMemory = HwHelper::get(hwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
|
||||||
|
executionEnvironment->initializeMemoryManager(Device::getEnabled64kbPages(*hwInfo), enableLocalMemory);
|
||||||
|
|
||||||
return executionEnvironment;
|
return executionEnvironment;
|
||||||
}
|
}
|
||||||
} // namespace OCLRT
|
} // namespace OCLRT
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "unit_tests/mocks/mock_device.h"
|
#include "unit_tests/mocks/mock_device.h"
|
||||||
|
|
||||||
#include "runtime/device/driver_info.h"
|
#include "runtime/device/driver_info.h"
|
||||||
#include "runtime/helpers/hw_helper.h"
|
|
||||||
#include "runtime/os_interface/os_context.h"
|
#include "runtime/os_interface/os_context.h"
|
||||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||||
#include "unit_tests/mocks/mock_ostime.h"
|
#include "unit_tests/mocks/mock_ostime.h"
|
||||||
|
@ -33,6 +32,7 @@ MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executi
|
||||||
this->mockMemoryManager.reset(new OsAgnosticMemoryManager(false, enableLocalMemory, aubUsage, *executionEnvironment));
|
this->mockMemoryManager.reset(new OsAgnosticMemoryManager(false, enableLocalMemory, aubUsage, *executionEnvironment));
|
||||||
this->osTime = MockOSTime::create();
|
this->osTime = MockOSTime::create();
|
||||||
mockWaTable = *hwInfo.pWaTable;
|
mockWaTable = *hwInfo.pWaTable;
|
||||||
|
executionEnvironment->initializeMemoryManager(getEnabled64kbPages(hwInfo), enableLocalMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockDevice::setOSTime(OSTime *osTime) {
|
void MockDevice::setOSTime(OSTime *osTime) {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "runtime/device/device.h"
|
#include "runtime/device/device.h"
|
||||||
|
#include "runtime/helpers/hw_helper.h"
|
||||||
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
||||||
#include "unit_tests/mocks/mock_allocation_properties.h"
|
#include "unit_tests/mocks/mock_allocation_properties.h"
|
||||||
|
|
||||||
|
@ -113,7 +114,17 @@ class MockDevice : public Device {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const HardwareInfo *pHwInfo) {
|
inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const HardwareInfo *pHwInfo) {
|
||||||
return Device::create<Device>(pHwInfo, new ExecutionEnvironment, 0u);
|
auto executionEnvironment = new ExecutionEnvironment();
|
||||||
|
|
||||||
|
bool enableLocalMemory = false;
|
||||||
|
bool enable64kbPages = false;
|
||||||
|
if (pHwInfo != nullptr) {
|
||||||
|
enableLocalMemory = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*pHwInfo);
|
||||||
|
enable64kbPages = getEnabled64kbPages(*pHwInfo);
|
||||||
|
}
|
||||||
|
executionEnvironment->initializeMemoryManager(enable64kbPages, enableLocalMemory);
|
||||||
|
|
||||||
|
return Device::create<Device>(pHwInfo, executionEnvironment, 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
class FailDevice : public MockDevice {
|
class FailDevice : public MockDevice {
|
||||||
|
|
|
@ -531,12 +531,12 @@ TEST(SourceLevelDebugger, givenTwoDevicesWhenSecondIsCreatedThenNotCreatingNewSo
|
||||||
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
|
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
|
||||||
executionEnvironment->incRefInternal();
|
executionEnvironment->incRefInternal();
|
||||||
|
|
||||||
std::unique_ptr<Device> device1(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 0u));
|
std::unique_ptr<Device> device1(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment.get(), 0u));
|
||||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
||||||
EXPECT_TRUE(interceptor.initCalled);
|
EXPECT_TRUE(interceptor.initCalled);
|
||||||
|
|
||||||
interceptor.initCalled = false;
|
interceptor.initCalled = false;
|
||||||
std::unique_ptr<Device> device2(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 1u));
|
std::unique_ptr<Device> device2(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment.get(), 1u));
|
||||||
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
||||||
EXPECT_FALSE(interceptor.initCalled);
|
EXPECT_FALSE(interceptor.initCalled);
|
||||||
}
|
}
|
||||||
|
@ -550,9 +550,9 @@ TEST(SourceLevelDebugger, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheS
|
||||||
DebuggerLibrary::setDebuggerActive(true);
|
DebuggerLibrary::setDebuggerActive(true);
|
||||||
|
|
||||||
auto executionEnvironment = new ExecutionEnvironment;
|
auto executionEnvironment = new ExecutionEnvironment;
|
||||||
std::unique_ptr<Device> device1(Device::create<OCLRT::Device>(nullptr, executionEnvironment, 0u));
|
std::unique_ptr<Device> device1(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 0u));
|
||||||
auto sourceLevelDebugger = device1->getSourceLevelDebugger();
|
auto sourceLevelDebugger = device1->getSourceLevelDebugger();
|
||||||
std::unique_ptr<Device> device2(Device::create<OCLRT::Device>(nullptr, executionEnvironment, 1u));
|
std::unique_ptr<Device> device2(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 1u));
|
||||||
EXPECT_EQ(sourceLevelDebugger, device2->getSourceLevelDebugger());
|
EXPECT_EQ(sourceLevelDebugger, device2->getSourceLevelDebugger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue