2018-06-22 18:54:33 +08:00
|
|
|
/*
|
2019-01-10 20:57:40 +08:00
|
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2018-06-22 18:54:33 +08:00
|
|
|
|
2019-07-15 19:51:08 +08:00
|
|
|
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
2019-09-11 15:26:24 +08:00
|
|
|
#include "core/unit_tests/utilities/destructor_counted.h"
|
2018-11-11 05:25:48 +08:00
|
|
|
#include "runtime/aub/aub_center.h"
|
2018-08-22 16:29:37 +08:00
|
|
|
#include "runtime/built_ins/built_ins.h"
|
2019-02-27 00:52:31 +08:00
|
|
|
#include "runtime/command_stream/preemption.h"
|
2018-08-22 16:29:37 +08:00
|
|
|
#include "runtime/compiler_interface/compiler_interface.h"
|
2018-06-27 17:35:37 +08:00
|
|
|
#include "runtime/device/device.h"
|
2018-06-22 18:54:33 +08:00
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2018-07-16 23:11:43 +08:00
|
|
|
#include "runtime/gmm_helper/gmm_helper.h"
|
2019-01-10 20:57:40 +08:00
|
|
|
#include "runtime/helpers/hw_helper.h"
|
2018-07-13 13:42:18 +08:00
|
|
|
#include "runtime/helpers/options.h"
|
2018-07-16 23:11:43 +08:00
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
2018-08-10 17:07:17 +08:00
|
|
|
#include "runtime/os_interface/os_interface.h"
|
2018-06-22 18:54:33 +08:00
|
|
|
#include "runtime/platform/platform.h"
|
2018-08-22 16:29:37 +08:00
|
|
|
#include "runtime/source_level_debugger/source_level_debugger.h"
|
2018-07-16 23:11:43 +08:00
|
|
|
#include "test.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "unit_tests/helpers/unit_test_helper.h"
|
2018-07-16 19:01:10 +08:00
|
|
|
#include "unit_tests/mocks/mock_csr.h"
|
2018-10-12 21:20:02 +08:00
|
|
|
#include "unit_tests/mocks/mock_device.h"
|
2018-11-26 06:58:12 +08:00
|
|
|
#include "unit_tests/mocks/mock_execution_environment.h"
|
2018-10-01 22:10:54 +08:00
|
|
|
#include "unit_tests/mocks/mock_memory_manager.h"
|
2019-08-21 16:53:07 +08:00
|
|
|
#include "unit_tests/mocks/mock_memory_operations_handler.h"
|
2018-06-22 18:54:33 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2018-06-22 18:54:33 +08:00
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenDefaultConstructorWhenItIsCalledThenExecutionEnvironmentHasInitialRefCountZero) {
|
|
|
|
ExecutionEnvironment environment;
|
|
|
|
EXPECT_EQ(0, environment.getRefInternalCount());
|
|
|
|
EXPECT_EQ(0, environment.getRefApiCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenPlatformWhenItIsConstructedThenItCretesExecutionEnvironmentWithOneRefCountInternal) {
|
|
|
|
std::unique_ptr<Platform> platform(new Platform);
|
|
|
|
ASSERT_NE(nullptr, platform->peekExecutionEnvironment());
|
|
|
|
EXPECT_EQ(1, platform->peekExecutionEnvironment()->getRefInternalCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenPlatformAndExecutionEnvironmentWithRefCountsWhenPlatformIsDestroyedThenExecutionEnvironmentIsNotDeleted) {
|
|
|
|
std::unique_ptr<Platform> platform(new Platform);
|
|
|
|
auto executionEnvironment = platform->peekExecutionEnvironment();
|
|
|
|
executionEnvironment->incRefInternal();
|
|
|
|
platform.reset();
|
|
|
|
EXPECT_EQ(1, executionEnvironment->getRefInternalCount());
|
|
|
|
executionEnvironment->decRefInternal();
|
|
|
|
}
|
2018-06-27 17:35:37 +08:00
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenPlatformWhenItIsInitializedAndCreatesDevicesThenThoseDevicesAddRefcountsToExecutionEnvironment) {
|
|
|
|
std::unique_ptr<Platform> platform(new Platform);
|
|
|
|
auto executionEnvironment = platform->peekExecutionEnvironment();
|
|
|
|
|
2019-10-07 18:42:28 +08:00
|
|
|
auto expectedRefCounts = executionEnvironment->getRefInternalCount();
|
2018-06-27 17:35:37 +08:00
|
|
|
platform->initialize();
|
2019-10-07 18:42:28 +08:00
|
|
|
EXPECT_LT(0u, platform->getDevice(0)->getNumAvailableDevices());
|
|
|
|
if (platform->getDevice(0)->getNumAvailableDevices() > 1) {
|
|
|
|
expectedRefCounts++;
|
|
|
|
}
|
|
|
|
expectedRefCounts += platform->getDevice(0)->getNumAvailableDevices();
|
|
|
|
EXPECT_EQ(expectedRefCounts, executionEnvironment->getRefInternalCount());
|
2018-06-27 17:35:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenDeviceThatHaveRefferencesAfterPlatformIsDestroyedThenDeviceIsStillUsable) {
|
2019-10-07 18:42:28 +08:00
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(1);
|
2018-06-27 17:35:37 +08:00
|
|
|
std::unique_ptr<Platform> platform(new Platform);
|
|
|
|
auto executionEnvironment = platform->peekExecutionEnvironment();
|
|
|
|
platform->initialize();
|
|
|
|
auto device = platform->getDevice(0);
|
|
|
|
EXPECT_EQ(1, device->getRefInternalCount());
|
|
|
|
device->incRefInternal();
|
|
|
|
platform.reset(nullptr);
|
|
|
|
EXPECT_EQ(1, device->getRefInternalCount());
|
|
|
|
EXPECT_EQ(1, executionEnvironment->getRefInternalCount());
|
|
|
|
|
|
|
|
device->decRefInternal();
|
2018-07-11 20:16:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesCommandStreamReceiverInExecutionEnvironment) {
|
|
|
|
Platform platform;
|
|
|
|
auto executionEnvironment = platform.peekExecutionEnvironment();
|
|
|
|
platform.initialize();
|
2018-11-20 20:58:15 +08:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
|
2018-07-11 22:47:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManagerInExecutionEnvironment) {
|
|
|
|
Platform platform;
|
|
|
|
auto executionEnvironment = platform.peekExecutionEnvironment();
|
|
|
|
platform.initialize();
|
|
|
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
2018-07-12 14:07:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillAvailable) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-03-15 17:22:35 +08:00
|
|
|
executionEnvironment->initializeMemoryManager();
|
2019-09-17 16:44:49 +08:00
|
|
|
std::unique_ptr<Device> device(Device::create<RootDevice>(executionEnvironment, 0u));
|
2018-07-12 14:07:23 +08:00
|
|
|
device.reset(nullptr);
|
|
|
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
2018-07-13 13:42:18 +08:00
|
|
|
}
|
|
|
|
|
2018-07-16 23:11:43 +08:00
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeCommandStreamReceiverIsCalledThenItIsInitalized) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-09-02 19:23:25 +08:00
|
|
|
executionEnvironment->initializeMemoryManager();
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment->initializeCommandStreamReceiver(0, 0);
|
2018-11-20 20:58:15 +08:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
|
2018-07-16 23:11:43 +08:00
|
|
|
}
|
|
|
|
|
2018-09-11 21:55:04 +08:00
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledWithDifferentDeviceIndexesThenInternalStorageIsResized) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-09-02 19:23:25 +08:00
|
|
|
executionEnvironment->initializeMemoryManager();
|
2018-09-11 21:55:04 +08:00
|
|
|
EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size());
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment->initializeCommandStreamReceiver(0, 0);
|
2018-09-11 21:55:04 +08:00
|
|
|
EXPECT_EQ(1u, executionEnvironment->commandStreamReceivers.size());
|
2018-11-20 20:58:15 +08:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment->initializeCommandStreamReceiver(1, 0);
|
2018-09-11 21:55:04 +08:00
|
|
|
EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers.size());
|
2018-11-20 20:58:15 +08:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[1][0]);
|
2018-09-11 21:55:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledMultipleTimesForTheSameIndexThenCommandStreamReceiverIsReused) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-09-02 19:23:25 +08:00
|
|
|
executionEnvironment->initializeMemoryManager();
|
2018-09-11 21:55:04 +08:00
|
|
|
EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size());
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment->initializeCommandStreamReceiver(0, 1);
|
2018-09-11 21:55:04 +08:00
|
|
|
|
2018-11-20 20:58:15 +08:00
|
|
|
auto currentCommandStreamReceiver = executionEnvironment->commandStreamReceivers[0][1].get();
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment->initializeCommandStreamReceiver(0, 1);
|
2018-09-11 21:55:04 +08:00
|
|
|
|
2018-11-20 20:58:15 +08:00
|
|
|
EXPECT_EQ(currentCommandStreamReceiver, executionEnvironment->commandStreamReceivers[0][1].get());
|
2019-01-10 20:57:40 +08:00
|
|
|
EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers[0].size());
|
2018-11-20 20:58:15 +08:00
|
|
|
EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
|
2018-07-16 23:11:43 +08:00
|
|
|
}
|
|
|
|
|
2018-11-26 06:58:12 +08:00
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsReceivesCorrectInputParams) {
|
|
|
|
MockExecutionEnvironment executionEnvironment;
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment.setHwInfo(*platformDevices);
|
|
|
|
executionEnvironment.initAubCenter(true, "test.aub", CommandStreamReceiverType::CSR_AUB);
|
2018-11-26 06:58:12 +08:00
|
|
|
EXPECT_TRUE(executionEnvironment.initAubCenterCalled);
|
|
|
|
EXPECT_TRUE(executionEnvironment.localMemoryEnabledReceived);
|
|
|
|
EXPECT_STREQ(executionEnvironment.aubFileNameReceived.c_str(), "test.aub");
|
|
|
|
}
|
|
|
|
|
2018-12-11 00:12:32 +08:00
|
|
|
TEST(ExecutionEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenReturnNull) {
|
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.UseAubStream.set(false);
|
|
|
|
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
|
|
|
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
|
|
|
auto aubManager = executionEnvironment->aubCenter->getAubManager();
|
2018-11-27 10:17:57 +08:00
|
|
|
EXPECT_EQ(nullptr, aubManager);
|
|
|
|
}
|
|
|
|
|
2018-09-26 21:28:11 +08:00
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
|
|
|
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
|
|
|
auto currentAubCenter = executionEnvironment->aubCenter.get();
|
2018-09-26 21:28:11 +08:00
|
|
|
EXPECT_NE(nullptr, currentAubCenter);
|
|
|
|
auto currentAubStreamProvider = currentAubCenter->getStreamProvider();
|
2018-09-20 06:36:44 +08:00
|
|
|
EXPECT_NE(nullptr, currentAubStreamProvider);
|
|
|
|
auto currentAubFileStream = currentAubStreamProvider->getStream();
|
|
|
|
EXPECT_NE(nullptr, currentAubFileStream);
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
|
|
|
|
EXPECT_EQ(currentAubCenter, executionEnvironment->aubCenter.get());
|
|
|
|
EXPECT_EQ(currentAubStreamProvider, executionEnvironment->aubCenter->getStreamProvider());
|
|
|
|
EXPECT_EQ(currentAubFileStream, executionEnvironment->aubCenter->getStreamProvider()->getStream());
|
2018-09-20 06:36:44 +08:00
|
|
|
}
|
|
|
|
|
2018-10-12 21:20:02 +08:00
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenLocalMemorySupportedInMemoryManagerHasCorrectValue) {
|
2019-02-12 17:56:27 +08:00
|
|
|
const HardwareInfo *hwInfo = platformDevices[0];
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo));
|
2018-10-12 21:20:02 +08:00
|
|
|
auto executionEnvironment = device->getExecutionEnvironment();
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment->initializeCommandStreamReceiver(0, 0);
|
2019-05-08 22:00:24 +08:00
|
|
|
auto enableLocalMemory = HwHelper::get(hwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
|
2019-03-15 17:22:35 +08:00
|
|
|
executionEnvironment->initializeMemoryManager();
|
2019-02-12 17:56:27 +08:00
|
|
|
EXPECT_EQ(enableLocalMemory, executionEnvironment->memoryManager->isLocalMemorySupported());
|
2018-10-12 21:20:02 +08:00
|
|
|
}
|
|
|
|
|
2018-09-11 21:55:04 +08:00
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenItIsInitalized) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
|
|
|
executionEnvironment->initializeCommandStreamReceiver(0, 0);
|
2019-03-15 17:22:35 +08:00
|
|
|
executionEnvironment->initializeMemoryManager();
|
2018-09-11 21:55:04 +08:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
|
|
|
}
|
2019-02-15 16:25:08 +08:00
|
|
|
static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector<std::unique_ptr<CommandStreamReceiver>>) +
|
|
|
|
sizeof(std::mutex) +
|
2019-05-06 18:33:44 +08:00
|
|
|
sizeof(std::unique_ptr<HardwareInfo>) +
|
2019-08-21 16:53:07 +08:00
|
|
|
(is64bit ? 88 : 48),
|
2019-02-15 16:25:08 +08:00
|
|
|
"New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
|
2018-07-13 13:42:18 +08:00
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) {
|
2018-08-22 16:29:37 +08:00
|
|
|
uint32_t destructorId = 0u;
|
2018-08-01 15:06:46 +08:00
|
|
|
|
2018-08-22 16:29:37 +08:00
|
|
|
struct MockExecutionEnvironment : ExecutionEnvironment {
|
|
|
|
using ExecutionEnvironment::gmmHelper;
|
2018-07-13 13:42:18 +08:00
|
|
|
};
|
2019-10-07 18:42:28 +08:00
|
|
|
struct GmmHelperMock : public DestructorCounted<GmmHelper, 8> {
|
2018-08-22 16:29:37 +08:00
|
|
|
GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, hwInfo) {}
|
2018-07-13 13:42:18 +08:00
|
|
|
};
|
2019-10-07 18:42:28 +08:00
|
|
|
struct OsInterfaceMock : public DestructorCounted<OSInterface, 7> {
|
2018-08-22 16:29:37 +08:00
|
|
|
OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
2018-08-01 15:06:46 +08:00
|
|
|
};
|
2019-10-07 18:42:28 +08:00
|
|
|
struct MemoryOperationsHandlerMock : public DestructorCounted<MockMemoryOperationsHandler, 6> {
|
2019-08-21 16:53:07 +08:00
|
|
|
MemoryOperationsHandlerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
|
|
|
};
|
2019-10-07 18:42:28 +08:00
|
|
|
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 5> {
|
2019-03-28 22:42:23 +08:00
|
|
|
MemoryMangerMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
|
2018-08-21 21:47:21 +08:00
|
|
|
};
|
2019-10-07 18:42:28 +08:00
|
|
|
struct AubCenterMock : public DestructorCounted<AubCenter, 4> {
|
2019-02-08 22:08:35 +08:00
|
|
|
AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB) {}
|
2018-09-20 06:36:44 +08:00
|
|
|
};
|
2019-10-07 18:42:28 +08:00
|
|
|
struct CommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 3> {
|
2018-10-11 17:19:49 +08:00
|
|
|
CommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
|
2018-07-16 19:01:10 +08:00
|
|
|
};
|
2018-08-22 16:29:37 +08:00
|
|
|
struct BuiltinsMock : public DestructorCounted<BuiltIns, 2> {
|
|
|
|
BuiltinsMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
2018-07-12 21:47:48 +08:00
|
|
|
};
|
2018-08-22 16:29:37 +08:00
|
|
|
struct CompilerInterfaceMock : public DestructorCounted<CompilerInterface, 1> {
|
|
|
|
CompilerInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
|
|
|
};
|
|
|
|
struct SourceLevelDebuggerMock : public DestructorCounted<SourceLevelDebugger, 0> {
|
|
|
|
SourceLevelDebuggerMock(uint32_t &destructorId) : DestructorCounted(destructorId, nullptr) {}
|
2018-07-13 13:42:18 +08:00
|
|
|
};
|
|
|
|
|
2018-08-22 16:29:37 +08:00
|
|
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
2019-03-28 22:42:23 +08:00
|
|
|
executionEnvironment->setHwInfo(*platformDevices);
|
2018-11-20 20:58:15 +08:00
|
|
|
executionEnvironment->commandStreamReceivers.resize(1);
|
2018-08-22 16:29:37 +08:00
|
|
|
executionEnvironment->gmmHelper = std::make_unique<GmmHelperMock>(destructorId, platformDevices[0]);
|
|
|
|
executionEnvironment->osInterface = std::make_unique<OsInterfaceMock>(destructorId);
|
2019-08-21 16:53:07 +08:00
|
|
|
executionEnvironment->memoryOperationsInterface = std::make_unique<MemoryOperationsHandlerMock>(destructorId);
|
2019-03-28 22:42:23 +08:00
|
|
|
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId, *executionEnvironment);
|
2018-09-26 21:28:11 +08:00
|
|
|
executionEnvironment->aubCenter = std::make_unique<AubCenterMock>(destructorId);
|
2019-01-10 20:57:40 +08:00
|
|
|
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<CommandStreamReceiverMock>(destructorId, *executionEnvironment));
|
2018-08-22 16:29:37 +08:00
|
|
|
executionEnvironment->builtins = std::make_unique<BuiltinsMock>(destructorId);
|
|
|
|
executionEnvironment->compilerInterface = std::make_unique<CompilerInterfaceMock>(destructorId);
|
|
|
|
executionEnvironment->sourceLevelDebugger = std::make_unique<SourceLevelDebuggerMock>(destructorId);
|
2018-07-13 13:42:18 +08:00
|
|
|
|
|
|
|
executionEnvironment.reset(nullptr);
|
2019-10-07 18:42:28 +08:00
|
|
|
EXPECT_EQ(9u, destructorId);
|
2018-07-16 19:01:10 +08:00
|
|
|
}
|
2018-07-17 17:11:48 +08:00
|
|
|
|
|
|
|
TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManagerAndCommandStreamReceiver) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-05-06 18:33:44 +08:00
|
|
|
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, 0u));
|
2019-07-15 20:28:09 +08:00
|
|
|
auto &commandStreamReceiver = device->getGpgpuCommandStreamReceiver();
|
2018-07-17 17:11:48 +08:00
|
|
|
auto memoryManager = device->getMemoryManager();
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
std::unique_ptr<MockDevice> device2(Device::create<MockDevice>(executionEnvironment, 1u));
|
2019-07-15 20:28:09 +08:00
|
|
|
EXPECT_NE(&commandStreamReceiver, &device2->getGpgpuCommandStreamReceiver());
|
2018-07-17 17:11:48 +08:00
|
|
|
EXPECT_EQ(memoryManager, device2->getMemoryManager());
|
|
|
|
}
|
2018-08-17 19:38:09 +08:00
|
|
|
|
|
|
|
typedef ::testing::Test ExecutionEnvironmentHw;
|
|
|
|
|
2018-10-03 01:10:29 +08:00
|
|
|
HWTEST_F(ExecutionEnvironmentHw, givenHwHelperInputWhenInitializingCsrThenCreatePageTableManagerIfAllowed) {
|
2018-08-17 19:38:09 +08:00
|
|
|
HardwareInfo localHwInfo = *platformDevices[0];
|
2018-10-03 01:10:29 +08:00
|
|
|
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
|
2018-08-17 19:38:09 +08:00
|
|
|
|
|
|
|
ExecutionEnvironment executionEnvironment;
|
2019-09-02 19:23:25 +08:00
|
|
|
executionEnvironment.initializeMemoryManager();
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment.setHwInfo(&localHwInfo);
|
|
|
|
executionEnvironment.initializeCommandStreamReceiver(0, 0);
|
2018-11-20 20:58:15 +08:00
|
|
|
auto csr0 = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceivers[0][0].get());
|
2018-10-03 01:10:29 +08:00
|
|
|
EXPECT_FALSE(csr0->createPageTableManagerCalled);
|
|
|
|
|
2019-05-08 23:16:25 +08:00
|
|
|
auto hwInfo = executionEnvironment.getMutableHardwareInfo();
|
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedImages = false;
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment.initializeCommandStreamReceiver(1, 0);
|
2018-11-20 20:58:15 +08:00
|
|
|
auto csr1 = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceivers[1][0].get());
|
2019-05-08 23:16:25 +08:00
|
|
|
EXPECT_EQ(UnitTestHelper<FamilyType>::isPageTableManagerSupported(*hwInfo), csr1->createPageTableManagerCalled);
|
2018-10-03 01:10:29 +08:00
|
|
|
|
2019-05-08 23:16:25 +08:00
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedImages = true;
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment.initializeCommandStreamReceiver(2, 0);
|
2018-11-20 20:58:15 +08:00
|
|
|
auto csr2 = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceivers[2][0].get());
|
2019-05-08 23:16:25 +08:00
|
|
|
EXPECT_EQ(UnitTestHelper<FamilyType>::isPageTableManagerSupported(*hwInfo), csr2->createPageTableManagerCalled);
|
2018-08-17 19:38:09 +08:00
|
|
|
}
|
2019-02-27 00:52:31 +08:00
|
|
|
|
2019-02-19 15:55:11 +08:00
|
|
|
TEST(ExecutionEnvironment, givenUnproperSetCsrFlagValueWhenInitializingMemoryManagerThenCreateDefaultMemoryManager) {
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(10);
|
|
|
|
|
2019-03-28 22:42:23 +08:00
|
|
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>(*platformDevices);
|
2019-03-15 17:22:35 +08:00
|
|
|
executionEnvironment->initializeMemoryManager();
|
2019-02-19 15:55:11 +08:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
|
|
|
|
}
|