2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2018-2021 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-05-31 17:28:07 +08:00
|
|
|
#include "shared/source/command_stream/tbx_command_stream_receiver.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
#include "shared/source/indirect_heap/indirect_heap.h"
|
|
|
|
#include "shared/source/os_interface/os_context.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
2021-09-16 22:53:49 +08:00
|
|
|
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/ult_hw_config.h"
|
2021-04-13 20:00:07 +08:00
|
|
|
#include "shared/test/common/helpers/unit_test_helper.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/variable_backup.h"
|
2021-10-13 00:42:24 +08:00
|
|
|
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
|
|
|
#include "shared/test/common/mocks/mock_csr.h"
|
2020-11-05 20:40:03 +08:00
|
|
|
#include "shared/test/common/mocks/mock_driver_info.h"
|
2021-07-06 21:44:16 +08:00
|
|
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
2021-10-05 20:54:33 +08:00
|
|
|
#include "shared/test/common/mocks/mock_memory_manager.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
2021-12-15 01:40:08 +08:00
|
|
|
#include "shared/test/common/test_macros/test.h"
|
2021-06-25 19:34:12 +08:00
|
|
|
#include "shared/test/common/test_macros/test_checks_shared.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/platform/platform.h"
|
2020-05-28 20:05:12 +08:00
|
|
|
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
2021-09-16 22:53:49 +08:00
|
|
|
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
2021-08-17 02:24:13 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_os_context.h"
|
2020-03-17 21:25:44 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
2020-02-23 05:50:57 +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
|
|
|
|
2020-05-28 20:05:12 +08:00
|
|
|
typedef Test<ClDeviceFixture> DeviceTest;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:19:18 +08:00
|
|
|
TEST_F(DeviceTest, WhenDeviceIsCreatedThenCommandStreamReceiverIsNotNull) {
|
2019-07-15 20:28:09 +08:00
|
|
|
EXPECT_NE(nullptr, &pDevice->getGpgpuCommandStreamReceiver());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2020-05-05 22:40:31 +08:00
|
|
|
TEST_F(DeviceTest, WhenDeviceIsCreatedThenEnabledClVersionMatchesHardwareInfo) {
|
|
|
|
auto version = pClDevice->getEnabledClVersion();
|
2017-12-21 07:45:38 +08:00
|
|
|
auto version2 = pDevice->getHardwareInfo().capabilityTable.clVersionSupport;
|
|
|
|
|
|
|
|
EXPECT_EQ(version, version2);
|
|
|
|
}
|
|
|
|
|
2020-06-24 00:59:36 +08:00
|
|
|
TEST_F(DeviceTest, WhenDeviceIsCheckedForOcl21ConformanceThenCorrectValueIsReturned) {
|
|
|
|
auto hwInfo = pClDevice->getHardwareInfo();
|
|
|
|
for (auto supportsOcl21Features : ::testing::Bool()) {
|
|
|
|
hwInfo.capabilityTable.supportsOcl21Features = supportsOcl21Features;
|
|
|
|
for (auto supportsIfp : ::testing::Bool()) {
|
|
|
|
hwInfo.capabilityTable.supportsIndependentForwardProgress = supportsIfp;
|
|
|
|
for (auto supportsDeviceEnqueue : ::testing::Bool()) {
|
|
|
|
hwInfo.capabilityTable.supportsDeviceEnqueue = supportsDeviceEnqueue;
|
|
|
|
for (auto supportsPipes : ::testing::Bool()) {
|
|
|
|
hwInfo.capabilityTable.supportsPipes = supportsPipes;
|
|
|
|
|
|
|
|
auto pClDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
|
|
|
|
|
|
|
auto expectedOcl21Conformance = (supportsOcl21Features && supportsIfp && supportsDeviceEnqueue && supportsPipes);
|
|
|
|
EXPECT_EQ(expectedOcl21Conformance, pClDevice->isOcl21Conformant());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-23 21:26:06 +08:00
|
|
|
TEST_F(DeviceTest, givenDeviceWhenEngineIsCreatedThenSetInitialValueForTag) {
|
2021-12-13 20:45:24 +08:00
|
|
|
for (auto &engine : pDevice->allEngines) {
|
2019-03-23 21:26:06 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-05-04 03:33:11 +08:00
|
|
|
TEST_F(DeviceTest, givenDeviceWhenAskedForSpecificEngineThenReturnIt) {
|
2020-09-15 23:29:02 +08:00
|
|
|
auto hwInfo = *defaultHwInfo;
|
2021-11-25 17:31:14 +08:00
|
|
|
hwInfo.featureTable.flags.ftrCCSNode = true;
|
2021-11-05 00:38:47 +08:00
|
|
|
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
2020-09-15 23:29:02 +08:00
|
|
|
|
|
|
|
MockClDevice mockClDevice{MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0)};
|
|
|
|
|
|
|
|
auto &engines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo);
|
2019-03-23 21:26:06 +08:00
|
|
|
for (uint32_t i = 0; i < engines.size(); i++) {
|
2021-03-16 20:34:27 +08:00
|
|
|
auto &deviceEngine = mockClDevice.getEngine(engines[i].first, EngineUsage::Regular);
|
2020-09-15 23:29:02 +08:00
|
|
|
EXPECT_EQ(deviceEngine.osContext->getEngineType(), engines[i].first);
|
|
|
|
EXPECT_EQ(deviceEngine.osContext->isLowPriority(), false);
|
2019-03-23 21:26:06 +08:00
|
|
|
}
|
|
|
|
|
2021-03-16 20:34:27 +08:00
|
|
|
auto &deviceEngine = mockClDevice.getEngine(hwInfo.capabilityTable.defaultEngineType, EngineUsage::LowPriority);
|
2020-09-15 23:29:02 +08:00
|
|
|
EXPECT_EQ(deviceEngine.osContext->getEngineType(), hwInfo.capabilityTable.defaultEngineType);
|
|
|
|
EXPECT_EQ(deviceEngine.osContext->isLowPriority(), true);
|
|
|
|
|
2021-03-16 20:34:27 +08:00
|
|
|
EXPECT_THROW(mockClDevice.getEngine(aub_stream::ENGINE_VCS, EngineUsage::Regular), 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);
|
2020-03-24 23:03:47 +08:00
|
|
|
auto &engines = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo);
|
2021-03-16 20:34:27 +08:00
|
|
|
auto &deviceEngine = pDevice->getEngine(engines[0].first, EngineUsage::Regular);
|
|
|
|
auto ¬ExistingEngine = pDevice->getEngine(aub_stream::ENGINE_VCS, EngineUsage::Regular);
|
2019-04-09 23:46:23 +08:00
|
|
|
EXPECT_EQ(¬ExistingEngine, &deviceEngine);
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:19:18 +08:00
|
|
|
TEST_F(DeviceTest, WhenDeviceIsCreatedThenOsTimeIsNotNull) {
|
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));
|
2021-05-24 21:49:09 +08:00
|
|
|
if constexpr (is64bit) {
|
2017-12-21 07:45:38 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:19:18 +08:00
|
|
|
TEST_F(DeviceTest, WhenRetainingThenReferenceIsOneAndApiIsUsed) {
|
2020-01-14 21:32:11 +08:00
|
|
|
ASSERT_NE(nullptr, pClDevice);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
pClDevice->retainApi();
|
|
|
|
pClDevice->retainApi();
|
|
|
|
pClDevice->retainApi();
|
|
|
|
ASSERT_EQ(1, pClDevice->getReference());
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
ASSERT_FALSE(pClDevice->releaseApi().isUnused());
|
|
|
|
ASSERT_EQ(1, pClDevice->getReference());
|
|
|
|
}
|
|
|
|
|
2020-11-05 20:40:03 +08:00
|
|
|
TEST_F(DeviceTest, givenNoPciBusInfoThenIsPciBusInfoValidReturnsFalse) {
|
|
|
|
PhysicalDevicePciBusInfo invalidPciBusInfoList[] = {
|
|
|
|
PhysicalDevicePciBusInfo(0, 1, 2, PhysicalDevicePciBusInfo::InvalidValue),
|
|
|
|
PhysicalDevicePciBusInfo(0, 1, PhysicalDevicePciBusInfo::InvalidValue, 3),
|
|
|
|
PhysicalDevicePciBusInfo(0, PhysicalDevicePciBusInfo::InvalidValue, 2, 3),
|
|
|
|
PhysicalDevicePciBusInfo(PhysicalDevicePciBusInfo::InvalidValue, 1, 2, 3)};
|
|
|
|
|
|
|
|
for (auto pciBusInfo : invalidPciBusInfoList) {
|
|
|
|
auto driverInfo = new DriverInfoMock();
|
|
|
|
driverInfo->setPciBusInfo(pciBusInfo);
|
|
|
|
|
|
|
|
pClDevice->driverInfo.reset(driverInfo);
|
|
|
|
pClDevice->initializeCaps();
|
|
|
|
|
|
|
|
EXPECT_FALSE(pClDevice->isPciBusInfoValid());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, givenPciBusInfoThenIsPciBusInfoValidReturnsTrue) {
|
|
|
|
PhysicalDevicePciBusInfo pciBusInfo(0, 1, 2, 3);
|
|
|
|
|
|
|
|
auto driverInfo = new DriverInfoMock();
|
|
|
|
driverInfo->setPciBusInfo(pciBusInfo);
|
|
|
|
|
|
|
|
pClDevice->driverInfo.reset(driverInfo);
|
|
|
|
pClDevice->initializeCaps();
|
|
|
|
|
|
|
|
EXPECT_TRUE(pClDevice->isPciBusInfoValid());
|
|
|
|
}
|
|
|
|
|
2020-02-21 22:25:04 +08:00
|
|
|
HWTEST_F(DeviceTest, WhenDeviceIsCreatedThenActualEngineTypeIsSameAsDefault) {
|
2020-03-24 18:42:54 +08:00
|
|
|
HardwareInfo hwInfo = *defaultHwInfo;
|
2020-02-21 22:25:04 +08:00
|
|
|
if (hwInfo.capabilityTable.defaultEngineType == aub_stream::EngineType::ENGINE_CCS) {
|
2021-11-25 17:31:14 +08:00
|
|
|
hwInfo.featureTable.flags.ftrCCSNode = true;
|
2020-02-21 22:25:04 +08:00
|
|
|
}
|
2017-11-14 18:15:09 +08:00
|
|
|
|
2020-02-21 22:25:04 +08:00
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
|
2017-11-14 18:15:09 +08:00
|
|
|
|
2020-02-21 22:25:04 +08:00
|
|
|
auto actualEngineType = device->getDefaultEngine().osContext->getEngineType();
|
|
|
|
auto defaultEngineType = device->getHardwareInfo().capabilityTable.defaultEngineType;
|
|
|
|
|
|
|
|
EXPECT_EQ(&device->getDefaultEngine().commandStreamReceiver->getOsContext(), device->getDefaultEngine().osContext);
|
2017-11-14 18:15:09 +08:00
|
|
|
EXPECT_EQ(defaultEngineType, actualEngineType);
|
2021-02-10 23:13:50 +08:00
|
|
|
|
|
|
|
int defaultCounter = 0;
|
2021-12-13 20:45:24 +08:00
|
|
|
const auto &engines = device->getAllEngines();
|
2021-02-10 23:13:50 +08:00
|
|
|
for (const auto &engine : engines) {
|
|
|
|
if (engine.osContext->isDefaultContext()) {
|
|
|
|
defaultCounter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_EQ(defaultCounter, 1);
|
2017-11-14 18:15:09 +08:00
|
|
|
}
|
2018-01-18 16:09:01 +08:00
|
|
|
|
2020-05-25 18:11:30 +08:00
|
|
|
HWTEST_F(DeviceTest, givenNoHwCsrTypeAndModifiedDefaultEngineIndexWhenIsSimulationIsCalledThenTrueIsReturned) {
|
|
|
|
EXPECT_FALSE(pDevice->isSimulation());
|
2020-10-28 23:08:37 +08:00
|
|
|
auto csr = TbxCommandStreamReceiver::create("", false, *pDevice->executionEnvironment, 0, 1);
|
2020-05-25 18:11:30 +08:00
|
|
|
pDevice->defaultEngineIndex = 1;
|
|
|
|
pDevice->resetCommandStreamReceiver(csr);
|
|
|
|
|
|
|
|
EXPECT_TRUE(pDevice->isSimulation());
|
|
|
|
|
|
|
|
std::array<CommandStreamReceiverType, 3> exptectedEngineTypes = {CommandStreamReceiverType::CSR_HW,
|
|
|
|
CommandStreamReceiverType::CSR_TBX,
|
|
|
|
CommandStreamReceiverType::CSR_HW};
|
|
|
|
|
|
|
|
for (uint32_t i = 0u; i < 3u; ++i) {
|
2021-12-13 20:45:24 +08:00
|
|
|
auto engineType = pDevice->allEngines[i].commandStreamReceiver->getType();
|
2020-05-25 18:11:30 +08:00
|
|
|
EXPECT_EQ(exptectedEngineTypes[i], engineType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-20 22:42:58 +08:00
|
|
|
TEST_F(DeviceTest, givenRootDeviceWithSubDevicesWhenCreatingThenRootDeviceContextIsInitialized) {
|
|
|
|
DebugManagerStateRestore restore{};
|
|
|
|
DebugManager.flags.DeferOsContextInitialization.set(1);
|
|
|
|
|
|
|
|
UltDeviceFactory factory(1, 2);
|
|
|
|
MockDevice &device = *factory.rootDevices[0];
|
|
|
|
|
|
|
|
EXPECT_TRUE(device.getDefaultEngine().osContext->isInitialized());
|
|
|
|
}
|
|
|
|
|
2021-04-19 23:06:08 +08:00
|
|
|
HWTEST_F(DeviceTest, givenDeviceWithoutSubDevicesWhenCreatingContextsThenMemoryManagerDefaultContextIsSetCorrectly) {
|
|
|
|
UltDeviceFactory factory(1, 1);
|
|
|
|
MockDevice &device = *factory.rootDevices[0];
|
2021-04-20 20:24:04 +08:00
|
|
|
auto rootDeviceIndex = device.getRootDeviceIndex();
|
2021-04-19 23:06:08 +08:00
|
|
|
MockMemoryManager *memoryManager = static_cast<MockMemoryManager *>(device.getMemoryManager());
|
|
|
|
|
2021-04-20 20:24:04 +08:00
|
|
|
OsContext *defaultOsContextMemoryManager = memoryManager->registeredEngines[memoryManager->defaultEngineIndex[rootDeviceIndex]].osContext;
|
2021-04-19 23:06:08 +08:00
|
|
|
OsContext *defaultOsContextRootDevice = device.getDefaultEngine().osContext;
|
|
|
|
EXPECT_EQ(defaultOsContextRootDevice, defaultOsContextMemoryManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(DeviceTest, givenDeviceWithSubDevicesWhenCreatingContextsThenMemoryManagerDefaultContextIsSetCorrectly) {
|
|
|
|
UltDeviceFactory factory(1, 2);
|
|
|
|
MockDevice &device = *factory.rootDevices[0];
|
2021-04-20 20:24:04 +08:00
|
|
|
auto rootDeviceIndex = device.getRootDeviceIndex();
|
2021-04-19 23:06:08 +08:00
|
|
|
MockMemoryManager *memoryManager = static_cast<MockMemoryManager *>(device.getMemoryManager());
|
|
|
|
|
2021-04-20 20:24:04 +08:00
|
|
|
OsContext *defaultOsContextMemoryManager = memoryManager->registeredEngines[memoryManager->defaultEngineIndex[rootDeviceIndex]].osContext;
|
2021-04-19 23:06:08 +08:00
|
|
|
OsContext *defaultOsContextRootDevice = device.getDefaultEngine().osContext;
|
|
|
|
EXPECT_EQ(defaultOsContextRootDevice, defaultOsContextMemoryManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(DeviceTest, givenMultiDeviceWhenCreatingContextsThenMemoryManagerDefaultContextIsSetCorrectly) {
|
|
|
|
UltDeviceFactory factory(3, 2);
|
|
|
|
MockDevice &device = *factory.rootDevices[2];
|
|
|
|
MockMemoryManager *memoryManager = static_cast<MockMemoryManager *>(device.getMemoryManager());
|
|
|
|
|
2021-04-20 20:24:04 +08:00
|
|
|
for (auto &pRootDevice : factory.rootDevices) {
|
|
|
|
OsContext *defaultOsContextMemoryManager = memoryManager->registeredEngines[memoryManager->defaultEngineIndex[pRootDevice->getRootDeviceIndex()]].osContext;
|
|
|
|
OsContext *defaultOsContextRootDevice = pRootDevice->getDefaultEngine().osContext;
|
|
|
|
EXPECT_EQ(defaultOsContextRootDevice, defaultOsContextMemoryManager);
|
|
|
|
}
|
2021-04-19 23:06:08 +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));
|
2020-10-28 23:08:37 +08:00
|
|
|
MockCommandStreamReceiver *csr = new MockCommandStreamReceiver(*mockDevice->getExecutionEnvironment(), mockDevice->getRootDeviceIndex(), mockDevice->getDeviceBitfield());
|
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);
|
|
|
|
|
2020-02-03 20:19:12 +08:00
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useHwCsr = 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);
|
|
|
|
|
2020-02-03 20:19:12 +08:00
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useHwCsr = 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);
|
|
|
|
|
2020-02-03 20:19:12 +08:00
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useHwCsr = 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) {
|
2021-11-05 00:38:47 +08:00
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
2018-09-06 15:01:13 +08:00
|
|
|
auto memoryManager = device->getMemoryManager();
|
2020-02-21 22:25:04 +08:00
|
|
|
auto numEnginesForDevice = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).size();
|
2021-09-01 00:49:46 +08:00
|
|
|
if (device->getNumGenericSubDevices() > 1) {
|
|
|
|
numEnginesForDevice *= device->getNumGenericSubDevices();
|
2021-12-13 20:45:24 +08:00
|
|
|
numEnginesForDevice += device->allEngines.size();
|
2021-09-03 00:40:42 +08:00
|
|
|
|
|
|
|
if (device->getSubDevice(0)->getNumSubDevices() > 0) {
|
|
|
|
numEnginesForDevice += device->getNumSubDevices();
|
|
|
|
}
|
|
|
|
} else if (device->getNumSubDevices() > 0) {
|
|
|
|
numEnginesForDevice += device->getNumSubDevices();
|
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) {
|
2020-02-03 23:18:21 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platform()->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);
|
2020-03-04 15:51:02 +08:00
|
|
|
for (auto i = 0u; i < numDevices; i++) {
|
2020-03-25 01:07:46 +08:00
|
|
|
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
2021-11-05 00:38:47 +08:00
|
|
|
executionEnvironment->rootDeviceEnvironments[i]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true;
|
2020-03-04 15:51:02 +08:00
|
|
|
}
|
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
|
|
|
|
2021-09-03 00:40:42 +08:00
|
|
|
MockDevice *devices[] = {device1.get(), device2.get()};
|
|
|
|
|
2019-01-23 18:59:54 +08:00
|
|
|
auto ®isteredEngines = executionEnvironment->memoryManager->getRegisteredEngines();
|
2021-09-03 00:40:42 +08:00
|
|
|
|
|
|
|
auto &hwInfo = device1->getHardwareInfo();
|
|
|
|
const auto &numGpgpuEngines = static_cast<uint32_t>(HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).size());
|
|
|
|
|
|
|
|
size_t numExpectedGenericEnginesPerDevice = numGpgpuEngines;
|
|
|
|
size_t numExpectedEngineInstancedEnginesPerDevice = 0;
|
|
|
|
if (device1->getNumSubDevices() > 0) {
|
|
|
|
numExpectedEngineInstancedEnginesPerDevice = device1->getNumSubDevices();
|
2018-11-28 16:02:55 +08:00
|
|
|
}
|
2021-09-03 00:40:42 +08:00
|
|
|
|
|
|
|
auto expectedTotalRegisteredEngines = (numExpectedGenericEnginesPerDevice + numExpectedEngineInstancedEnginesPerDevice) * numDevices;
|
|
|
|
|
|
|
|
EXPECT_EQ(expectedTotalRegisteredEngines, registeredEngines.size());
|
|
|
|
|
|
|
|
uint32_t contextId = 0;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < numDevices; i++) {
|
|
|
|
auto device = devices[i];
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < numExpectedEngineInstancedEnginesPerDevice; j++) {
|
|
|
|
auto subDevice = device->getSubDevice(j);
|
|
|
|
auto &engine = subDevice->getEngine(0);
|
|
|
|
EXPECT_EQ(contextId, engine.osContext->getContextId());
|
|
|
|
EXPECT_EQ(1u, engine.osContext->getDeviceBitfield().to_ulong());
|
|
|
|
|
|
|
|
EXPECT_EQ(registeredEngines[contextId].commandStreamReceiver,
|
|
|
|
engine.commandStreamReceiver);
|
|
|
|
|
|
|
|
contextId++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < numExpectedGenericEnginesPerDevice; j++) {
|
|
|
|
auto &engine = device->getEngine(j);
|
|
|
|
|
|
|
|
EXPECT_EQ(contextId, engine.osContext->getContextId());
|
|
|
|
EXPECT_EQ(1u, engine.osContext->getDeviceBitfield().to_ulong());
|
|
|
|
|
|
|
|
EXPECT_EQ(registeredEngines[contextId].commandStreamReceiver,
|
|
|
|
engine.commandStreamReceiver);
|
|
|
|
|
|
|
|
contextId++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_EQ(expectedTotalRegisteredEngines, executionEnvironment->memoryManager->getRegisteredEnginesCount());
|
2018-09-06 21:54:29 +08:00
|
|
|
}
|
|
|
|
|
2019-10-24 19:34:25 +08:00
|
|
|
TEST(DeviceCreation, givenMultiRootDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
|
2020-02-03 23:18:21 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platform()->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);
|
2020-03-04 15:51:02 +08:00
|
|
|
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
2020-03-25 01:07:46 +08:00
|
|
|
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
2020-03-04 15:51:02 +08:00
|
|
|
}
|
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) {
|
2020-02-03 23:18:21 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platform()->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);
|
2020-03-04 15:51:02 +08:00
|
|
|
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
2020-03-25 01:07:46 +08:00
|
|
|
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
2021-11-05 00:38:47 +08:00
|
|
|
executionEnvironment->rootDeviceEnvironments[i]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true;
|
2020-03-04 15:51:02 +08:00
|
|
|
}
|
2021-11-05 00:38:47 +08:00
|
|
|
auto hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
2020-03-03 16:21:18 +08:00
|
|
|
const auto &numGpgpuEngines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).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++) {
|
2021-12-13 20:45:24 +08:00
|
|
|
EXPECT_NE(device2->allEngines[i].commandStreamReceiver, device1->allEngines[i].commandStreamReceiver);
|
2018-11-23 21:59:27 +08:00
|
|
|
}
|
2018-09-11 21:55:04 +08:00
|
|
|
}
|
|
|
|
|
2020-02-21 22:25:04 +08:00
|
|
|
HWTEST_F(DeviceTest, givenDeviceWhenAskingForDefaultEngineThenReturnValidValue) {
|
2020-02-03 23:18:21 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
|
2020-03-04 15:51:02 +08:00
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1u);
|
2020-02-21 22:25:04 +08:00
|
|
|
auto &hwHelper = HwHelperHw<FamilyType>::get();
|
2020-03-04 15:51:02 +08:00
|
|
|
hwHelper.adjustDefaultEngineType(executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo());
|
2020-02-21 22:25:04 +08:00
|
|
|
|
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
|
|
|
|
2020-03-03 16:21:18 +08:00
|
|
|
EXPECT_EQ(device->getHardwareInfo().capabilityTable.defaultEngineType, osContext->getEngineType());
|
2019-03-20 17:56:22 +08:00
|
|
|
EXPECT_FALSE(osContext->isLowPriority());
|
2018-11-28 16:02:55 +08:00
|
|
|
}
|
|
|
|
|
2021-02-17 01:04:00 +08:00
|
|
|
HWTEST_F(DeviceTest, givenDebugFlagWhenCreatingRootDeviceWithSubDevicesThenWorkPartitionAllocationIsCreatedForRootDevice) {
|
|
|
|
DebugManagerStateRestore restore{};
|
|
|
|
{
|
|
|
|
UltDeviceFactory deviceFactory{1, 2};
|
2021-03-15 19:56:52 +08:00
|
|
|
EXPECT_NE(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
2021-02-17 01:04:00 +08:00
|
|
|
EXPECT_EQ(nullptr, deviceFactory.subDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.subDevices[1]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
2021-03-15 19:56:52 +08:00
|
|
|
EXPECT_TRUE(deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
|
|
|
EXPECT_FALSE(deviceFactory.subDevices[0]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
|
|
|
EXPECT_FALSE(deviceFactory.subDevices[1]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
2021-02-17 01:04:00 +08:00
|
|
|
}
|
|
|
|
{
|
|
|
|
DebugManager.flags.EnableStaticPartitioning.set(0);
|
|
|
|
UltDeviceFactory deviceFactory{1, 2};
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.subDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.subDevices[1]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
2021-03-15 19:56:52 +08:00
|
|
|
EXPECT_FALSE(deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
|
|
|
EXPECT_FALSE(deviceFactory.subDevices[0]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
|
|
|
EXPECT_FALSE(deviceFactory.subDevices[1]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
2021-02-17 01:04:00 +08:00
|
|
|
}
|
|
|
|
{
|
|
|
|
DebugManager.flags.EnableStaticPartitioning.set(1);
|
|
|
|
UltDeviceFactory deviceFactory{1, 2};
|
|
|
|
EXPECT_NE(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.subDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.subDevices[1]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
2021-03-15 19:56:52 +08:00
|
|
|
EXPECT_TRUE(deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
|
|
|
EXPECT_FALSE(deviceFactory.subDevices[0]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
|
|
|
EXPECT_FALSE(deviceFactory.subDevices[1]->getDefaultEngine().commandStreamReceiver->isStaticWorkPartitioningEnabled());
|
2021-02-17 01:04:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(DeviceTest, givenDebugFlagWhenCreatingRootDeviceWithoutSubDevicesThenWorkPartitionAllocationIsNotCreated) {
|
|
|
|
DebugManagerStateRestore restore{};
|
|
|
|
{
|
|
|
|
UltDeviceFactory deviceFactory{1, 1};
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
DebugManager.flags.EnableStaticPartitioning.set(0);
|
|
|
|
UltDeviceFactory deviceFactory{1, 1};
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
DebugManager.flags.EnableStaticPartitioning.set(1);
|
|
|
|
UltDeviceFactory deviceFactory{1, 1};
|
|
|
|
EXPECT_EQ(nullptr, deviceFactory.rootDevices[0]->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocation());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-11 16:32:17 +08:00
|
|
|
TEST(DeviceCreation, givenFtrSimulationModeFlagTrueWhenNoOtherSimulationFlagsArePresentThenIsSimulationReturnsTrue) {
|
2020-03-24 18:42:54 +08:00
|
|
|
HardwareInfo hwInfo = *defaultHwInfo;
|
2021-11-25 17:31:14 +08:00
|
|
|
hwInfo.featureTable.flags.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
|
|
|
|
2021-06-29 00:24:32 +08:00
|
|
|
TEST(DeviceCreation, givenDeviceWhenCheckingGpgpuEnginesCountThenNumberGreaterThanZeroIsReturned) {
|
2019-05-15 21:12:55 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2021-08-17 02:24:13 +08:00
|
|
|
auto &hwHelper = HwHelper::get(renderCoreFamily);
|
|
|
|
EXPECT_GT(hwHelper.getGpgpuEngineInstances(device->getHardwareInfo()).size(), 0u);
|
2019-05-15 21:12:55 +08:00
|
|
|
}
|
2019-11-05 20:38:20 +08:00
|
|
|
|
2020-07-15 18:38:34 +08:00
|
|
|
TEST(DeviceCreation, givenDeviceWhenCheckingParentDeviceThenCorrectValueIsReturned) {
|
|
|
|
UltDeviceFactory deviceFactory{2, 2};
|
|
|
|
|
2021-04-08 01:00:33 +08:00
|
|
|
EXPECT_EQ(deviceFactory.rootDevices[0], deviceFactory.rootDevices[0]->getRootDevice());
|
|
|
|
EXPECT_EQ(deviceFactory.rootDevices[0], deviceFactory.subDevices[0]->getRootDevice());
|
|
|
|
EXPECT_EQ(deviceFactory.rootDevices[0], deviceFactory.subDevices[1]->getRootDevice());
|
2020-07-15 18:38:34 +08:00
|
|
|
|
2021-04-08 01:00:33 +08:00
|
|
|
EXPECT_EQ(deviceFactory.rootDevices[1], deviceFactory.rootDevices[1]->getRootDevice());
|
|
|
|
EXPECT_EQ(deviceFactory.rootDevices[1], deviceFactory.subDevices[2]->getRootDevice());
|
|
|
|
EXPECT_EQ(deviceFactory.rootDevices[1], deviceFactory.subDevices[3]->getRootDevice());
|
2020-07-15 18:38:34 +08:00
|
|
|
}
|
|
|
|
|
2020-12-30 21:36:22 +08:00
|
|
|
TEST(DeviceCreation, givenRootDeviceWithSubDevicesWhenCheckingEngineGroupsThenItHasOneNonEmptyGroup) {
|
|
|
|
UltDeviceFactory deviceFactory{1, 2};
|
2021-12-13 20:45:24 +08:00
|
|
|
EXPECT_EQ(1u, deviceFactory.rootDevices[0]->getRegularEngineGroups().size());
|
2021-12-03 22:30:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceCreation, whenCheckingEngineGroupsThenGroupsAreUnique) {
|
|
|
|
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
|
|
|
defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
|
|
|
|
|
|
|
|
for (auto ftrGpGpuMidThreadLevelPreempt : ::testing::Bool()) {
|
|
|
|
defaultHwInfo->featureTable.flags.ftrGpGpuMidThreadLevelPreempt = ftrGpGpuMidThreadLevelPreempt;
|
|
|
|
for (auto blitterOperationsSupported : ::testing::Bool()) {
|
|
|
|
defaultHwInfo->capabilityTable.blitterOperationsSupported = blitterOperationsSupported;
|
|
|
|
for (auto ftrRcsNode : ::testing::Bool()) {
|
|
|
|
defaultHwInfo->featureTable.flags.ftrRcsNode = ftrRcsNode;
|
|
|
|
for (auto ftrCCSNode : ::testing::Bool()) {
|
|
|
|
defaultHwInfo->featureTable.flags.ftrCCSNode = ftrCCSNode;
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0};
|
|
|
|
std::set<EngineGroupType> uniqueEngineGroupTypes;
|
2021-12-13 20:45:24 +08:00
|
|
|
for (auto &engineGroup : deviceFactory.rootDevices[0]->getRegularEngineGroups()) {
|
2021-12-03 22:30:46 +08:00
|
|
|
uniqueEngineGroupTypes.insert(engineGroup.engineGroupType);
|
|
|
|
}
|
2021-12-13 20:45:24 +08:00
|
|
|
EXPECT_EQ(uniqueEngineGroupTypes.size(), deviceFactory.rootDevices[0]->getRegularEngineGroups().size());
|
2021-12-03 22:30:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-30 21:36:22 +08:00
|
|
|
}
|
|
|
|
|
2019-11-05 20:38:20 +08:00
|
|
|
using DeviceHwTest = ::testing::Test;
|
|
|
|
|
2019-12-27 18:32:12 +08:00
|
|
|
HWTEST_F(DeviceHwTest, givenHwHelperInputWhenInitializingCsrThenCreatePageTableManagerIfNeeded) {
|
2020-03-24 18:42:54 +08:00
|
|
|
HardwareInfo localHwInfo = *defaultHwInfo;
|
2019-11-05 20:38:20 +08:00
|
|
|
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
|
|
|
|
|
2020-01-30 16:36:05 +08:00
|
|
|
MockExecutionEnvironment executionEnvironment;
|
2019-12-27 18:32:12 +08:00
|
|
|
executionEnvironment.prepareRootDeviceEnvironments(3);
|
2019-11-05 20:38:20 +08:00
|
|
|
executionEnvironment.incRefInternal();
|
2020-03-04 15:51:02 +08:00
|
|
|
for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) {
|
|
|
|
executionEnvironment.rootDeviceEnvironments[i]->setHwInfo(&localHwInfo);
|
|
|
|
}
|
2019-11-05 20:38:20 +08:00
|
|
|
executionEnvironment.initializeMemoryManager();
|
|
|
|
std::unique_ptr<MockDevice> device;
|
|
|
|
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(&localHwInfo, &executionEnvironment, 0));
|
|
|
|
auto &csr0 = device->getUltCommandStreamReceiver<FamilyType>();
|
|
|
|
EXPECT_FALSE(csr0.createPageTableManagerCalled);
|
|
|
|
|
2020-03-04 15:51:02 +08:00
|
|
|
auto hwInfo = executionEnvironment.rootDeviceEnvironments[1]->getMutableHardwareInfo();
|
2019-11-05 20:38:20 +08:00
|
|
|
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>();
|
2021-10-06 20:42:30 +08:00
|
|
|
EXPECT_EQ(csr1.needsPageTableManager(), csr1.createPageTableManagerCalled);
|
2019-11-05 20:38:20 +08:00
|
|
|
|
2020-03-04 15:51:02 +08:00
|
|
|
hwInfo = executionEnvironment.rootDeviceEnvironments[2]->getMutableHardwareInfo();
|
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>();
|
2021-10-06 20:42:30 +08:00
|
|
|
EXPECT_EQ(csr2.needsPageTableManager(), csr2.createPageTableManagerCalled);
|
2019-11-05 20:38:20 +08:00
|
|
|
}
|
2020-01-21 16:35:12 +08:00
|
|
|
|
2020-02-06 03:00:08 +08:00
|
|
|
HWTEST_F(DeviceHwTest, givenDeviceCreationWhenCsrFailsToCreateGlobalSyncAllocationThenReturnNull) {
|
|
|
|
class MockUltCsrThatFailsToCreateGlobalFenceAllocation : public UltCommandStreamReceiver<FamilyType> {
|
|
|
|
public:
|
2020-10-29 22:33:35 +08:00
|
|
|
MockUltCsrThatFailsToCreateGlobalFenceAllocation(ExecutionEnvironment &executionEnvironment,
|
|
|
|
const DeviceBitfield deviceBitfield)
|
2020-10-28 23:08:37 +08:00
|
|
|
: UltCommandStreamReceiver<FamilyType>(executionEnvironment, 0, deviceBitfield) {}
|
2020-02-06 03:00:08 +08:00
|
|
|
bool createGlobalFenceAllocation() override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
class MockDeviceThatFailsToCreateGlobalFenceAllocation : public MockDevice {
|
|
|
|
public:
|
|
|
|
MockDeviceThatFailsToCreateGlobalFenceAllocation(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
|
|
|
: MockDevice(executionEnvironment, deviceIndex) {}
|
|
|
|
std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const override {
|
2020-10-28 23:08:37 +08:00
|
|
|
return std::make_unique<MockUltCsrThatFailsToCreateGlobalFenceAllocation>(*executionEnvironment, getDeviceBitfield());
|
2020-02-06 03:00:08 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto executionEnvironment = platform()->peekExecutionEnvironment();
|
|
|
|
auto mockDevice(MockDevice::create<MockDeviceThatFailsToCreateGlobalFenceAllocation>(executionEnvironment, 0));
|
|
|
|
EXPECT_EQ(nullptr, mockDevice);
|
|
|
|
}
|
|
|
|
|
2021-12-03 22:30:46 +08:00
|
|
|
HWTEST_F(DeviceHwTest, givenBothCcsAndRcsEnginesInDeviceWhenGettingEngineGroupsThenReturnInCorrectOrder) {
|
2021-09-16 22:53:49 +08:00
|
|
|
struct MyHwHelper : HwHelperHw<FamilyType> {
|
2021-09-17 12:55:21 +08:00
|
|
|
EngineGroupType getEngineGroupType(aub_stream::EngineType engineType, EngineUsage engineUsage, const HardwareInfo &hwInfo) const override {
|
2021-09-16 22:53:49 +08:00
|
|
|
if (engineType == aub_stream::ENGINE_RCS) {
|
|
|
|
return EngineGroupType::RenderCompute;
|
|
|
|
}
|
|
|
|
if (EngineHelpers::isCcs(engineType)) {
|
|
|
|
return EngineGroupType::Compute;
|
|
|
|
}
|
|
|
|
UNRECOVERABLE_IF(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
RAIIHwHelperFactory<MyHwHelper> overrideHwHelper{::defaultHwInfo->platform.eRenderCoreFamily};
|
|
|
|
|
|
|
|
MockOsContext rcsContext(0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_RCS, EngineUsage::Regular}));
|
|
|
|
EngineControl rcsEngine{nullptr, &rcsContext};
|
|
|
|
|
|
|
|
MockOsContext ccsContext(1, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::EngineType::ENGINE_CCS, EngineUsage::Regular}));
|
|
|
|
EngineControl ccsEngine{nullptr, &ccsContext};
|
|
|
|
|
|
|
|
MockDevice device{};
|
2021-12-13 20:45:24 +08:00
|
|
|
ASSERT_EQ(0u, device.getRegularEngineGroups().size());
|
2021-12-03 22:30:46 +08:00
|
|
|
device.addEngineToEngineGroup(ccsEngine);
|
|
|
|
device.addEngineToEngineGroup(rcsEngine);
|
2021-12-13 20:45:24 +08:00
|
|
|
auto &engineGroups = device.getRegularEngineGroups();
|
2021-12-03 22:30:46 +08:00
|
|
|
EXPECT_EQ(1u, engineGroups[0].engines.size());
|
|
|
|
EXPECT_EQ(EngineGroupType::Compute, engineGroups[0].engineGroupType);
|
|
|
|
EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, engineGroups[0].engines[0].getEngineType());
|
|
|
|
EXPECT_EQ(1u, engineGroups[1].engines.size());
|
|
|
|
EXPECT_EQ(EngineGroupType::RenderCompute, engineGroups[1].engineGroupType);
|
|
|
|
EXPECT_EQ(aub_stream::EngineType::ENGINE_RCS, engineGroups[1].engines[0].getEngineType());
|
|
|
|
|
2021-12-13 20:45:24 +08:00
|
|
|
device.getRegularEngineGroups().clear();
|
2021-09-16 22:53:49 +08:00
|
|
|
device.addEngineToEngineGroup(rcsEngine);
|
|
|
|
device.addEngineToEngineGroup(ccsEngine);
|
2021-12-13 20:45:24 +08:00
|
|
|
engineGroups = device.getRegularEngineGroups();
|
2021-12-03 22:30:46 +08:00
|
|
|
EXPECT_EQ(1u, engineGroups[0].engines.size());
|
|
|
|
EXPECT_EQ(EngineGroupType::RenderCompute, engineGroups[0].engineGroupType);
|
|
|
|
EXPECT_EQ(aub_stream::EngineType::ENGINE_RCS, engineGroups[0].engines[0].getEngineType());
|
|
|
|
EXPECT_EQ(1u, engineGroups[1].engines.size());
|
|
|
|
EXPECT_EQ(EngineGroupType::Compute, engineGroups[1].engineGroupType);
|
|
|
|
EXPECT_EQ(aub_stream::EngineType::ENGINE_CCS, engineGroups[1].engines[0].getEngineType());
|
2021-09-16 22:53:49 +08:00
|
|
|
}
|
|
|
|
|
2021-06-25 19:34:12 +08:00
|
|
|
TEST(DeviceGetEngineTest, givenHwCsrModeWhenGetEngineThenDedicatedForInternalUsageEngineIsReturned) {
|
2020-01-21 16:35:12 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
|
|
|
|
|
|
|
auto &internalEngine = device->getInternalEngine();
|
|
|
|
auto &defaultEngine = device->getDefaultEngine();
|
|
|
|
EXPECT_NE(defaultEngine.commandStreamReceiver, internalEngine.commandStreamReceiver);
|
|
|
|
}
|
2020-02-10 16:44:00 +08:00
|
|
|
|
2021-06-25 19:34:12 +08:00
|
|
|
TEST(DeviceGetEngineTest, whenCreateDeviceThenInternalEngineHasDefaultType) {
|
2020-02-10 16:44:00 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
|
|
|
|
|
|
|
auto internalEngineType = device->getInternalEngine().osContext->getEngineType();
|
|
|
|
auto defaultEngineType = getChosenEngineType(device->getHardwareInfo());
|
|
|
|
EXPECT_EQ(defaultEngineType, internalEngineType);
|
|
|
|
}
|
2020-03-07 02:02:24 +08:00
|
|
|
|
2021-06-25 19:34:12 +08:00
|
|
|
TEST(DeviceGetEngineTest, givenCreatedDeviceWhenRetrievingDefaultEngineThenOsContextHasDefaultFieldSet) {
|
2020-03-07 02:02:24 +08:00
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
|
|
|
|
|
|
|
auto &defaultEngine = device->getDefaultEngine();
|
|
|
|
EXPECT_TRUE(defaultEngine.osContext->isDefaultContext());
|
|
|
|
}
|
2020-11-16 19:43:03 +08:00
|
|
|
|
2021-12-03 22:30:46 +08:00
|
|
|
TEST(DeviceGetEngineTest, givenVariousIndicesWhenGettingEngineGroupIndexFromEngineGroupTypeThenReturnCorrectResults) {
|
2020-11-16 19:43:03 +08:00
|
|
|
const auto nonEmptyEngineGroup = std::vector<EngineControl>{EngineControl{nullptr, nullptr}};
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2021-12-13 20:45:24 +08:00
|
|
|
auto &engineGroups = device->getRegularEngineGroups();
|
2021-12-03 22:30:46 +08:00
|
|
|
engineGroups.resize(3);
|
|
|
|
engineGroups[0].engineGroupType = static_cast<EngineGroupType>(4);
|
|
|
|
engineGroups[1].engineGroupType = static_cast<EngineGroupType>(3);
|
|
|
|
engineGroups[2].engineGroupType = static_cast<EngineGroupType>(2);
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(4u)));
|
|
|
|
EXPECT_EQ(1u, device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(3u)));
|
|
|
|
EXPECT_EQ(2u, device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(2u)));
|
|
|
|
EXPECT_ANY_THROW(device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(1u)));
|
|
|
|
EXPECT_ANY_THROW(device->getEngineGroupIndexFromEngineGroupType(static_cast<EngineGroupType>(0u)));
|
2021-01-20 01:32:22 +08:00
|
|
|
}
|
|
|
|
|
2021-06-25 19:34:12 +08:00
|
|
|
TEST(DeviceGetEngineTest, givenDeferredContextInitializationEnabledWhenCreatingEnginesThenInitializeOnlyOsContextsWhichRequireIt) {
|
2021-04-16 00:14:04 +08:00
|
|
|
DebugManagerStateRestore restore{};
|
|
|
|
DebugManager.flags.DeferOsContextInitialization.set(1);
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
|
|
|
const auto defaultEngineType = getChosenEngineType(device->getHardwareInfo());
|
2021-12-13 20:45:24 +08:00
|
|
|
EXPECT_NE(0u, device->getAllEngines().size());
|
|
|
|
for (const EngineControl &engine : device->getAllEngines()) {
|
2021-04-16 00:14:04 +08:00
|
|
|
OsContext *osContext = engine.osContext;
|
|
|
|
const bool isDefaultEngine = defaultEngineType == osContext->getEngineType() && osContext->isRegular();
|
|
|
|
const bool shouldBeInitialized = osContext->isImmediateContextInitializationEnabled(isDefaultEngine);
|
|
|
|
EXPECT_EQ(shouldBeInitialized, osContext->isInitialized());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-25 19:34:12 +08:00
|
|
|
TEST(DeviceGetEngineTest, givenDeferredContextInitializationDisabledWhenCreatingEnginesThenInitializeAllOsContexts) {
|
2021-04-16 00:14:04 +08:00
|
|
|
DebugManagerStateRestore restore{};
|
|
|
|
DebugManager.flags.DeferOsContextInitialization.set(0);
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
2021-12-13 20:45:24 +08:00
|
|
|
EXPECT_NE(0u, device->getAllEngines().size());
|
|
|
|
for (const EngineControl &engine : device->getAllEngines()) {
|
2021-04-16 00:14:04 +08:00
|
|
|
EXPECT_TRUE(engine.osContext->isInitialized());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-25 19:34:12 +08:00
|
|
|
TEST(DeviceGetEngineTest, givenNonHwCsrModeWhenGetEngineThenDefaultEngineIsReturned) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB);
|
|
|
|
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useHwCsr = true;
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
|
|
|
|
|
|
|
|
auto &internalEngine = device->getInternalEngine();
|
|
|
|
auto &defaultEngine = device->getDefaultEngine();
|
|
|
|
EXPECT_EQ(defaultEngine.commandStreamReceiver, internalEngine.commandStreamReceiver);
|
|
|
|
}
|
|
|
|
|
2021-01-28 21:28:51 +08:00
|
|
|
using DeviceQueueFamiliesTests = ::testing::Test;
|
|
|
|
|
|
|
|
HWTEST_F(DeviceQueueFamiliesTests, whenGettingQueueFamilyCapabilitiesAllThenReturnCorrectValue) {
|
2020-12-15 02:07:09 +08:00
|
|
|
const cl_command_queue_capabilities_intel expectedProperties = CL_QUEUE_CAPABILITY_CREATE_SINGLE_QUEUE_EVENTS_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_CREATE_CROSS_QUEUE_EVENTS_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_SINGLE_QUEUE_EVENT_WAIT_LIST_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_CROSS_QUEUE_EVENT_WAIT_LIST_INTEL |
|
2020-11-24 22:49:04 +08:00
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_RECT_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_MAP_BUFFER_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_FILL_BUFFER_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_MAP_IMAGE_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_FILL_IMAGE_INTEL |
|
2020-12-08 20:40:04 +08:00
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_IMAGE_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_BUFFER_INTEL |
|
2020-11-24 22:49:04 +08:00
|
|
|
CL_QUEUE_CAPABILITY_MARKER_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_BARRIER_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_KERNEL_INTEL;
|
|
|
|
EXPECT_EQ(expectedProperties, MockClDevice::getQueueFamilyCapabilitiesAll());
|
|
|
|
}
|
|
|
|
|
2021-01-28 21:28:51 +08:00
|
|
|
HWTEST_F(DeviceQueueFamiliesTests, givenComputeQueueWhenGettingQueueFamilyCapabilitiesThenReturnDefaultCapabilities) {
|
2020-11-24 22:49:04 +08:00
|
|
|
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
2020-12-08 20:40:04 +08:00
|
|
|
EXPECT_EQ(CL_QUEUE_DEFAULT_CAPABILITIES_INTEL, device->getQueueFamilyCapabilities(NEO::EngineGroupType::Compute));
|
|
|
|
EXPECT_EQ(CL_QUEUE_DEFAULT_CAPABILITIES_INTEL, device->getQueueFamilyCapabilities(NEO::EngineGroupType::RenderCompute));
|
2020-12-17 00:04:38 +08:00
|
|
|
}
|
|
|
|
|
2021-01-28 21:28:51 +08:00
|
|
|
HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueFamiliesTests, givenCopyQueueWhenGettingQueueFamilyCapabilitiesThenDoNotReturnUnsupportedOperations) {
|
2020-12-17 00:04:38 +08:00
|
|
|
const cl_command_queue_capabilities_intel capabilitiesNotSupportedOnBlitter = CL_QUEUE_CAPABILITY_KERNEL_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_FILL_BUFFER_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_FILL_IMAGE_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_IMAGE_INTEL |
|
2021-01-28 21:28:51 +08:00
|
|
|
CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_BUFFER_INTEL |
|
|
|
|
CL_QUEUE_CAPABILITY_CREATE_CROSS_QUEUE_EVENTS_INTEL;
|
2020-12-17 00:04:38 +08:00
|
|
|
const cl_command_queue_capabilities_intel expectedBlitterCapabilities = setBits(MockClDevice::getQueueFamilyCapabilitiesAll(), false, capabilitiesNotSupportedOnBlitter);
|
|
|
|
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
EXPECT_EQ(expectedBlitterCapabilities, device->getQueueFamilyCapabilities(NEO::EngineGroupType::Copy));
|
2020-11-24 22:49:04 +08:00
|
|
|
}
|
2021-06-28 21:44:09 +08:00
|
|
|
|
|
|
|
TEST(ClDeviceHelperTest, givenNonZeroNumberOfTilesWhenPrepareDeviceEnvironmentsCountCalledThenReturnCorrectValue) {
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
FeatureTable skuTable;
|
|
|
|
WorkaroundTable waTable = {};
|
|
|
|
RuntimeCapabilityTable capTable = {};
|
|
|
|
GT_SYSTEM_INFO sysInfo = {};
|
|
|
|
sysInfo.MultiTileArchInfo.IsValid = true;
|
|
|
|
sysInfo.MultiTileArchInfo.TileCount = 3;
|
|
|
|
PLATFORM platform = {};
|
|
|
|
HardwareInfo hwInfo{&platform, &skuTable, &waTable, &sysInfo, capTable};
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(0);
|
|
|
|
|
|
|
|
uint32_t devicesCount = HwHelper::getSubDevicesCount(&hwInfo);
|
|
|
|
EXPECT_EQ(devicesCount, 3u);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ClDeviceHelperTest, givenZeroNumberOfTilesWhenPrepareDeviceEnvironmentsCountCalledThenReturnCorrectValue) {
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
FeatureTable skuTable;
|
|
|
|
WorkaroundTable waTable = {};
|
|
|
|
RuntimeCapabilityTable capTable = {};
|
|
|
|
GT_SYSTEM_INFO sysInfo = {};
|
|
|
|
sysInfo.MultiTileArchInfo.IsValid = true;
|
|
|
|
sysInfo.MultiTileArchInfo.TileCount = 0;
|
|
|
|
PLATFORM platform = {};
|
|
|
|
HardwareInfo hwInfo{&platform, &skuTable, &waTable, &sysInfo, capTable};
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(0);
|
|
|
|
|
|
|
|
uint32_t devicesCount = HwHelper::getSubDevicesCount(&hwInfo);
|
|
|
|
EXPECT_EQ(devicesCount, 1u);
|
2021-02-27 06:02:57 +08:00
|
|
|
}
|