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