2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-02-27 18:39:32 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-09-04 16:58:52 +08:00
|
|
|
#include "core/memory_manager/memory_constants.h"
|
2019-11-19 18:49:19 +08:00
|
|
|
#include "core/os_interface/os_library.h"
|
2019-07-15 19:51:08 +08:00
|
|
|
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
2018-08-07 20:46:15 +08:00
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/helpers/hw_info.h"
|
|
|
|
#include "runtime/helpers/options.h"
|
|
|
|
#include "runtime/os_interface/device_factory.h"
|
2019-08-21 16:53:07 +08:00
|
|
|
#include "runtime/os_interface/os_interface.h"
|
2019-01-23 18:59:54 +08:00
|
|
|
#include "runtime/platform/platform.h"
|
2019-11-13 20:53:27 +08:00
|
|
|
#include "unit_tests/mocks/mock_execution_environment.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-15 18:09:06 +08:00
|
|
|
OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-29 06:38:41 +08:00
|
|
|
struct DeviceFactoryTest : public ::testing::Test {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
|
|
|
void SetUp() override {
|
2019-05-06 18:33:44 +08:00
|
|
|
const HardwareInfo *hwInfo = platformDevices[0];
|
2019-01-23 18:59:54 +08:00
|
|
|
executionEnvironment = platformImpl->peekExecutionEnvironment();
|
2019-05-08 22:00:24 +08:00
|
|
|
mockGdiDll = setAdapterInfo(&hwInfo->platform, &hwInfo->gtSystemInfo, hwInfo->capabilityTable.gpuAddressSpace);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
delete mockGdiDll;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
OsLibrary *mockGdiDll;
|
2019-01-23 18:59:54 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(DeviceFactoryTest, GetDevices_Expect_True_If_Returned) {
|
2018-07-12 17:45:02 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t numDevices = 0;
|
2019-05-06 18:33:44 +08:00
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
EXPECT_TRUE((numDevices > 0) ? success : !success);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Null) {
|
2018-07-12 17:45:02 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t numDevices = 0;
|
2019-05-06 18:33:44 +08:00
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE((numDevices > 0) ? success : !success);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Platform) {
|
2018-07-12 17:45:02 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
2017-12-21 07:45:38 +08:00
|
|
|
const HardwareInfo *refHwinfo = *platformDevices;
|
|
|
|
size_t numDevices = 0;
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
|
|
|
const HardwareInfo *hwInfo = executionEnvironment->getHardwareInfo();
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
EXPECT_TRUE((numDevices > 0) ? success : !success);
|
|
|
|
|
|
|
|
if (numDevices > 0) {
|
|
|
|
|
2019-05-08 22:00:24 +08:00
|
|
|
EXPECT_EQ(refHwinfo->platform.eDisplayCoreFamily, hwInfo->platform.eDisplayCoreFamily);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) {
|
2018-07-12 17:45:02 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
2017-12-21 07:45:38 +08:00
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
|
|
|
|
size_t numDevices = 0;
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
|
|
|
auto hwInfo = executionEnvironment->getHardwareInfo();
|
2017-12-21 07:45:38 +08:00
|
|
|
ASSERT_TRUE(success);
|
2019-05-06 18:33:44 +08:00
|
|
|
auto refEnableKmdNotify = hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify;
|
|
|
|
auto refDelayKmdNotifyMicroseconds = hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
|
|
|
|
auto refEnableQuickKmdSleep = hwInfo->capabilityTable.kmdNotifyProperties.enableQuickKmdSleep;
|
|
|
|
auto refDelayQuickKmdSleepMicroseconds = hwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds;
|
|
|
|
auto refEnableQuickKmdSleepForSporadicWaits = hwInfo->capabilityTable.kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits;
|
|
|
|
auto refDelayQuickKmdSleepForSporadicWaitsMicroseconds = hwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepForSporadicWaitsMicroseconds;
|
2017-12-21 07:45:38 +08:00
|
|
|
DeviceFactory::releaseDevices();
|
|
|
|
|
|
|
|
DebugManager.flags.OverrideEnableKmdNotify.set(!refEnableKmdNotify);
|
2018-02-27 14:40:15 +08:00
|
|
|
DebugManager.flags.OverrideKmdNotifyDelayMicroseconds.set(static_cast<int32_t>(refDelayKmdNotifyMicroseconds) + 10);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-21 17:00:49 +08:00
|
|
|
DebugManager.flags.OverrideEnableQuickKmdSleep.set(!refEnableQuickKmdSleep);
|
|
|
|
DebugManager.flags.OverrideQuickKmdSleepDelayMicroseconds.set(static_cast<int32_t>(refDelayQuickKmdSleepMicroseconds) + 11);
|
|
|
|
|
2018-03-22 16:41:17 +08:00
|
|
|
DebugManager.flags.OverrideEnableQuickKmdSleepForSporadicWaits.set(!refEnableQuickKmdSleepForSporadicWaits);
|
|
|
|
DebugManager.flags.OverrideDelayQuickKmdSleepForSporadicWaitsMicroseconds.set(static_cast<int32_t>(refDelayQuickKmdSleepForSporadicWaitsMicroseconds) + 12);
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
ASSERT_TRUE(success);
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo = executionEnvironment->getHardwareInfo();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
EXPECT_EQ(!refEnableKmdNotify, hwInfo->capabilityTable.kmdNotifyProperties.enableKmdNotify);
|
|
|
|
EXPECT_EQ(refDelayKmdNotifyMicroseconds + 10, hwInfo->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);
|
2018-03-21 17:00:49 +08:00
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
EXPECT_EQ(!refEnableQuickKmdSleep, hwInfo->capabilityTable.kmdNotifyProperties.enableQuickKmdSleep);
|
|
|
|
EXPECT_EQ(refDelayQuickKmdSleepMicroseconds + 11, hwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepMicroseconds);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-22 16:41:17 +08:00
|
|
|
EXPECT_EQ(!refEnableQuickKmdSleepForSporadicWaits,
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits);
|
2018-03-22 16:41:17 +08:00
|
|
|
EXPECT_EQ(refDelayQuickKmdSleepForSporadicWaitsMicroseconds + 12,
|
2019-05-06 18:33:44 +08:00
|
|
|
hwInfo->capabilityTable.kmdNotifyProperties.delayQuickKmdSleepForSporadicWaitsMicroseconds);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2018-02-14 21:52:00 +08:00
|
|
|
|
|
|
|
TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) {
|
2018-07-12 17:45:02 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
2018-02-14 21:52:00 +08:00
|
|
|
DebugManagerStateRestore dbgRestorer;
|
|
|
|
int32_t debugEngineType = 2;
|
|
|
|
DebugManager.flags.NodeOrdinal.set(debugEngineType);
|
2019-05-06 18:33:44 +08:00
|
|
|
|
2018-02-14 21:52:00 +08:00
|
|
|
size_t numDevices = 0;
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
2018-02-14 21:52:00 +08:00
|
|
|
ASSERT_TRUE(success);
|
2019-05-06 18:33:44 +08:00
|
|
|
auto hwInfo = executionEnvironment->getHardwareInfo();
|
|
|
|
|
|
|
|
int32_t actualEngineType = static_cast<int32_t>(hwInfo->capabilityTable.defaultEngineType);
|
2018-02-14 21:52:00 +08:00
|
|
|
EXPECT_EQ(debugEngineType, actualEngineType);
|
|
|
|
}
|
2018-02-21 23:06:09 +08:00
|
|
|
|
|
|
|
TEST_F(DeviceFactoryTest, givenPointerToHwInfoWhenGetDevicedCalledThenRequiedSurfaceSizeIsSettedProperly) {
|
2018-07-12 17:45:02 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
2018-02-21 23:06:09 +08:00
|
|
|
size_t numDevices = 0;
|
2019-05-06 18:33:44 +08:00
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
2018-02-21 23:06:09 +08:00
|
|
|
ASSERT_TRUE(success);
|
2019-05-06 18:33:44 +08:00
|
|
|
auto hwInfo = executionEnvironment->getHardwareInfo();
|
2018-02-21 23:06:09 +08:00
|
|
|
|
2019-05-08 22:00:24 +08:00
|
|
|
EXPECT_EQ(hwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte, hwInfo->capabilityTable.requiredPreemptionSurfaceSize);
|
2018-03-21 17:00:49 +08:00
|
|
|
}
|
2018-06-20 17:19:55 +08:00
|
|
|
|
2019-10-17 22:00:12 +08:00
|
|
|
TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenGetDevicesIsCalledThenNumberOfReturnedDevicesIsEqualToDebugVariable) {
|
2018-07-12 17:45:02 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
2018-06-20 17:19:55 +08:00
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
auto requiredDeviceCount = 2u;
|
2019-10-17 22:00:12 +08:00
|
|
|
DebugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount);
|
2018-06-20 17:19:55 +08:00
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
size_t numDevices = 0;
|
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
2018-06-20 17:19:55 +08:00
|
|
|
|
|
|
|
ASSERT_TRUE(success);
|
|
|
|
EXPECT_EQ(requiredDeviceCount, numDevices);
|
2019-10-23 22:17:06 +08:00
|
|
|
EXPECT_EQ(requiredDeviceCount, executionEnvironment->rootDeviceEnvironments.size());
|
2018-06-20 17:19:55 +08:00
|
|
|
}
|
2018-08-10 17:07:17 +08:00
|
|
|
|
2019-10-17 22:00:12 +08:00
|
|
|
TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenGetDevicesForProductFamilyOverrideIsCalledThenNumberOfReturnedDevicesIsEqualToDebugVariable) {
|
2018-09-18 22:31:47 +08:00
|
|
|
DeviceFactoryCleaner cleaner;
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
auto requiredDeviceCount = 2u;
|
2019-10-17 22:00:12 +08:00
|
|
|
DebugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount);
|
2018-09-18 22:31:47 +08:00
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
size_t numDevices = 0;
|
|
|
|
bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, *executionEnvironment);
|
2018-09-18 22:31:47 +08:00
|
|
|
|
|
|
|
ASSERT_TRUE(success);
|
|
|
|
EXPECT_EQ(requiredDeviceCount, numDevices);
|
|
|
|
}
|
|
|
|
|
2019-11-13 20:53:27 +08:00
|
|
|
TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeForTgllpProductFamilyWhenGetDevicesForProductFamilyOverrideIsCalledThenAubCenterIsInitializedCorrectly) {
|
|
|
|
DeviceFactoryCleaner cleaner;
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
DebugManager.flags.ProductFamilyOverride.set("tgllp");
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
|
|
|
|
|
|
|
size_t numDevices = 0;
|
|
|
|
bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment);
|
|
|
|
ASSERT_TRUE(success);
|
|
|
|
|
2019-11-15 16:59:48 +08:00
|
|
|
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get());
|
|
|
|
|
|
|
|
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
|
|
|
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceFactoryTest, givenSetCommandStreamReceiverInAubModeWhenGetDevicesForProductFamilyOverrideIsCalledThenAllAubCentersAreInitializedCorrectly) {
|
|
|
|
DeviceFactoryCleaner cleaner;
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
auto requiredDeviceCount = 2u;
|
|
|
|
DebugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount);
|
|
|
|
DebugManager.flags.SetCommandStreamReceiver.set(1);
|
|
|
|
DebugManager.flags.ProductFamilyOverride.set("tgllp");
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(*platformDevices, true, requiredDeviceCount);
|
|
|
|
|
|
|
|
size_t numDevices = 0;
|
|
|
|
bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment);
|
|
|
|
ASSERT_TRUE(success);
|
|
|
|
EXPECT_EQ(requiredDeviceCount, numDevices);
|
|
|
|
|
|
|
|
for (auto rootDeviceIndex = 0u; rootDeviceIndex < requiredDeviceCount; rootDeviceIndex++) {
|
|
|
|
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get());
|
|
|
|
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled);
|
|
|
|
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived);
|
|
|
|
}
|
2019-11-13 20:53:27 +08:00
|
|
|
}
|
|
|
|
|
2019-10-18 16:15:09 +08:00
|
|
|
TEST_F(DeviceFactoryTest, givenInvalidHwConfigStringGetDevicesForProductFamilyOverrideReturnsFalse) {
|
|
|
|
DeviceFactoryCleaner cleaner;
|
|
|
|
DebugManagerStateRestore stateRestore;
|
|
|
|
DebugManager.flags.HardwareInfoOverride.set("1x3");
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
|
|
|
|
|
|
|
size_t numDevices = 0;
|
|
|
|
bool success = DeviceFactory::getDevicesForProductFamilyOverride(numDevices, executionEnvironment);
|
|
|
|
EXPECT_FALSE(success);
|
|
|
|
}
|
|
|
|
|
2018-08-10 17:07:17 +08:00
|
|
|
TEST_F(DeviceFactoryTest, givenGetDevicesCallWhenItIsDoneThenOsInterfaceIsAllocated) {
|
|
|
|
DeviceFactoryCleaner cleaner;
|
2019-05-06 18:33:44 +08:00
|
|
|
|
2018-08-10 17:07:17 +08:00
|
|
|
size_t numDevices = 0;
|
2019-05-06 18:33:44 +08:00
|
|
|
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
|
2018-08-10 17:07:17 +08:00
|
|
|
EXPECT_TRUE(success);
|
2019-01-23 18:59:54 +08:00
|
|
|
EXPECT_NE(nullptr, executionEnvironment->osInterface);
|
2019-08-21 16:53:07 +08:00
|
|
|
}
|