2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-08 20:11:09 +08:00
|
|
|
* Copyright (C) 2017-2019 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-11-13 17:01:19 +08:00
|
|
|
#include "core/helpers/hw_helper.h"
|
2019-12-09 22:29:30 +08:00
|
|
|
#include "core/helpers/options.h"
|
2019-12-03 04:04:32 +08:00
|
|
|
#include "core/indirect_heap/indirect_heap.h"
|
2019-07-15 19:51:08 +08:00
|
|
|
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "runtime/device/device.h"
|
2019-05-15 21:12:55 +08:00
|
|
|
#include "runtime/helpers/device_helpers.h"
|
2018-09-06 21:54:29 +08:00
|
|
|
#include "runtime/os_interface/os_context.h"
|
2019-01-23 18:59:54 +08:00
|
|
|
#include "runtime/platform/platform.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "test.h"
|
|
|
|
#include "unit_tests/fixtures/device_fixture.h"
|
2019-11-05 20:38:20 +08:00
|
|
|
#include "unit_tests/helpers/unit_test_helper.h"
|
2019-01-08 20:11:09 +08:00
|
|
|
#include "unit_tests/helpers/variable_backup.h"
|
2018-07-13 20:11:04 +08:00
|
|
|
#include "unit_tests/libult/create_command_stream.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
|
|
|
#include "unit_tests/mocks/mock_context.h"
|
2018-03-09 21:48:42 +08:00
|
|
|
#include "unit_tests/mocks/mock_csr.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-30 02:37:43 +08:00
|
|
|
typedef Test<DeviceFixture> DeviceTest;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
TEST_F(DeviceTest, Create) {
|
|
|
|
EXPECT_NE(nullptr, pDevice);
|
|
|
|
}
|
|
|
|
|
2018-04-24 19:06:49 +08:00
|
|
|
TEST_F(DeviceTest, givenDeviceWhenGetProductAbbrevThenReturnsHardwarePrefix) {
|
|
|
|
const auto productAbbrev = pDevice->getProductAbbrev();
|
2019-05-08 22:00:24 +08:00
|
|
|
const auto hwPrefix = hardwarePrefix[pDevice->getHardwareInfo().platform.eProductFamily];
|
2018-04-24 19:06:49 +08:00
|
|
|
EXPECT_EQ(hwPrefix, productAbbrev);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST_F(DeviceTest, getCommandStreamReceiver) {
|
2019-07-15 20:28:09 +08:00
|
|
|
EXPECT_NE(nullptr, &pDevice->getGpgpuCommandStreamReceiver());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, getSupportedClVersion) {
|
|
|
|
auto version = pDevice->getSupportedClVersion();
|
|
|
|
auto version2 = pDevice->getHardwareInfo().capabilityTable.clVersionSupport;
|
|
|
|
|
|
|
|
EXPECT_EQ(version, version2);
|
|
|
|
}
|
|
|
|
|
2019-03-23 21:26:06 +08:00
|
|
|
TEST_F(DeviceTest, givenDeviceWhenEngineIsCreatedThenSetInitialValueForTag) {
|
|
|
|
for (auto &engine : pDevice->engines) {
|
|
|
|
auto tagAddress = engine.commandStreamReceiver->getTagAddress();
|
2018-11-28 16:02:55 +08:00
|
|
|
ASSERT_NE(nullptr, const_cast<uint32_t *>(tagAddress));
|
|
|
|
EXPECT_EQ(initialHardwareTag, *tagAddress);
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-03-23 21:26:06 +08:00
|
|
|
TEST_F(DeviceTest, givenDeviceWhenAskedForSpecificEngineThenRetrunIt) {
|
2019-05-08 22:00:24 +08:00
|
|
|
auto &engines = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances();
|
2019-03-23 21:26:06 +08:00
|
|
|
for (uint32_t i = 0; i < engines.size(); i++) {
|
2019-03-25 20:21:48 +08:00
|
|
|
bool lowPriority = (HwHelper::lowPriorityGpgpuEngineIndex == i);
|
2019-03-23 21:26:06 +08:00
|
|
|
auto &deviceEngine = pDevice->getEngine(engines[i], lowPriority);
|
|
|
|
EXPECT_EQ(deviceEngine.osContext->getEngineType(), engines[i]);
|
|
|
|
EXPECT_EQ(deviceEngine.osContext->isLowPriority(), lowPriority);
|
|
|
|
}
|
|
|
|
|
2019-03-27 17:06:29 +08:00
|
|
|
EXPECT_THROW(pDevice->getEngine(aub_stream::ENGINE_VCS, false), std::exception);
|
2019-03-23 21:26:06 +08:00
|
|
|
}
|
|
|
|
|
2019-04-09 23:46:23 +08:00
|
|
|
TEST_F(DeviceTest, givenDebugVariableToAlwaysChooseEngineZeroWhenNotExistingEngineSelectedThenIndexZeroEngineIsReturned) {
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
DebugManager.flags.OverrideInvalidEngineWithDefault.set(true);
|
2019-05-08 22:00:24 +08:00
|
|
|
auto &engines = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances();
|
2019-04-09 23:46:23 +08:00
|
|
|
auto &deviceEngine = pDevice->getEngine(engines[0], false);
|
|
|
|
auto ¬ExistingEngine = pDevice->getEngine(aub_stream::ENGINE_VCS, false);
|
|
|
|
EXPECT_EQ(¬ExistingEngine, &deviceEngine);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
TEST_F(DeviceTest, WhenGetOSTimeThenNotNull) {
|
2018-07-25 23:12:44 +08:00
|
|
|
auto pDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
OSTime *osTime = pDevice->getOSTime();
|
|
|
|
ASSERT_NE(nullptr, osTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, GivenDebugVariableForcing32BitAllocationsWhenDeviceIsCreatedThenMemoryManagerHasForce32BitFlagSet) {
|
|
|
|
DebugManager.flags.Force32bitAddressing.set(true);
|
2018-07-25 23:12:44 +08:00
|
|
|
auto pDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
2017-12-21 07:45:38 +08:00
|
|
|
if (is64bit) {
|
|
|
|
EXPECT_TRUE(pDevice->getDeviceInfo().force32BitAddressess);
|
|
|
|
EXPECT_TRUE(pDevice->getMemoryManager()->peekForce32BitAllocations());
|
|
|
|
} else {
|
|
|
|
EXPECT_FALSE(pDevice->getDeviceInfo().force32BitAddressess);
|
|
|
|
EXPECT_FALSE(pDevice->getMemoryManager()->peekForce32BitAllocations());
|
|
|
|
}
|
|
|
|
DebugManager.flags.Force32bitAddressing.set(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, retainAndRelease) {
|
|
|
|
ASSERT_NE(nullptr, pDevice);
|
|
|
|
|
|
|
|
pDevice->retain();
|
|
|
|
pDevice->retain();
|
|
|
|
pDevice->retain();
|
|
|
|
ASSERT_EQ(1, pDevice->getReference());
|
|
|
|
|
|
|
|
ASSERT_FALSE(pDevice->release().isUnused());
|
|
|
|
ASSERT_EQ(1, pDevice->getReference());
|
|
|
|
}
|
|
|
|
|
2017-11-14 18:15:09 +08:00
|
|
|
TEST_F(DeviceTest, getEngineTypeDefault) {
|
|
|
|
auto pTestDevice = std::unique_ptr<Device>(createWithUsDeviceId(0));
|
|
|
|
|
2019-03-27 17:06:29 +08:00
|
|
|
auto actualEngineType = pDevice->getDefaultEngine().osContext->getEngineType();
|
|
|
|
auto defaultEngineType = pDevice->getHardwareInfo().capabilityTable.defaultEngineType;
|
2017-11-14 18:15:09 +08:00
|
|
|
|
2018-11-28 16:02:55 +08:00
|
|
|
EXPECT_EQ(&pDevice->getDefaultEngine().commandStreamReceiver->getOsContext(), pDevice->getDefaultEngine().osContext);
|
2017-11-14 18:15:09 +08:00
|
|
|
EXPECT_EQ(defaultEngineType, actualEngineType);
|
|
|
|
}
|
2018-01-18 16:09:01 +08:00
|
|
|
|
2018-03-09 21:48:42 +08:00
|
|
|
TEST(DeviceCleanup, givenDeviceWhenItIsDestroyedThenFlushBatchedSubmissionsIsCalled) {
|
2018-07-03 16:00:12 +08:00
|
|
|
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
2019-10-29 15:01:53 +08:00
|
|
|
MockCommandStreamReceiver *csr = new MockCommandStreamReceiver(*mockDevice->getExecutionEnvironment(), mockDevice->getRootDeviceIndex());
|
2018-03-09 21:48:42 +08:00
|
|
|
mockDevice->resetCommandStreamReceiver(csr);
|
|
|
|
int flushedBatchedSubmissionsCalledCount = 0;
|
|
|
|
csr->flushBatchedSubmissionsCallCounter = &flushedBatchedSubmissionsCalledCount;
|
|
|
|
mockDevice.reset(nullptr);
|
|
|
|
|
|
|
|
EXPECT_EQ(1, flushedBatchedSubmissionsCalledCount);
|
2018-03-30 02:37:43 +08:00
|
|
|
}
|
2018-06-06 16:34:51 +08:00
|
|
|
|
|
|
|
TEST(DeviceCreation, givenSelectedAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsTrue) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB);
|
|
|
|
|
2019-01-08 20:11:09 +08:00
|
|
|
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
|
2018-07-03 16:00:12 +08:00
|
|
|
auto mockDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2018-06-06 16:34:51 +08:00
|
|
|
EXPECT_TRUE(mockDevice->isSimulation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceCreation, givenSelectedTbxCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsTrue) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX);
|
|
|
|
|
2019-01-08 20:11:09 +08:00
|
|
|
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
|
2018-07-03 16:00:12 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2018-06-06 16:34:51 +08:00
|
|
|
EXPECT_TRUE(device->isSimulation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceCreation, givenSelectedTbxWithAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsTrue) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB);
|
|
|
|
|
2019-01-08 20:11:09 +08:00
|
|
|
VariableBackup<bool> backup(&overrideCommandStreamReceiverCreation, true);
|
2018-07-03 16:00:12 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2018-06-06 16:34:51 +08:00
|
|
|
EXPECT_TRUE(device->isSimulation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceCreation, givenHwWithAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsFalse) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_HW_WITH_AUB);
|
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2018-06-06 16:34:51 +08:00
|
|
|
EXPECT_FALSE(device->isSimulation());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceCreation, givenDefaultHwCsrInDebugVarsWhenDeviceIsCreatedThenIsSimulationReturnsFalse) {
|
2018-07-03 16:00:12 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2018-06-06 16:34:51 +08:00
|
|
|
EXPECT_FALSE(device->isSimulation());
|
|
|
|
}
|
2018-07-11 16:32:17 +08:00
|
|
|
|
2018-09-06 15:01:13 +08:00
|
|
|
TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryManager) {
|
2019-11-05 20:38:20 +08:00
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
2018-09-06 15:01:13 +08:00
|
|
|
auto memoryManager = device->getMemoryManager();
|
2019-10-07 18:42:28 +08:00
|
|
|
auto numEnginesForDevice = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size();
|
|
|
|
if (device->getNumAvailableDevices() > 1) {
|
|
|
|
numEnginesForDevice *= device->getNumAvailableDevices();
|
2019-11-05 20:38:20 +08:00
|
|
|
numEnginesForDevice += device->engines.size();
|
2019-10-07 18:42:28 +08:00
|
|
|
}
|
|
|
|
EXPECT_EQ(numEnginesForDevice, memoryManager->getRegisteredEnginesCount());
|
2018-09-06 15:01:13 +08:00
|
|
|
}
|
|
|
|
|
2019-10-24 19:34:25 +08:00
|
|
|
TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachOsContextHasUniqueId) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2018-11-28 16:02:55 +08:00
|
|
|
const size_t numDevices = 2;
|
2019-11-15 16:59:48 +08:00
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(numDevices);
|
2019-05-08 22:00:24 +08:00
|
|
|
const auto &numGpgpuEngines = static_cast<uint32_t>(HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size());
|
2018-11-28 16:02:55 +08:00
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
|
|
|
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
|
2018-09-06 21:54:29 +08:00
|
|
|
|
2019-01-23 18:59:54 +08:00
|
|
|
auto ®isteredEngines = executionEnvironment->memoryManager->getRegisteredEngines();
|
2019-02-18 20:59:16 +08:00
|
|
|
EXPECT_EQ(numGpgpuEngines * numDevices, registeredEngines.size());
|
|
|
|
|
2019-01-10 20:57:40 +08:00
|
|
|
for (uint32_t i = 0; i < numGpgpuEngines; i++) {
|
2019-03-23 21:26:06 +08:00
|
|
|
EXPECT_EQ(i, device1->engines[i].osContext->getContextId());
|
|
|
|
EXPECT_EQ(1u, device1->engines[i].osContext->getDeviceBitfield().to_ulong());
|
|
|
|
EXPECT_EQ(i + numGpgpuEngines, device2->engines[i].osContext->getContextId());
|
2019-10-24 19:34:25 +08:00
|
|
|
EXPECT_EQ(1u, device2->engines[i].osContext->getDeviceBitfield().to_ulong());
|
2019-02-18 20:59:16 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(registeredEngines[i].commandStreamReceiver,
|
2019-03-23 21:26:06 +08:00
|
|
|
device1->engines[i].commandStreamReceiver);
|
2019-02-18 20:59:16 +08:00
|
|
|
EXPECT_EQ(registeredEngines[i + numGpgpuEngines].commandStreamReceiver,
|
2019-03-23 21:26:06 +08:00
|
|
|
device2->engines[i].commandStreamReceiver);
|
2018-11-28 16:02:55 +08:00
|
|
|
}
|
2019-01-23 18:59:54 +08:00
|
|
|
EXPECT_EQ(numGpgpuEngines * numDevices, executionEnvironment->memoryManager->getRegisteredEnginesCount());
|
2018-09-06 21:54:29 +08:00
|
|
|
}
|
|
|
|
|
2019-10-24 19:34:25 +08:00
|
|
|
TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-10-24 19:34:25 +08:00
|
|
|
const size_t numDevices = 2;
|
2019-11-15 16:59:48 +08:00
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(numDevices);
|
2019-10-24 19:34:25 +08:00
|
|
|
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
|
|
|
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
|
2018-09-07 14:45:13 +08:00
|
|
|
|
2019-10-24 19:34:25 +08:00
|
|
|
EXPECT_EQ(0u, device->getRootDeviceIndex());
|
|
|
|
EXPECT_EQ(1u, device2->getRootDeviceIndex());
|
2018-09-07 14:45:13 +08:00
|
|
|
}
|
|
|
|
|
2019-10-24 19:34:25 +08:00
|
|
|
TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateCommandStreamReceiver) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2018-11-28 16:02:55 +08:00
|
|
|
const size_t numDevices = 2;
|
2019-11-15 16:59:48 +08:00
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(numDevices);
|
2019-05-08 22:00:24 +08:00
|
|
|
const auto &numGpgpuEngines = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances().size();
|
2019-05-06 18:33:44 +08:00
|
|
|
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
|
|
|
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
|
2018-09-11 21:55:04 +08:00
|
|
|
|
2019-11-05 20:38:20 +08:00
|
|
|
EXPECT_EQ(numGpgpuEngines, device1->commandStreamReceivers.size());
|
|
|
|
EXPECT_EQ(numGpgpuEngines, device2->commandStreamReceivers.size());
|
2018-11-28 16:02:55 +08:00
|
|
|
|
2019-01-10 20:57:40 +08:00
|
|
|
for (uint32_t i = 0; i < static_cast<uint32_t>(numGpgpuEngines); i++) {
|
2019-11-05 20:38:20 +08:00
|
|
|
EXPECT_NE(device2->engines[i].commandStreamReceiver, device1->engines[i].commandStreamReceiver);
|
2018-11-23 21:59:27 +08:00
|
|
|
}
|
2018-09-11 21:55:04 +08:00
|
|
|
}
|
|
|
|
|
2018-11-28 16:02:55 +08:00
|
|
|
TEST(DeviceCreation, givenDeviceWhenAskingForDefaultEngineThenReturnValidValue) {
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-05-06 18:33:44 +08:00
|
|
|
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0));
|
2019-03-20 17:56:22 +08:00
|
|
|
auto osContext = device->getDefaultEngine().osContext;
|
2018-11-28 16:02:55 +08:00
|
|
|
|
2019-03-20 17:56:22 +08:00
|
|
|
EXPECT_EQ(platformDevices[0]->capabilityTable.defaultEngineType, osContext->getEngineType());
|
|
|
|
EXPECT_FALSE(osContext->isLowPriority());
|
2018-11-28 16:02:55 +08:00
|
|
|
}
|
|
|
|
|
2018-07-11 16:32:17 +08:00
|
|
|
TEST(DeviceCreation, givenFtrSimulationModeFlagTrueWhenNoOtherSimulationFlagsArePresentThenIsSimulationReturnsTrue) {
|
2019-05-06 18:33:44 +08:00
|
|
|
HardwareInfo hwInfo = *platformDevices[0];
|
2019-05-08 22:00:24 +08:00
|
|
|
hwInfo.featureTable.ftrSimulationMode = true;
|
2018-07-11 16:32:17 +08:00
|
|
|
|
2019-05-08 22:00:24 +08:00
|
|
|
bool simulationFromDeviceId = hwInfo.capabilityTable.isSimulation(hwInfo.platform.usDeviceID);
|
2018-07-11 16:32:17 +08:00
|
|
|
EXPECT_FALSE(simulationFromDeviceId);
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(&hwInfo));
|
|
|
|
EXPECT_TRUE(device->isSimulation());
|
|
|
|
}
|
2019-05-15 21:12:55 +08:00
|
|
|
|
|
|
|
TEST(DeviceCreation, givenDeviceWhenCheckingEnginesCountThenNumberGreaterThanZeroIsReturned) {
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
|
|
|
EXPECT_GT(DeviceHelper::getEnginesCount(device->getHardwareInfo()), 0u);
|
|
|
|
}
|
2019-11-05 20:38:20 +08:00
|
|
|
|
|
|
|
using DeviceHwTest = ::testing::Test;
|
|
|
|
|
2019-12-27 18:32:12 +08:00
|
|
|
HWTEST_F(DeviceHwTest, givenHwHelperInputWhenInitializingCsrThenCreatePageTableManagerIfNeeded) {
|
2019-11-05 20:38:20 +08:00
|
|
|
HardwareInfo localHwInfo = *platformDevices[0];
|
|
|
|
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
|
|
|
|
|
|
|
|
ExecutionEnvironment executionEnvironment;
|
2019-12-27 18:32:12 +08:00
|
|
|
executionEnvironment.prepareRootDeviceEnvironments(3);
|
2019-11-05 20:38:20 +08:00
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
executionEnvironment.initializeMemoryManager();
|
|
|
|
executionEnvironment.setHwInfo(&localHwInfo);
|
2019-12-27 18:32:12 +08:00
|
|
|
auto defaultEngineType = getChosenEngineType(localHwInfo);
|
2019-11-05 20:38:20 +08:00
|
|
|
std::unique_ptr<MockDevice> device;
|
|
|
|
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(&localHwInfo, &executionEnvironment, 0));
|
|
|
|
auto &csr0 = device->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
EXPECT_FALSE(csr0.createPageTableManagerCalled);
|
|
|
|
|
|
|
|
auto hwInfo = executionEnvironment.getMutableHardwareInfo();
|
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedImages = false;
|
2019-12-27 18:32:12 +08:00
|
|
|
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(&localHwInfo, &executionEnvironment, 1));
|
2019-11-05 20:38:20 +08:00
|
|
|
auto &csr1 = device->getUltCommandStreamReceiver<FamilyType>();
|
2019-12-27 18:32:12 +08:00
|
|
|
EXPECT_EQ(csr1.needsPageTableManager(defaultEngineType), csr1.createPageTableManagerCalled);
|
2019-11-05 20:38:20 +08:00
|
|
|
|
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
hwInfo->capabilityTable.ftrRenderCompressedImages = true;
|
2019-12-27 18:32:12 +08:00
|
|
|
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(&localHwInfo, &executionEnvironment, 2));
|
2019-11-05 20:38:20 +08:00
|
|
|
auto &csr2 = device->getUltCommandStreamReceiver<FamilyType>();
|
2019-12-27 18:32:12 +08:00
|
|
|
EXPECT_EQ(csr2.needsPageTableManager(defaultEngineType), csr2.createPageTableManagerCalled);
|
2019-11-05 20:38:20 +08:00
|
|
|
}
|