From 8efafc1efbea73e53a711437e7255711bac1457d Mon Sep 17 00:00:00 2001 From: "Zdanowicz, Zbigniew" Date: Tue, 9 Jan 2018 14:25:30 +0100 Subject: [PATCH] Adjust default engine type according to feature availability Change-Id: I1645dfabe69a7697c1e17950c4d82e77f98984bf --- runtime/helpers/hw_helper.cpp | 5 +++- runtime/helpers/hw_helper.h | 5 +++- runtime/helpers/hw_helper.inl | 6 +++- .../os_interface/windows/device_factory.cpp | 3 +- unit_tests/gen8/hw_helper_tests.cpp | 15 +++++++--- unit_tests/gen9/hw_helper_tests.cpp | 19 ++++++++---- unit_tests/helpers/hw_helper_tests.cpp | 26 ++++++++++++++-- unit_tests/helpers/hw_helper_tests.h | 30 +++++-------------- unit_tests/mocks/mock_gfx_family.cpp | 6 +++- 9 files changed, 75 insertions(+), 40 deletions(-) diff --git a/runtime/helpers/hw_helper.cpp b/runtime/helpers/hw_helper.cpp index 779255e2a8..ef8d5bd0d6 100644 --- a/runtime/helpers/hw_helper.cpp +++ b/runtime/helpers/hw_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -54,4 +54,7 @@ bool HwHelper::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable) { return false; } +void HwHelper::adjustDefaultEngineType(HardwareInfo *pHwInfo) { +} + } // namespace OCLRT diff --git a/runtime/helpers/hw_helper.h b/runtime/helpers/hw_helper.h index fb22f640c4..b45edabfb1 100644 --- a/runtime/helpers/hw_helper.h +++ b/runtime/helpers/hw_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -38,6 +38,7 @@ class HwHelper { virtual size_t getMaxBarrierRegisterPerSlice() const; virtual void setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag); virtual bool setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable); + virtual void adjustDefaultEngineType(HardwareInfo *pHwInfo); protected: HwHelper(){}; @@ -79,6 +80,8 @@ class HwHelperHw : public HwHelper { bool setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable) override; + void adjustDefaultEngineType(HardwareInfo *pHwInfo) override; + private: HwHelperHw(){}; }; diff --git a/runtime/helpers/hw_helper.inl b/runtime/helpers/hw_helper.inl index 77c45d1358..3f1af32e50 100644 --- a/runtime/helpers/hw_helper.inl +++ b/runtime/helpers/hw_helper.inl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,4 +27,8 @@ template void HwHelperHw::setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag) { coherencyFlag = true; } + +template +void HwHelperHw::adjustDefaultEngineType(HardwareInfo *pHwInfo) { +} } // namespace OCLRT diff --git a/runtime/os_interface/windows/device_factory.cpp b/runtime/os_interface/windows/device_factory.cpp index 6915e03ee2..94b7819eca 100644 --- a/runtime/os_interface/windows/device_factory.cpp +++ b/runtime/os_interface/windows/device_factory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -67,6 +67,7 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) { tempHwInfos[devNum].capabilityTable.ftrSvm = adapterInfo->SkuTable.FtrSVM; HwHelper &hwHelper = HwHelper::get(adapterInfo->GfxPlatform.eRenderCoreFamily); + hwHelper.adjustDefaultEngineType(&tempHwInfos[devNum]); hwHelper.setCapabilityCoherencyFlag(&tempHwInfos[devNum], tempHwInfos[devNum].capabilityTable.ftrSupportsCoherency); hwHelper.setupPreemptionRegisters(&tempHwInfos[devNum], !!adapterInfo->WaTable.WaEnablePreemptionGranularityControlByUMD); // Instrumentation diff --git a/unit_tests/gen8/hw_helper_tests.cpp b/unit_tests/gen8/hw_helper_tests.cpp index 87e2ff3ef0..dce773d305 100644 --- a/unit_tests/gen8/hw_helper_tests.cpp +++ b/unit_tests/gen8/hw_helper_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -34,7 +34,7 @@ GEN8TEST_F(HwHelperTestBdw, setCapabilityCoherencyFlag) { auto &helper = HwHelper::get(renderCoreFamily); bool coherency = false; - helper.setCapabilityCoherencyFlag(pHwInfo, coherency); + helper.setCapabilityCoherencyFlag(&hwInfo, coherency); EXPECT_TRUE(coherency); } @@ -42,10 +42,17 @@ GEN8TEST_F(HwHelperTestBdw, setupPreemptionRegisters) { auto &helper = HwHelper::get(renderCoreFamily); bool preemption = false; - preemption = helper.setupPreemptionRegisters(pHwInfo, preemption); + preemption = helper.setupPreemptionRegisters(&hwInfo, preemption); EXPECT_FALSE(preemption); preemption = true; - preemption = helper.setupPreemptionRegisters(pHwInfo, preemption); + preemption = helper.setupPreemptionRegisters(&hwInfo, preemption); EXPECT_FALSE(preemption); } + +GEN8TEST_F(HwHelperTestBdw, adjustDefaultEngineType) { + auto engineType = hwInfo.capabilityTable.nodeOrdinal; + auto &helper = HwHelper::get(renderCoreFamily); + helper.adjustDefaultEngineType(&hwInfo); + EXPECT_EQ(engineType, hwInfo.capabilityTable.nodeOrdinal); +} diff --git a/unit_tests/gen9/hw_helper_tests.cpp b/unit_tests/gen9/hw_helper_tests.cpp index 7d51189aad..50242bddb6 100644 --- a/unit_tests/gen9/hw_helper_tests.cpp +++ b/unit_tests/gen9/hw_helper_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -33,7 +33,7 @@ GEN9TEST_F(HwHelperTestSkl, setCapabilityCoherencyFlag) { auto &helper = HwHelper::get(renderCoreFamily); bool coherency = false; - helper.setCapabilityCoherencyFlag(pHwInfo, coherency); + helper.setCapabilityCoherencyFlag(&hwInfo, coherency); EXPECT_TRUE(coherency); } @@ -41,12 +41,19 @@ GEN9TEST_F(HwHelperTestSkl, setupPreemptionRegisters) { auto &helper = HwHelper::get(renderCoreFamily); bool preemption = false; - preemption = helper.setupPreemptionRegisters(pHwInfo, preemption); + preemption = helper.setupPreemptionRegisters(&hwInfo, preemption); EXPECT_FALSE(preemption); - EXPECT_FALSE(pHwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580); + EXPECT_FALSE(hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580); preemption = true; - preemption = helper.setupPreemptionRegisters(pHwInfo, preemption); + preemption = helper.setupPreemptionRegisters(&hwInfo, preemption); EXPECT_TRUE(preemption); - EXPECT_TRUE(pHwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580); + EXPECT_TRUE(hwInfo.capabilityTable.whitelistedRegisters.csChicken1_0x2580); +} + +GEN9TEST_F(HwHelperTestSkl, adjustDefaultEngineType) { + auto engineType = hwInfo.capabilityTable.nodeOrdinal; + auto &helper = HwHelper::get(renderCoreFamily); + helper.adjustDefaultEngineType(&hwInfo); + EXPECT_EQ(engineType, hwInfo.capabilityTable.nodeOrdinal); } diff --git a/unit_tests/helpers/hw_helper_tests.cpp b/unit_tests/helpers/hw_helper_tests.cpp index 6a1c497456..52bd98ad98 100644 --- a/unit_tests/helpers/hw_helper_tests.cpp +++ b/unit_tests/helpers/hw_helper_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,6 +21,21 @@ */ #include "unit_tests/helpers/hw_helper_tests.h" +#include "runtime/helpers/options.h" + +void HwHelperTest::SetUp() { + memcpy(&testPlatform, platformDevices[0]->pPlatform, sizeof(testPlatform)); + memcpy(&testFtrTable, platformDevices[0]->pSkuTable, sizeof(testFtrTable)); + memcpy(&testWaTable, platformDevices[0]->pWaTable, sizeof(testWaTable)); + memcpy(&testSysInfo, platformDevices[0]->pSysInfo, sizeof(testSysInfo)); + hwInfo.capabilityTable = platformDevices[0]->capabilityTable; + hwInfo.pPlatform = &testPlatform; + hwInfo.pSkuTable = &testFtrTable; + hwInfo.pSysInfo = &testSysInfo; + hwInfo.pWaTable = &testWaTable; +} +void HwHelperTest::TearDown() { +} HWTEST_F(HwHelperTest, getReturnsValidHwHelper) { auto helper = HwHelper::get(renderCoreFamily); @@ -94,13 +109,18 @@ HWTEST_F(HwHelperTest, setCapabilityCoherencyFlagDummy) { bool coherency = false; auto helper = HwHelper::get(renderCoreFamily); - helper.setCapabilityCoherencyFlag(pHwInfo, coherency); + helper.setCapabilityCoherencyFlag(&hwInfo, coherency); } HWTEST_F(HwHelperTest, setupPreemptionRegistersDummy) { bool preemption = false; auto helper = HwHelper::get(renderCoreFamily); - helper.setupPreemptionRegisters(pHwInfo, preemption); + helper.setupPreemptionRegisters(&hwInfo, preemption); +} + +HWTEST_F(HwHelperTest, adjustDefaultEngineTypeDummy) { + auto helper = HwHelper::get(renderCoreFamily); + helper.adjustDefaultEngineType(&hwInfo); } TEST(DwordBuilderTest, setNonMaskedBits) { diff --git a/unit_tests/helpers/hw_helper_tests.h b/unit_tests/helpers/hw_helper_tests.h index 59cd318e1a..9ec0b03e63 100644 --- a/unit_tests/helpers/hw_helper_tests.h +++ b/unit_tests/helpers/hw_helper_tests.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,32 +24,18 @@ #include "runtime/device/device.h" #include "runtime/helpers/hw_helper.h" -#include "runtime/helpers/options.h" -#include "unit_tests/fixtures/platform_fixture.h" #include "test.h" using namespace OCLRT; -class HwHelperTest : public testing::Test, - public PlatformFixture { - void SetUp() override { - PlatformFixture::SetUp(numPlatformDevices, platformDevices); - const HardwareInfo &hwInfo = pPlatform->getDevice(0)->getHardwareInfo(); - pHwInfo = const_cast(&hwInfo); - pOldPlatform = pHwInfo->pPlatform; - memcpy(&testPlatform, pOldPlatform, sizeof(testPlatform)); - capabilities = pHwInfo->capabilityTable; - pHwInfo->pPlatform = &testPlatform; - } - void TearDown() override { - pHwInfo->pPlatform = pOldPlatform; - pHwInfo->capabilityTable = capabilities; - PlatformFixture::TearDown(); - } +class HwHelperTest : public testing::Test { + void SetUp() override; + void TearDown() override; protected: - const PLATFORM *pOldPlatform; PLATFORM testPlatform; - RuntimeCapabilityTable capabilities; - HardwareInfo *pHwInfo; + FeatureTable testFtrTable; + WorkaroundTable testWaTable; + GT_SYSTEM_INFO testSysInfo; + HardwareInfo hwInfo; }; diff --git a/unit_tests/mocks/mock_gfx_family.cpp b/unit_tests/mocks/mock_gfx_family.cpp index 0df1f88035..44e44c7877 100644 --- a/unit_tests/mocks/mock_gfx_family.cpp +++ b/unit_tests/mocks/mock_gfx_family.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -49,6 +49,10 @@ bool HwHelperHw::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enab return enable; } +template <> +void HwHelperHw::adjustDefaultEngineType(HardwareInfo *pHwInfo) { +} + struct hw_helper_static_init { hw_helper_static_init() { hwHelperFactory[IGFX_UNKNOWN_CORE] = &HwHelperHw::get();