2021-10-29 03:07:28 +08:00
|
|
|
/*
|
2023-01-02 19:14:39 +08:00
|
|
|
* Copyright (C) 2021-2023 Intel Corporation
|
2021-10-29 03:07:28 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-07-28 12:31:52 +08:00
|
|
|
#include "shared/source/device/device.h"
|
2022-12-16 00:01:37 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm.h"
|
2023-01-10 01:14:18 +08:00
|
|
|
#include "shared/source/helpers/driver_model_type.h"
|
2023-08-31 19:56:16 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2023-10-12 08:51:45 +08:00
|
|
|
#include "shared/source/memory_manager/gfx_partition.h"
|
2022-07-25 20:13:27 +08:00
|
|
|
#include "shared/source/os_interface/device_factory.h"
|
2023-01-10 01:14:18 +08:00
|
|
|
#include "shared/source/os_interface/driver_info.h"
|
2022-12-07 19:51:44 +08:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2023-03-06 23:12:14 +08:00
|
|
|
#include "shared/source/os_interface/product_helper_hw.h"
|
2023-11-16 22:24:12 +08:00
|
|
|
#include "shared/source/release_helper/release_helper.h"
|
2021-07-28 12:31:52 +08:00
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2021-12-31 23:23:20 +08:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
2021-11-05 00:38:47 +08:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2022-07-25 20:13:27 +08:00
|
|
|
#include "shared/test/common/helpers/ult_hw_config.h"
|
2021-11-05 00:38:47 +08:00
|
|
|
#include "shared/test/common/helpers/variable_backup.h"
|
2021-12-31 23:23:20 +08:00
|
|
|
#include "shared/test/common/mocks/mock_builtins.h"
|
2021-12-29 00:44:23 +08:00
|
|
|
#include "shared/test/common/mocks/mock_compiler_interface.h"
|
|
|
|
#include "shared/test/common/mocks/mock_compilers.h"
|
2021-11-05 00:38:47 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2023-10-18 16:00:43 +08:00
|
|
|
#include "shared/test/common/mocks/mock_driver_model.h"
|
2023-10-06 07:12:34 +08:00
|
|
|
#include "shared/test/common/mocks/mock_io_functions.h"
|
2022-07-22 02:44:54 +08:00
|
|
|
#include "shared/test/common/mocks/mock_memory_manager.h"
|
2023-03-06 23:12:14 +08:00
|
|
|
#include "shared/test/common/mocks/mock_product_helper.h"
|
2021-11-05 00:38:47 +08:00
|
|
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
2022-07-25 20:13:27 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2021-12-15 01:40:08 +08:00
|
|
|
#include "shared/test/common/test_macros/test.h"
|
2021-10-29 03:07:28 +08:00
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
2021-07-28 12:31:52 +08:00
|
|
|
TEST(DeviceBlitterTest, whenBlitterOperationsSupportIsDisabledThenNoInternalCopyEngineIsReturned) {
|
2021-11-05 00:38:47 +08:00
|
|
|
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
|
|
|
defaultHwInfo->capabilityTable.blitterOperationsSupported = false;
|
2021-10-29 03:07:28 +08:00
|
|
|
|
2021-11-05 00:38:47 +08:00
|
|
|
UltDeviceFactory factory{1, 0};
|
|
|
|
EXPECT_EQ(nullptr, factory.rootDevices[0]->getInternalCopyEngine());
|
2021-10-29 03:07:28 +08:00
|
|
|
}
|
2021-11-09 01:03:15 +08:00
|
|
|
|
2023-03-29 15:42:16 +08:00
|
|
|
TEST(DeviceBlitterTest, givenForceBCSForInternalCopyEngineToIndexZeroWhenGetInternalCopyEngineIsCalledThenInternalMainCopyEngineIsReturned) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.ForceBCSForInternalCopyEngine.set(0);
|
|
|
|
|
|
|
|
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
|
|
|
defaultHwInfo->capabilityTable.blitterOperationsSupported = true;
|
|
|
|
|
|
|
|
UltDeviceFactory factory{1, 0};
|
|
|
|
factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Internal});
|
|
|
|
auto engine = factory.rootDevices[0]->getInternalCopyEngine();
|
|
|
|
EXPECT_NE(nullptr, engine);
|
|
|
|
|
|
|
|
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, engine->getEngineType());
|
|
|
|
EXPECT_EQ(EngineUsage::Internal, engine->getEngineUsage());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceBlitterTest, givenForceBCSForInternalCopyEngineToIndexOneWhenGetInternalLinkCopyEngineIsCalledThenInternalLinkCopyEngineOneIsReturned) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.ForceBCSForInternalCopyEngine.set(1);
|
|
|
|
|
|
|
|
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
|
|
|
defaultHwInfo->capabilityTable.blitterOperationsSupported = true;
|
|
|
|
|
|
|
|
UltDeviceFactory factory{1, 0};
|
|
|
|
factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS1, EngineUsage::Internal});
|
|
|
|
auto engine = factory.rootDevices[0]->getInternalCopyEngine();
|
|
|
|
EXPECT_NE(nullptr, engine);
|
|
|
|
|
|
|
|
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, engine->getEngineType());
|
|
|
|
EXPECT_EQ(EngineUsage::Internal, engine->getEngineUsage());
|
|
|
|
}
|
|
|
|
|
2021-07-28 12:31:52 +08:00
|
|
|
TEST(DeviceBlitterTest, givenBlitterOperationsDisabledWhenCreatingBlitterEngineThenAbort) {
|
2021-11-09 01:03:15 +08:00
|
|
|
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
|
|
|
defaultHwInfo->capabilityTable.blitterOperationsSupported = false;
|
|
|
|
|
|
|
|
UltDeviceFactory factory{1, 0};
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Regular}), std::runtime_error);
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Cooperative}), std::runtime_error);
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Internal}), std::runtime_error);
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::LowPriority}), std::runtime_error);
|
|
|
|
}
|
2021-07-28 12:31:52 +08:00
|
|
|
|
2022-07-06 21:23:03 +08:00
|
|
|
TEST(Device, givenNoDebuggerWhenGettingDebuggerThenNullptrIsReturned) {
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, device->getDebugger());
|
|
|
|
EXPECT_EQ(nullptr, device->getL0Debugger());
|
|
|
|
}
|
|
|
|
|
2023-01-13 15:35:43 +08:00
|
|
|
TEST(Device, givenDeviceWithBrandingStringNameWhenGettingDeviceNameThenBrandingStringIsReturned) {
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
hwInfo.capabilityTable.deviceName = "Custom Device";
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
|
|
|
|
|
|
|
EXPECT_STREQ("Custom Device", device->getDeviceName().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Device, givenDeviceWithoutBrandingStringNameWhenGettingDeviceNameThenGenericNameWithHexadecimalDeviceIdIsReturned) {
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
hwInfo.capabilityTable.deviceName = "";
|
|
|
|
hwInfo.platform.usDeviceID = 0x1AB;
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
|
|
|
|
|
|
|
EXPECT_STREQ("Intel(R) Graphics [0x01ab]", device->getDeviceName().c_str());
|
|
|
|
}
|
|
|
|
|
2022-08-11 22:01:11 +08:00
|
|
|
using DeviceTest = Test<DeviceFixture>;
|
2021-07-28 12:31:52 +08:00
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledAndRtBackedBufferIsNullptrThenMemoryBackedBufferIsCreated) {
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTMemoryBackedBuffer());
|
|
|
|
EXPECT_EQ(false, pDevice->rayTracingIsInitialized());
|
|
|
|
pDevice->initializeRayTracing(0);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTMemoryBackedBuffer());
|
|
|
|
EXPECT_EQ(true, pDevice->rayTracingIsInitialized());
|
|
|
|
pDevice->initializeRayTracing(0);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTMemoryBackedBuffer());
|
|
|
|
EXPECT_EQ(true, pDevice->rayTracingIsInitialized());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledWithUnsupportedBVHLevelsThenNullptrIsReturned) {
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(100));
|
|
|
|
}
|
|
|
|
|
2023-05-15 21:48:46 +08:00
|
|
|
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledWithMockAllocatorThenDispatchGlobalsArrayAllocationIsLockable) {
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.ForceLocalMemoryAccessMode.set(0);
|
|
|
|
auto maxBvhLevel = 3;
|
|
|
|
pDevice->initializeRayTracing(maxBvhLevel);
|
|
|
|
for (auto i = 0; i < maxBvhLevel; i++) {
|
|
|
|
auto rtDispatchGlobals = pDevice->getRTDispatchGlobals(i);
|
|
|
|
EXPECT_NE(nullptr, rtDispatchGlobals);
|
|
|
|
auto dispatchGlobalsArray = rtDispatchGlobals->rtDispatchGlobalsArray;
|
|
|
|
EXPECT_NE(nullptr, dispatchGlobalsArray);
|
|
|
|
EXPECT_FALSE(dispatchGlobalsArray->getDefaultGmm()->resourceParams.Flags.Info.NotLockable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-28 12:31:52 +08:00
|
|
|
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledWithMockAllocatorThenRTDispatchGlobalsIsAllocated) {
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledMultipleTimesWithMockAllocatorThenInitializeRayTracingIsIdempotent) {
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledBeforeInitializationThenNullPtrIsReturned) {
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledWithZeroSizeAndMockAllocatorThenDispatchGlobalsIsReturned) {
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(0));
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(0));
|
|
|
|
}
|
2021-12-27 20:44:57 +08:00
|
|
|
|
2022-04-25 22:54:13 +08:00
|
|
|
TEST_F(DeviceTest, whenAllocateRTDispatchGlobalsIsCalledThenRTDispatchGlobalsIsAllocated) {
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
pDevice->allocateRTDispatchGlobals(3);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
|
|
|
|
}
|
|
|
|
|
2023-03-06 23:12:14 +08:00
|
|
|
TEST_F(DeviceTest, givenNot48bResourceForRtWhenAllocateRTDispatchGlobalsIsCalledThenRTDispatchGlobalsIsAllocatedWithout48bResourceFlag) {
|
|
|
|
auto mockProductHelper = std::make_unique<MockProductHelper>();
|
|
|
|
mockProductHelper->is48bResourceNeededForRayTracingResult = false;
|
|
|
|
std::unique_ptr<ProductHelper> productHelper = std::move(mockProductHelper);
|
|
|
|
auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironmentRef();
|
|
|
|
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
|
|
|
|
memoryManager->validateAllocateProperties = [](const AllocationProperties &properties) -> void {
|
|
|
|
EXPECT_FALSE(properties.flags.resource48Bit);
|
|
|
|
};
|
|
|
|
|
|
|
|
std::swap(rootDeviceEnvironment.productHelper, productHelper);
|
|
|
|
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
pDevice->allocateRTDispatchGlobals(3);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
|
|
|
|
std::swap(rootDeviceEnvironment.productHelper, productHelper);
|
|
|
|
}
|
|
|
|
|
2022-11-04 10:35:20 +08:00
|
|
|
HWTEST2_F(DeviceTest, whenAllocateRTDispatchGlobalsIsCalledAndRTStackAllocationFailsRTDispatchGlobalsIsNotAllocated, IsPVC) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(2);
|
|
|
|
pDevice->deviceBitfield = 3;
|
|
|
|
|
|
|
|
pDevice->subdevices.push_back(new SubDevice(pDevice->executionEnvironment, 0, *pDevice));
|
|
|
|
pDevice->subdevices.push_back(new SubDevice(pDevice->executionEnvironment, 1, *pDevice));
|
|
|
|
|
|
|
|
std::unique_ptr<NEO::MemoryManager> otherMemoryManager;
|
|
|
|
otherMemoryManager = std::make_unique<NEO::MockMemoryManagerWithCapacity>(*pDevice->executionEnvironment);
|
|
|
|
static_cast<NEO::MockMemoryManagerWithCapacity &>(*otherMemoryManager).capacity = 50000000;
|
|
|
|
pDevice->executionEnvironment->memoryManager.swap(otherMemoryManager);
|
|
|
|
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(3));
|
|
|
|
|
|
|
|
pDevice->executionEnvironment->memoryManager.swap(otherMemoryManager);
|
|
|
|
}
|
|
|
|
|
2022-07-22 02:44:54 +08:00
|
|
|
TEST_F(DeviceTest, givenDispatchGlobalsAllocationFailsThenRTDispatchGlobalsInfoIsNull) {
|
|
|
|
std::unique_ptr<NEO::MemoryManager> otherMemoryManager;
|
|
|
|
otherMemoryManager = std::make_unique<NEO::FailMemoryManager>(1, *pDevice->getExecutionEnvironment());
|
|
|
|
pDevice->getExecutionEnvironment()->memoryManager.swap(otherMemoryManager);
|
|
|
|
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
auto rtDispatchGlobalsInfo = pDevice->getRTDispatchGlobals(5);
|
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, rtDispatchGlobalsInfo);
|
|
|
|
|
|
|
|
pDevice->getExecutionEnvironment()->memoryManager.swap(otherMemoryManager);
|
|
|
|
}
|
|
|
|
|
2022-03-28 22:09:31 +08:00
|
|
|
TEST_F(DeviceTest, GivenDeviceWhenGenerateUuidThenValidValuesAreSet) {
|
2022-12-13 00:43:41 +08:00
|
|
|
std::array<uint8_t, ProductHelper::uuidSize> uuid, expectedUuid;
|
2022-03-28 22:09:31 +08:00
|
|
|
pDevice->generateUuid(uuid);
|
|
|
|
uint32_t rootDeviceIndex = pDevice->getRootDeviceIndex();
|
|
|
|
|
|
|
|
expectedUuid.fill(0);
|
|
|
|
memcpy_s(&expectedUuid[0], sizeof(uint32_t), &pDevice->getDeviceInfo().vendorId, sizeof(pDevice->getDeviceInfo().vendorId));
|
|
|
|
memcpy_s(&expectedUuid[4], sizeof(uint32_t), &pDevice->getHardwareInfo().platform.usDeviceID, sizeof(pDevice->getHardwareInfo().platform.usDeviceID));
|
|
|
|
memcpy_s(&expectedUuid[8], sizeof(uint32_t), &rootDeviceIndex, sizeof(rootDeviceIndex));
|
|
|
|
|
2022-12-13 00:43:41 +08:00
|
|
|
EXPECT_EQ(memcmp(&uuid, &expectedUuid, ProductHelper::uuidSize), 0);
|
2022-03-28 22:09:31 +08:00
|
|
|
}
|
|
|
|
|
2023-01-05 22:01:17 +08:00
|
|
|
TEST_F(DeviceTest, GivenDeviceWhenGenerateUuidFromPciBusInfoThenValidValuesAreSet) {
|
|
|
|
std::array<uint8_t, ProductHelper::uuidSize> uuid, expectedUuid;
|
|
|
|
|
|
|
|
PhysicalDevicePciBusInfo pciBusInfo = {1, 1, 1, 1};
|
|
|
|
|
|
|
|
pDevice->generateUuidFromPciBusInfo(pciBusInfo, uuid);
|
|
|
|
|
|
|
|
expectedUuid.fill(0);
|
|
|
|
uint16_t vendorId = 0x8086; // Intel
|
|
|
|
uint16_t deviceId = static_cast<uint16_t>(pDevice->getHardwareInfo().platform.usDeviceID);
|
|
|
|
uint16_t revisionId = static_cast<uint16_t>(pDevice->getHardwareInfo().platform.usRevId);
|
|
|
|
uint16_t pciDomain = static_cast<uint16_t>(pciBusInfo.pciDomain);
|
|
|
|
uint8_t pciBus = static_cast<uint8_t>(pciBusInfo.pciBus);
|
|
|
|
uint8_t pciDevice = static_cast<uint8_t>(pciBusInfo.pciDevice);
|
|
|
|
uint8_t pciFunction = static_cast<uint8_t>(pciBusInfo.pciFunction);
|
|
|
|
|
|
|
|
memcpy_s(&expectedUuid[0], sizeof(uint16_t), &vendorId, sizeof(uint16_t));
|
|
|
|
memcpy_s(&expectedUuid[2], sizeof(uint16_t), &deviceId, sizeof(uint16_t));
|
|
|
|
memcpy_s(&expectedUuid[4], sizeof(uint16_t), &revisionId, sizeof(uint16_t));
|
|
|
|
memcpy_s(&expectedUuid[6], sizeof(uint16_t), &pciDomain, sizeof(uint16_t));
|
|
|
|
memcpy_s(&expectedUuid[8], sizeof(uint8_t), &pciBus, sizeof(uint8_t));
|
|
|
|
memcpy_s(&expectedUuid[9], sizeof(uint8_t), &pciDevice, sizeof(uint8_t));
|
|
|
|
memcpy_s(&expectedUuid[10], sizeof(uint8_t), &pciFunction, sizeof(uint8_t));
|
|
|
|
|
|
|
|
EXPECT_EQ(memcmp(&uuid, &expectedUuid, ProductHelper::uuidSize), 0);
|
|
|
|
}
|
|
|
|
|
2022-08-11 22:01:11 +08:00
|
|
|
using DeviceGetCapsTest = Test<DeviceFixture>;
|
2021-12-27 20:44:57 +08:00
|
|
|
|
2021-12-29 00:44:23 +08:00
|
|
|
TEST_F(DeviceGetCapsTest, givenMockCompilerInterfaceWhenInitializeCapsIsCalledThenMaxParameterSizeIsSetCorrectly) {
|
|
|
|
auto pCompilerInterface = new MockCompilerInterface;
|
|
|
|
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(pCompilerInterface);
|
|
|
|
pDevice->maxParameterSizeFromIGC = 2u;
|
|
|
|
pDevice->callBaseGetMaxParameterSizeFromIGC = true;
|
|
|
|
MockIgcFeaturesAndWorkarounds mockIgcFtrWa;
|
|
|
|
pCompilerInterface->igcFeaturesAndWorkaroundsTagOCL = &mockIgcFtrWa;
|
|
|
|
|
|
|
|
mockIgcFtrWa.maxOCLParamSize = 0u;
|
2021-12-27 20:44:57 +08:00
|
|
|
pDevice->initializeCaps();
|
2021-12-29 00:44:23 +08:00
|
|
|
EXPECT_EQ(2048u, pDevice->getDeviceInfo().maxParameterSize);
|
|
|
|
|
|
|
|
mockIgcFtrWa.maxOCLParamSize = 1u;
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_EQ(1u, pDevice->getDeviceInfo().maxParameterSize);
|
2021-12-31 23:23:20 +08:00
|
|
|
}
|
|
|
|
|
2022-01-13 11:16:39 +08:00
|
|
|
TEST_F(DeviceGetCapsTest,
|
|
|
|
givenImplicitScalingWhenInitializeCapsIsCalledThenMaxMemAllocSizeIsSetCorrectly) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(4);
|
|
|
|
pDevice->deviceBitfield = 15;
|
|
|
|
|
|
|
|
DebugManager.flags.EnableWalkerPartition.set(1);
|
|
|
|
DebugManager.flags.EnableSharedSystemUsmSupport.set(1);
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize == pDevice->getDeviceInfo().globalMemSize);
|
|
|
|
|
|
|
|
DebugManager.flags.EnableWalkerPartition.set(0);
|
|
|
|
DebugManager.flags.EnableSharedSystemUsmSupport.set(1);
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize <= pDevice->getDeviceInfo().globalMemSize);
|
|
|
|
|
|
|
|
DebugManager.flags.EnableWalkerPartition.set(1);
|
|
|
|
DebugManager.flags.EnableSharedSystemUsmSupport.set(0);
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize < pDevice->getDeviceInfo().globalMemSize);
|
|
|
|
|
|
|
|
DebugManager.flags.EnableWalkerPartition.set(0);
|
|
|
|
DebugManager.flags.EnableSharedSystemUsmSupport.set(0);
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize < pDevice->getDeviceInfo().globalMemSize);
|
|
|
|
}
|
|
|
|
|
2022-04-12 23:42:23 +08:00
|
|
|
TEST_F(DeviceGetCapsTest,
|
|
|
|
givenImplicitScalingTrueWhenInitializeCapsIsCalledThenMaxMemAllocSizeIsSetCorrectly) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(4);
|
|
|
|
pDevice->deviceBitfield = 15;
|
|
|
|
|
|
|
|
DebugManager.flags.EnableImplicitScaling.set(1);
|
|
|
|
DebugManager.flags.EnableWalkerPartition.set(1);
|
|
|
|
DebugManager.flags.EnableSharedSystemUsmSupport.set(1);
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize == pDevice->getDeviceInfo().globalMemSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceGetCapsTest,
|
|
|
|
givenImplicitScalingFalseWhenInitializeCapsIsCalledThenMaxMemAllocSizeIsSetCorrectly) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(4);
|
|
|
|
pDevice->deviceBitfield = 15;
|
|
|
|
|
|
|
|
DebugManager.flags.EnableImplicitScaling.set(0);
|
|
|
|
DebugManager.flags.EnableWalkerPartition.set(1);
|
|
|
|
DebugManager.flags.EnableSharedSystemUsmSupport.set(1);
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_TRUE(pDevice->getDeviceInfo().maxMemAllocSize <= pDevice->getDeviceInfo().globalMemSize);
|
|
|
|
}
|
|
|
|
|
2021-12-31 23:23:20 +08:00
|
|
|
TEST_F(DeviceGetCapsTest, givenDontForcePreemptionModeDebugVariableWhenCreateDeviceThenSetDefaultHwPreemptionMode) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
{
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(-1);
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
EXPECT_TRUE(device->getHardwareInfo().capabilityTable.defaultPreemptionMode ==
|
|
|
|
device->getPreemptionMode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceGetCapsTest, givenDebugFlagSetWhenCreatingDeviceInfoThenOverrideProfilingTimerResolution) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
|
|
|
|
DebugManager.flags.OverrideProfilingTimerResolution.set(123);
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
|
|
|
|
EXPECT_EQ(double(123), device->getDeviceInfo().profilingTimerResolution);
|
|
|
|
EXPECT_EQ(123u, device->getDeviceInfo().outProfilingTimerResolution);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceGetCapsTest, givenForcePreemptionModeDebugVariableWhenCreateDeviceThenSetForcedMode) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
{
|
|
|
|
PreemptionMode forceMode = PreemptionMode::MidThread;
|
|
|
|
if (defaultHwInfo->capabilityTable.defaultPreemptionMode == forceMode) {
|
|
|
|
// force non-default mode
|
|
|
|
forceMode = PreemptionMode::ThreadGroup;
|
|
|
|
}
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set((int32_t)forceMode);
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
|
|
|
|
EXPECT_TRUE(forceMode == device->getPreemptionMode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceGetCapsTest, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThenSipKernelIsNotCreated) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
{
|
|
|
|
auto builtIns = new MockBuiltins();
|
2022-05-10 01:40:30 +08:00
|
|
|
ASSERT_FALSE(MockSipData::called); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
|
2021-12-31 23:23:20 +08:00
|
|
|
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::MidThread);
|
|
|
|
|
|
|
|
auto executionEnvironment = new ExecutionEnvironment();
|
|
|
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
|
|
|
executionEnvironment->rootDeviceEnvironments[0u]->builtins.reset(builtIns);
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0u));
|
|
|
|
ASSERT_EQ(builtIns, device->getBuiltIns());
|
|
|
|
EXPECT_FALSE(MockSipData::called);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceGetCapsTest, whenDriverModelHasLimitationForMaxMemoryAllocationSizeThenTakeItIntoAccount) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
size_t maxAllocSizeTestValue = 512;
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
device->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface());
|
2023-10-18 16:00:43 +08:00
|
|
|
auto driverModel = std::make_unique<MockDriverModel>();
|
|
|
|
driverModel->maxAllocSize = maxAllocSizeTestValue;
|
|
|
|
device->executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::move(driverModel));
|
2021-12-31 23:23:20 +08:00
|
|
|
device->initializeCaps();
|
|
|
|
const auto &caps = device->getDeviceInfo();
|
|
|
|
EXPECT_EQ(maxAllocSizeTestValue, caps.maxMemAllocSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceGetCapsTest, WhenDeviceIsCreatedThenVmeIsEnabled) {
|
|
|
|
DebugSettingsManager<DebugFunctionalityLevel::RegKeys> freshDebugSettingsManager("");
|
|
|
|
EXPECT_TRUE(freshDebugSettingsManager.flags.EnableIntelVme.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceGetCapsSimpleTest, givenVariousOclVersionsWhenCapsAreCreatedThenDeviceReportsSpirvAsSupportedIl) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
int32_t oclVersionsToTest[] = {12, 21, 30};
|
|
|
|
for (auto oclVersion : oclVersionsToTest) {
|
|
|
|
DebugManager.flags.ForceOCLVersion.set(oclVersion);
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
const auto &caps = device->getDeviceInfo();
|
|
|
|
EXPECT_STREQ("SPIR-V_1.2 ", caps.ilVersion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceGetCapsSimpleTest, givenDebugFlagToSetWorkgroupSizeWhenDeviceIsCreatedThenItUsesThatWorkgroupSize) {
|
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
DebugManager.flags.OverrideMaxWorkgroupSize.set(16u);
|
|
|
|
|
|
|
|
HardwareInfo myHwInfo = *defaultHwInfo;
|
|
|
|
GT_SYSTEM_INFO &mySysInfo = myHwInfo.gtSystemInfo;
|
|
|
|
|
|
|
|
mySysInfo.EUCount = 24;
|
|
|
|
mySysInfo.SubSliceCount = 3;
|
|
|
|
mySysInfo.ThreadCount = 24 * 7;
|
|
|
|
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&myHwInfo));
|
|
|
|
|
|
|
|
EXPECT_EQ(16u, device->getDeviceInfo().maxWorkGroupSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceGetCapsTest, givenFlagEnabled64kbPagesWhenCallConstructorMemoryManagerThenReturnCorrectValue) {
|
|
|
|
DebugManagerStateRestore dbgRestore;
|
2022-05-12 22:04:41 +08:00
|
|
|
VariableBackup<bool> osEnabled64kbPagesBackup(&OSInterface::osEnabled64kbPages);
|
2021-12-31 23:23:20 +08:00
|
|
|
class MockMemoryManager : public MemoryManager {
|
|
|
|
public:
|
|
|
|
MockMemoryManager(ExecutionEnvironment &executionEnvironment) : MemoryManager(executionEnvironment) {}
|
|
|
|
void addAllocationToHostPtrManager(GraphicsAllocation *memory) override{};
|
|
|
|
void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) override{};
|
2023-05-04 09:40:52 +08:00
|
|
|
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; }
|
|
|
|
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override { return nullptr; };
|
2022-02-04 21:59:01 +08:00
|
|
|
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { return nullptr; };
|
2021-12-31 23:23:20 +08:00
|
|
|
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override { return AllocationStatus::Success; };
|
|
|
|
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override{};
|
|
|
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{};
|
2022-03-02 11:43:59 +08:00
|
|
|
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override{};
|
2021-12-31 23:23:20 +08:00
|
|
|
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override {
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override { return 0; };
|
|
|
|
double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override { return 0; }
|
2023-03-08 07:04:46 +08:00
|
|
|
AddressRange reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) override {
|
2021-12-31 23:23:20 +08:00
|
|
|
return {};
|
|
|
|
}
|
2023-10-12 08:51:45 +08:00
|
|
|
AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) override {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) override {
|
|
|
|
*heap = HeapIndex::HEAP_STANDARD;
|
|
|
|
return MemoryConstants::pageSize64k;
|
|
|
|
}
|
2021-12-31 23:23:20 +08:00
|
|
|
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override{};
|
|
|
|
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override { return nullptr; };
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) override { return nullptr; };
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override { return nullptr; };
|
|
|
|
GraphicsAllocation *allocateUSMHostGraphicsMemory(const AllocationData &allocationData) override { return nullptr; };
|
|
|
|
GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) override { return nullptr; };
|
2023-09-16 01:20:28 +08:00
|
|
|
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override { return nullptr; };
|
2021-12-31 23:23:20 +08:00
|
|
|
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override { return nullptr; };
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryWithGpuVa(const AllocationData &allocationData) override { return nullptr; };
|
2022-12-07 06:36:12 +08:00
|
|
|
GraphicsAllocation *allocatePhysicalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) override { return nullptr; };
|
|
|
|
GraphicsAllocation *allocatePhysicalLocalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) override { return nullptr; };
|
|
|
|
void unMapPhysicalToVirtualMemory(GraphicsAllocation *physicalAllocation, uint64_t gpuRange, size_t bufferSize, OsContext *osContext, uint32_t rootDeviceIndex) override { return; };
|
|
|
|
bool mapPhysicalToVirtualMemory(GraphicsAllocation *physicalAllocation, uint64_t gpuRange, size_t bufferSize) override { return false; };
|
2021-12-31 23:23:20 +08:00
|
|
|
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr<Gmm> gmm) override { return nullptr; };
|
|
|
|
GraphicsAllocation *allocateMemoryByKMD(const AllocationData &allocationData) override { return nullptr; };
|
|
|
|
void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override { return nullptr; };
|
|
|
|
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override{};
|
|
|
|
};
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment;
|
|
|
|
executionEnvironment.prepareRootDeviceEnvironments(1);
|
|
|
|
auto &capabilityTable = executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable;
|
|
|
|
std::unique_ptr<MemoryManager> memoryManager;
|
|
|
|
|
|
|
|
DebugManager.flags.Enable64kbpages.set(-1);
|
|
|
|
|
|
|
|
capabilityTable.ftr64KBpages = false;
|
|
|
|
OSInterface::osEnabled64kbPages = false;
|
|
|
|
memoryManager.reset(new MockMemoryManager(executionEnvironment));
|
|
|
|
EXPECT_FALSE(memoryManager->peek64kbPagesEnabled(0u));
|
|
|
|
|
|
|
|
capabilityTable.ftr64KBpages = false;
|
|
|
|
OSInterface::osEnabled64kbPages = true;
|
|
|
|
memoryManager.reset(new MockMemoryManager(executionEnvironment));
|
|
|
|
EXPECT_FALSE(memoryManager->peek64kbPagesEnabled(0u));
|
|
|
|
|
|
|
|
capabilityTable.ftr64KBpages = true;
|
|
|
|
OSInterface::osEnabled64kbPages = false;
|
|
|
|
memoryManager.reset(new MockMemoryManager(executionEnvironment));
|
|
|
|
EXPECT_FALSE(memoryManager->peek64kbPagesEnabled(0u));
|
|
|
|
|
|
|
|
capabilityTable.ftr64KBpages = true;
|
|
|
|
OSInterface::osEnabled64kbPages = true;
|
|
|
|
memoryManager.reset(new MockMemoryManager(executionEnvironment));
|
|
|
|
EXPECT_TRUE(memoryManager->peek64kbPagesEnabled(0u));
|
|
|
|
|
|
|
|
DebugManager.flags.Enable64kbpages.set(0); // force false
|
|
|
|
memoryManager.reset(new MockMemoryManager(executionEnvironment));
|
|
|
|
EXPECT_FALSE(memoryManager->peek64kbPagesEnabled(0u));
|
|
|
|
|
|
|
|
DebugManager.flags.Enable64kbpages.set(1); // force true
|
|
|
|
memoryManager.reset(new MockMemoryManager(executionEnvironment));
|
|
|
|
EXPECT_TRUE(memoryManager->peek64kbPagesEnabled(0u));
|
2022-04-12 23:42:23 +08:00
|
|
|
}
|
2022-07-22 02:44:54 +08:00
|
|
|
|
2022-07-25 20:13:27 +08:00
|
|
|
using DeviceTests = ::testing::Test;
|
|
|
|
|
|
|
|
TEST_F(DeviceTests, givenDispatchGlobalsAllocationFailsOnSecondSubDeviceThenRtDispatchGlobalsInfoIsNull) {
|
2022-07-22 02:44:54 +08:00
|
|
|
class FailMockMemoryManager : public MockMemoryManager {
|
|
|
|
public:
|
|
|
|
FailMockMemoryManager(NEO::ExecutionEnvironment &executionEnvironment) : MockMemoryManager(false, false, executionEnvironment) {}
|
|
|
|
|
2022-07-26 13:20:40 +08:00
|
|
|
GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) override {
|
2022-07-22 02:44:54 +08:00
|
|
|
allocateGraphicsMemoryWithPropertiesCount++;
|
|
|
|
if (allocateGraphicsMemoryWithPropertiesCount > 2) {
|
|
|
|
return nullptr;
|
|
|
|
} else {
|
|
|
|
return MockMemoryManager::allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.EnableWalkerPartition.set(-1);
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(2u);
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 2};
|
|
|
|
ExecutionEnvironment &executionEnvironment = *deviceFactory.rootDevices[0]->executionEnvironment;
|
|
|
|
executionEnvironment.memoryManager = std::make_unique<FailMockMemoryManager>(executionEnvironment);
|
|
|
|
|
|
|
|
deviceFactory.rootDevices[0]->initializeRayTracing(5);
|
|
|
|
auto rtDispatchGlobalsInfo = deviceFactory.rootDevices[0]->getRTDispatchGlobals(5);
|
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, rtDispatchGlobalsInfo);
|
|
|
|
}
|
2022-07-25 20:13:27 +08:00
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZexNumberOfCssEnvVariableDefinedWhenDeviceIsCreatedThenCreateDevicesWithProperCcsCount) {
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
DebugManager.flags.ZEX_NUMBER_OF_CCS.set("0:4,1:1,2:2,3:1");
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo, false, 4);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
UltDeviceFactory deviceFactory{4, 0, executionEnvironment};
|
|
|
|
|
|
|
|
{
|
|
|
|
auto device = deviceFactory.rootDevices[0];
|
|
|
|
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
auto expectedNumberOfCcs = std::min(4u, defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
|
|
|
EXPECT_EQ(expectedNumberOfCcs, computeEngineGroup.engines.size());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto device = deviceFactory.rootDevices[1];
|
|
|
|
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
EXPECT_EQ(1u, computeEngineGroup.engines.size());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto device = deviceFactory.rootDevices[2];
|
|
|
|
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
auto expectedNumberOfCcs = std::min(2u, defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
|
|
|
EXPECT_EQ(expectedNumberOfCcs, computeEngineGroup.engines.size());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto device = deviceFactory.rootDevices[3];
|
|
|
|
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
EXPECT_EQ(1u, computeEngineGroup.engines.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-22 16:48:55 +08:00
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenDeviceIsCreatedWithZexNumberOfCssEnvVariableDefinedAndHwInfoCcsCountIsSetToDefaultWhenAdjustCcsCountForSpecificRootDeviceIsInvokedThenVerifyHwInfoCcsCountIsRestored) {
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
DebugManager.flags.ZEX_NUMBER_OF_CCS.set("0:1,1:2");
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo, false, 2);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
|
|
|
{
|
|
|
|
auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo();
|
|
|
|
hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
|
|
|
|
|
|
|
executionEnvironment.adjustCcsCount(0);
|
|
|
|
EXPECT_EQ(1u, hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[1]->getMutableHardwareInfo();
|
|
|
|
hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
|
|
|
|
|
|
|
executionEnvironment.adjustCcsCount(1);
|
|
|
|
EXPECT_EQ(std::min(2u, defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled), hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST2_F(DeviceTests, givenDeviceIsCreatedWithAmbiguousZexNumberOfCssEnvVariableAndHwInfoCcsCountIsModifiedWhenAdjustCcsCountForSpecificDeviceIsInvokedThenVerifyCcsCountIsAdjustedToOne, IsPVC) {
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
for (const auto &numberOfCcsString : {"default", "", "0"}) {
|
|
|
|
DebugManager.flags.ZEX_NUMBER_OF_CCS.set(numberOfCcsString);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
|
|
|
|
|
|
|
auto device = deviceFactory.rootDevices[0];
|
|
|
|
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
EXPECT_EQ(1u, computeEngineGroup.engines.size());
|
|
|
|
|
|
|
|
auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo();
|
|
|
|
hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
|
|
|
|
|
|
|
executionEnvironment.adjustCcsCount(0);
|
|
|
|
EXPECT_EQ(1u, hardwareInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 20:13:27 +08:00
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZexNumberOfCssAndZeAffinityMaskSetWhenDeviceIsCreatedThenProperNumberOfCcsIsExposed) {
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleRootDevices.set(2);
|
|
|
|
DebugManager.flags.ZE_AFFINITY_MASK.set("1");
|
|
|
|
DebugManager.flags.ZEX_NUMBER_OF_CCS.set("0:1,1:2");
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo, false, 2);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
auto devices = DeviceFactory::createDevices(executionEnvironment);
|
|
|
|
|
|
|
|
{
|
|
|
|
auto device = devices[0].get();
|
|
|
|
|
|
|
|
EXPECT_EQ(0u, device->getRootDeviceIndex());
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
EXPECT_EQ(1u, computeEngineGroup.engines.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-16 11:00:31 +08:00
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetAndTilesAsDevicesModelThenProperSubDeviceHierarchyMapisSet) {
|
2023-11-08 20:55:37 +08:00
|
|
|
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "FLAT"}};
|
|
|
|
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
2023-08-16 11:00:31 +08:00
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
uint32_t numRootDevices = 4;
|
|
|
|
uint32_t numSubDevices = 4;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices);
|
|
|
|
|
|
|
|
uint32_t expectedRootDevices = 4;
|
|
|
|
DebugManager.flags.ZE_AFFINITY_MASK.set("0,3,4,1.1,9,15,25");
|
|
|
|
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo, false, numRootDevices);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
auto devices = DeviceFactory::createDevices(executionEnvironment);
|
|
|
|
EXPECT_EQ(devices.size(), expectedRootDevices);
|
|
|
|
std::vector<uint32_t> expectedRootDeviceIndices = {0, 0, 1, 2};
|
|
|
|
std::vector<uint32_t> expectedSubDeviceIndices = {0, 3, 0, 1};
|
|
|
|
for (uint32_t i = 0u; i < devices.size(); i++) {
|
|
|
|
std::tuple<uint32_t, uint32_t, uint32_t> subDeviceMap;
|
|
|
|
EXPECT_TRUE(executionEnvironment.getSubDeviceHierarchy(i, &subDeviceMap));
|
|
|
|
auto hwRootDeviceIndex = std::get<0>(subDeviceMap);
|
|
|
|
auto hwSubDeviceIndex = std::get<1>(subDeviceMap);
|
|
|
|
auto hwSubDevicesCount = std::get<2>(subDeviceMap);
|
|
|
|
EXPECT_EQ(hwRootDeviceIndex, expectedRootDeviceIndices[i]);
|
|
|
|
EXPECT_EQ(hwSubDeviceIndex, expectedSubDeviceIndices[i]);
|
|
|
|
EXPECT_EQ(hwSubDevicesCount, numSubDevices);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-06 07:12:34 +08:00
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetThenProperSubDeviceHierarchyMapIsSet) {
|
|
|
|
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
|
|
|
|
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
|
|
|
|
2023-08-16 11:00:31 +08:00
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
uint32_t numRootDevices = 4;
|
|
|
|
uint32_t numSubDevices = 4;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices);
|
|
|
|
|
|
|
|
uint32_t expectedRootDevices = 4;
|
2023-11-08 20:55:37 +08:00
|
|
|
DebugManager.flags.ZE_AFFINITY_MASK.set("0.2,1.2,2.3,3.3,15,25");
|
2023-08-16 11:00:31 +08:00
|
|
|
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo, false, numRootDevices);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
auto devices = DeviceFactory::createDevices(executionEnvironment);
|
|
|
|
EXPECT_EQ(devices.size(), expectedRootDevices);
|
|
|
|
std::vector<uint32_t> expectedRootDeviceIndices = {0, 1, 2, 3};
|
|
|
|
std::vector<uint32_t> expectedSubDeviceIndices = {2, 2, 3, 3};
|
|
|
|
for (uint32_t i = 0u; i < devices.size(); i++) {
|
|
|
|
std::tuple<uint32_t, uint32_t, uint32_t> subDeviceMap;
|
|
|
|
EXPECT_TRUE(executionEnvironment.getSubDeviceHierarchy(i, &subDeviceMap));
|
|
|
|
auto hwRootDeviceIndex = std::get<0>(subDeviceMap);
|
|
|
|
auto hwSubDeviceIndex = std::get<1>(subDeviceMap);
|
|
|
|
auto hwSubDevicesCount = std::get<2>(subDeviceMap);
|
|
|
|
EXPECT_EQ(hwRootDeviceIndex, expectedRootDeviceIndices[i]);
|
|
|
|
EXPECT_EQ(hwSubDeviceIndex, expectedSubDeviceIndices[i]);
|
|
|
|
EXPECT_EQ(hwSubDevicesCount, numSubDevices);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZeAffinityMaskSetWithoutTilesThenProperSubDeviceHierarchyMapisUnset) {
|
2023-10-06 07:12:34 +08:00
|
|
|
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "COMPOSITE"}};
|
|
|
|
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
|
|
|
|
2023-08-16 11:00:31 +08:00
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
uint32_t numRootDevices = 4;
|
|
|
|
uint32_t numSubDevices = 4;
|
|
|
|
|
|
|
|
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
|
|
|
DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices);
|
|
|
|
|
|
|
|
uint32_t expectedRootDevices = 4;
|
2023-11-08 20:55:37 +08:00
|
|
|
DebugManager.flags.ZE_AFFINITY_MASK.set("0,1,2,3,15,25");
|
2023-08-16 11:00:31 +08:00
|
|
|
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo, false, numRootDevices);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
auto devices = DeviceFactory::createDevices(executionEnvironment);
|
|
|
|
EXPECT_EQ(devices.size(), expectedRootDevices);
|
|
|
|
for (uint32_t i = 0u; i < devices.size(); i++) {
|
|
|
|
std::tuple<uint32_t, uint32_t, uint32_t> subDeviceMap;
|
|
|
|
EXPECT_FALSE(executionEnvironment.getSubDeviceHierarchy(i, &subDeviceMap));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 20:13:27 +08:00
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZexNumberOfCssEnvVariableIsLargerThanNumberOfAvailableCcsCountWhenDeviceIsCreatedThenCreateDevicesWithAvailableCcsCount) {
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
|
|
|
DebugManager.flags.ZEX_NUMBER_OF_CCS.set("0:13");
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
|
|
|
|
|
|
|
auto device = deviceFactory.rootDevices[0];
|
|
|
|
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
EXPECT_EQ(defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled, computeEngineGroup.engines.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenZexNumberOfCssEnvVariableSetAmbigouslyWhenDeviceIsCreatedThenDontApplyAnyLimitations) {
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
for (const auto &numberOfCcsString : {"default", "", "0"}) {
|
|
|
|
DebugManager.flags.ZEX_NUMBER_OF_CCS.set(numberOfCcsString);
|
|
|
|
|
|
|
|
auto hwInfo = *defaultHwInfo;
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
|
|
|
|
|
|
|
auto device = deviceFactory.rootDevices[0];
|
|
|
|
|
|
|
|
auto computeEngineGroupIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::Compute);
|
|
|
|
auto computeEngineGroup = device->getRegularEngineGroups()[computeEngineGroupIndex];
|
|
|
|
EXPECT_EQ(defaultHwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled, computeEngineGroup.engines.size());
|
|
|
|
}
|
|
|
|
}
|
2022-09-19 21:34:14 +08:00
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenDebuggableOsContextWhenDeviceCreatesEnginesThenDeviceIsInitializedWithFirstSubmission) {
|
2023-01-27 20:37:09 +08:00
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useFirstSubmissionInitDevice = true;
|
|
|
|
|
2022-09-19 21:34:14 +08:00
|
|
|
auto hwInfo = *defaultHwInfo;
|
2023-11-16 22:24:12 +08:00
|
|
|
auto releaseHelper = ReleaseHelper::create(hwInfo.ipVersion);
|
|
|
|
hardwareInfoSetup[hwInfo.platform.eProductFamily](&hwInfo, true, 0, releaseHelper.get());
|
2022-09-19 21:34:14 +08:00
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
|
|
|
executionEnvironment.memoryManager.reset(new MockMemoryManagerWithDebuggableOsContext(executionEnvironment));
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
|
|
|
|
|
|
|
auto device = deviceFactory.rootDevices[0];
|
|
|
|
auto csr = device->allEngines[device->defaultEngineIndex].commandStreamReceiver;
|
|
|
|
EXPECT_EQ(1u, csr->peekLatestSentTaskCount());
|
|
|
|
}
|
|
|
|
|
2023-01-27 20:37:09 +08:00
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, whenDeviceCreatesEnginesThenDeviceIsInitializedWithFirstSubmission) {
|
|
|
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
|
|
ultHwConfig.useFirstSubmissionInitDevice = true;
|
|
|
|
|
2022-09-19 21:34:14 +08:00
|
|
|
auto hwInfo = *defaultHwInfo;
|
2023-11-16 22:24:12 +08:00
|
|
|
auto releaseHelper = ReleaseHelper::create(hwInfo.ipVersion);
|
|
|
|
hardwareInfoSetup[hwInfo.platform.eProductFamily](&hwInfo, true, 0, releaseHelper.get());
|
2022-09-19 21:34:14 +08:00
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
|
|
|
|
|
|
|
auto device = deviceFactory.rootDevices[0];
|
|
|
|
auto csr = device->allEngines[device->defaultEngineIndex].commandStreamReceiver;
|
2023-01-27 20:37:09 +08:00
|
|
|
EXPECT_EQ(device->isInitDeviceWithFirstSubmissionSupported(csr->getType()), csr->peekLatestSentTaskCount());
|
2022-11-04 10:35:20 +08:00
|
|
|
}
|
2023-01-19 23:25:41 +08:00
|
|
|
|
|
|
|
TEST(FailDeviceTest, GivenFailedDeviceWhenCreatingDeviceThenNullIsReturned) {
|
|
|
|
auto hwInfo = defaultHwInfo.get();
|
|
|
|
auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDevice>(hwInfo);
|
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, pDevice);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FailDeviceTest, GivenMidThreadPreemptionAndFailedDeviceWhenCreatingDeviceThenNullIsReturned) {
|
|
|
|
DebugManagerStateRestore dbgRestore;
|
|
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
|
|
|
|
auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDeviceAfterOne>(defaultHwInfo.get());
|
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, pDevice);
|
|
|
|
}
|
2023-01-19 16:57:27 +08:00
|
|
|
|
|
|
|
TEST_F(DeviceTests, whenInitializingDeviceThenSetCorrectDefaultBcsEngineIndex) {
|
|
|
|
if (!defaultHwInfo->capabilityTable.blitterOperationsSupported) {
|
|
|
|
GTEST_SKIP();
|
|
|
|
}
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
|
|
|
executionEnvironment.incRefInternal();
|
|
|
|
|
|
|
|
UltDeviceFactory deviceFactory{1, 0, executionEnvironment};
|
|
|
|
|
|
|
|
auto device = deviceFactory.rootDevices[0];
|
|
|
|
auto &engine = device->allEngines[device->defaultBcsEngineIndex];
|
|
|
|
|
|
|
|
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, engine.getEngineType());
|
|
|
|
EXPECT_EQ(EngineUsage::Regular, engine.getEngineUsage());
|
|
|
|
}
|
2023-07-06 02:21:23 +08:00
|
|
|
|
|
|
|
TEST_F(DeviceTests, givenDeviceMidThreadPreemptionWhenDebuggerDisabledThenStateSipRequired) {
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
|
|
|
|
device->setPreemptionMode(NEO::PreemptionMode::MidThread);
|
|
|
|
EXPECT_TRUE(device->isStateSipRequired());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTests, givenDeviceThreadGroupPreemptionWhenDebuggerEnabledThenStateSipRequired) {
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
device->setPreemptionMode(NEO::PreemptionMode::ThreadGroup);
|
|
|
|
device->getExecutionEnvironment()->rootDeviceEnvironments[0]->initDebuggerL0(device.get());
|
|
|
|
EXPECT_TRUE(device->isStateSipRequired());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTests, givenDeviceThreadGroupPreemptionWhenDebuggerDisabledThenStateSipNotRequired) {
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
device->setPreemptionMode(NEO::PreemptionMode::ThreadGroup);
|
|
|
|
EXPECT_FALSE(device->isStateSipRequired());
|
|
|
|
}
|
2023-08-31 19:56:16 +08:00
|
|
|
|
|
|
|
HWTEST2_F(DeviceTests, GivenXeHpAndLaterThenDefaultPreemptionModeIsThreadGroup, IsWithinXeGfxFamily) {
|
|
|
|
EXPECT_EQ(PreemptionMode::ThreadGroup, defaultHwInfo->capabilityTable.defaultPreemptionMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTest, GivenXeHpAndLaterThenProfilingTimerResolutionIs83) {
|
|
|
|
const auto &caps = pDevice->getDeviceInfo();
|
|
|
|
EXPECT_EQ(83u, caps.outProfilingTimerResolution);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, GivenXeHpAndLaterThenKmdNotifyIsDisabled) {
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify);
|
|
|
|
EXPECT_EQ(0, defaultHwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.kmdNotifyProperties.enableQuickKmdSleep);
|
|
|
|
EXPECT_EQ(0, defaultHwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds);
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits);
|
|
|
|
EXPECT_EQ(0, defaultHwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepForSporadicWaitsMicroseconds);
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.kmdNotifyProperties.enableQuickKmdSleepForDirectSubmission);
|
|
|
|
EXPECT_EQ(0, defaultHwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepForDirectSubmissionMicroseconds);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, GivenXeHpAndLaterThenCompressionFeatureFlagIsFalse) {
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.ftrRenderCompressedBuffers);
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.ftrRenderCompressedImages);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTest, givenHwInfoWhenRequestedComputeUnitsUsedForScratchThenReturnValidValue) {
|
|
|
|
const auto &hwInfo = pDevice->getHardwareInfo();
|
|
|
|
auto &gfxCoreHelper = pDevice->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
|
|
|
auto &productHelper = pDevice->getProductHelper();
|
|
|
|
|
|
|
|
const uint32_t multiplyFactor = productHelper.getThreadEuRatioForScratch(hwInfo) / 8u;
|
|
|
|
const uint32_t numThreadsPerEu = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) * multiplyFactor;
|
|
|
|
uint32_t expectedValue = hwInfo.gtSystemInfo.MaxSubSlicesSupported * hwInfo.gtSystemInfo.MaxEuPerSubSlice * numThreadsPerEu;
|
|
|
|
|
|
|
|
EXPECT_EQ(expectedValue, gfxCoreHelper.getComputeUnitsUsedForScratch(pDevice->getRootDeviceEnvironment()));
|
|
|
|
EXPECT_EQ(expectedValue, pDevice->getDeviceInfo().computeUnitsUsedForScratch);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenDebugFlagSetWhenAskingForComputeUnitsForScratchThenReturnNewValue) {
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
uint32_t expectedValue = defaultHwInfo->gtSystemInfo.ThreadCount + 11;
|
|
|
|
DebugManager.flags.OverrideNumComputeUnitsForScratch.set(static_cast<int32_t>(expectedValue));
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
|
|
|
auto &gfxCoreHelper = device->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
|
|
|
|
|
|
|
EXPECT_EQ(expectedValue, gfxCoreHelper.getComputeUnitsUsedForScratch(device->getRootDeviceEnvironment()));
|
|
|
|
EXPECT_EQ(expectedValue, device->getDeviceInfo().computeUnitsUsedForScratch);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST2_F(DeviceTests, givenHwInfoWhenSlmSizeIsRequiredThenReturnCorrectValue, IsXeHpgCore) {
|
|
|
|
EXPECT_EQ(64u, defaultHwInfo->capabilityTable.slmSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenXeHPAndLaterProductWhenCheckingDeviceEnqueueSupportThenFalseIsReturned) {
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.supportsDeviceEnqueue);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenXeHPAndLaterProductWhenCheckingPipesSupportThenFalseIsReturned) {
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.supportsPipes);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWCMDTEST_F(IGFX_XE_HP_CORE, DeviceTests, givenXeHPAndLaterProductWhenRequestedVmeFlagsThenReturnFalse) {
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.supportsVme);
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.ftrSupportsVmeAvcTextureSampler);
|
|
|
|
EXPECT_FALSE(defaultHwInfo->capabilityTable.ftrSupportsVmeAvcPreemption);
|
|
|
|
}
|
2023-09-12 17:23:51 +08:00
|
|
|
|
|
|
|
TEST_F(DeviceTests, whenCheckingPreferredPlatformNameThenNullIsReturned) {
|
|
|
|
EXPECT_EQ(nullptr, defaultHwInfo->capabilityTable.preferredPlatformName);
|
|
|
|
}
|