Move allowStatelessCompression from HwHelper to HwInfoConfig

Signed-off-by: Rafal Maziejuk <rafal.maziejuk@intel.com>
Related-To: NEO-4541
This commit is contained in:
Rafal Maziejuk
2021-09-08 15:07:46 +00:00
committed by Compute-Runtime-Automation
parent 09e8bc4eda
commit bbfbf19a02
19 changed files with 121 additions and 109 deletions

View File

@@ -7,6 +7,7 @@
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/os_interface/hw_info_config.h"
namespace NEO {
@@ -27,8 +28,8 @@ void HwHelperHw<Family>::setExtraAllocationData(AllocationData &allocationData,
}
}
auto &helper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
if (helper.allowStatelessCompression(hwInfo)) {
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
if (hwInfoConfig.allowStatelessCompression(hwInfo)) {
if (properties.allocationType == GraphicsAllocation::AllocationType::GLOBAL_SURFACE ||
properties.allocationType == GraphicsAllocation::AllocationType::CONSTANT_SURFACE ||
properties.allocationType == GraphicsAllocation::AllocationType::PRINTF_SURFACE) {

View File

@@ -67,7 +67,6 @@ class HwHelper {
virtual bool preferSmallWorkgroupSizeForKernel(const size_t size, const HardwareInfo &hwInfo) const = 0;
virtual bool isBufferSizeSuitableForRenderCompression(const size_t size, const HardwareInfo &hwInfo) const = 0;
virtual bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) = 0;
virtual bool allowStatelessCompression(const HardwareInfo &hwInfo) const = 0;
virtual bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const = 0;
virtual LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0;
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
@@ -312,8 +311,6 @@ class HwHelperHw : public HwHelper {
void setExtraAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const HardwareInfo &hwInfo) const override;
bool allowStatelessCompression(const HardwareInfo &hwInfo) const override;
bool isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const override;
LocalMemoryAccessMode getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override;

View File

@@ -413,14 +413,6 @@ inline bool HwHelperHw<GfxFamily>::isSpecialWorkgroupSizeRequired(const Hardware
return false;
}
template <typename GfxFamily>
inline bool HwHelperHw<GfxFamily>::allowStatelessCompression(const HardwareInfo &hwInfo) const {
if (DebugManager.flags.EnableStatelessCompression.get() != -1) {
return static_cast<bool>(DebugManager.flags.EnableStatelessCompression.get());
}
return false;
}
template <typename GfxFamily>
inline bool HwHelperHw<GfxFamily>::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const {
return allocation.isAllocatedInLocalMemoryPool() &&

View File

@@ -10,6 +10,7 @@
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "opencl/source/mem_obj/mem_obj_helper.h"
@@ -504,8 +505,8 @@ GraphicsAllocation::AllocationType SVMAllocsManager::getGraphicsAllocationType(c
allocationType = GraphicsAllocation::AllocationType::WRITE_COMBINED;
} else {
UNRECOVERABLE_IF(nullptr == unifiedMemoryProperties.device);
auto &hwHelper = HwHelper::get(unifiedMemoryProperties.device->getHardwareInfo().platform.eRenderCoreFamily);
if (hwHelper.allowStatelessCompression(unifiedMemoryProperties.device->getHardwareInfo())) {
const auto &hwInfoConfig = *HwInfoConfig::get(unifiedMemoryProperties.device->getHardwareInfo().platform.eProductFamily);
if (hwInfoConfig.allowStatelessCompression(unifiedMemoryProperties.device->getHardwareInfo())) {
allocationType = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
} else {
allocationType = GraphicsAllocation::AllocationType::BUFFER;

View File

@@ -55,6 +55,7 @@ class HwInfoConfig {
virtual std::string getDeviceMemoryName() const = 0;
virtual bool isDisableOverdispatchAvailable(const HardwareInfo &hwInfo) const = 0;
virtual bool allowRenderCompression(const HardwareInfo &hwInfo) const = 0;
virtual bool allowStatelessCompression(const HardwareInfo &hwInfo) const = 0;
uint32_t threadsPerEu;
};
@@ -92,6 +93,7 @@ class HwInfoConfigHw : public HwInfoConfig {
std::string getDeviceMemoryName() const override;
bool isDisableOverdispatchAvailable(const HardwareInfo &hwInfo) const override;
bool allowRenderCompression(const HardwareInfo &hwInfo) const override;
bool allowStatelessCompression(const HardwareInfo &hwInfo) const override;
protected:
HwInfoConfigHw() = default;

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/hw_info_config.h"
@@ -155,4 +156,15 @@ template <PRODUCT_FAMILY gfxProduct>
bool HwInfoConfigHw<gfxProduct>::allowRenderCompression(const HardwareInfo &hwInfo) const {
return true;
}
template <PRODUCT_FAMILY gfxProduct>
bool HwInfoConfigHw<gfxProduct>::allowStatelessCompression(const HardwareInfo &hwInfo) const {
if (!NEO::ApiSpecificConfig::isStatelessCompressionSupported()) {
return false;
}
if (DebugManager.flags.EnableStatelessCompression.get() != -1) {
return static_cast<bool>(DebugManager.flags.EnableStatelessCompression.get());
}
return false;
}
} // namespace NEO

View File

@@ -34,8 +34,8 @@ void populateFactoryTable<CommandStreamReceiverHw<Family>>() {
template <>
MemoryCompressionState CommandStreamReceiverHw<Family>::getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const {
auto memoryCompressionState = MemoryCompressionState::NotApplicable;
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
if (hwHelper.allowStatelessCompression(hwInfo)) {
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
if (hwInfoConfig.allowStatelessCompression(hwInfo)) {
memoryCompressionState = auxTranslationRequired ? MemoryCompressionState::Disabled : MemoryCompressionState::Enabled;
}
return memoryCompressionState;

View File

@@ -79,23 +79,6 @@ template <>
void HwHelperHw<Family>::setL1CachePolicy(bool useL1Cache, typename Family::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo) {
}
template <>
inline bool HwHelperHw<Family>::allowStatelessCompression(const HardwareInfo &hwInfo) const {
if (!NEO::ApiSpecificConfig::isStatelessCompressionSupported()) {
return false;
}
if (DebugManager.flags.EnableStatelessCompression.get() != -1) {
return static_cast<bool>(DebugManager.flags.EnableStatelessCompression.get());
}
if (HwHelper::getSubDevicesCount(&hwInfo) > 1) {
return DebugManager.flags.EnableMultiTileCompression.get() > 0 ? true : false;
}
if (hwInfo.platform.usRevId < HwInfoConfig::get(hwInfo.platform.eProductFamily)->getHwRevIdFromStepping(REVISION_B, hwInfo)) {
return false;
}
return true;
}
template <>
bool HwHelperHw<Family>::isBankOverrideRequired(const HardwareInfo &hwInfo) const {
@@ -118,7 +101,7 @@ bool HwHelperHw<Family>::isBufferSizeSuitableForRenderCompression(const size_t s
if (DebugManager.flags.OverrideBufferSuitableForRenderCompression.get() != -1) {
return !!DebugManager.flags.OverrideBufferSuitableForRenderCompression.get();
}
if (allowStatelessCompression(hwInfo)) {
if (HwInfoConfig::get(hwInfo.platform.eProductFamily)->allowStatelessCompression(hwInfo)) {
return true;
} else {
return size > KB;

View File

@@ -66,3 +66,20 @@ bool HwInfoConfigHw<gfxProduct>::allowRenderCompression(const HardwareInfo &hwIn
}
return true;
}
template <>
bool HwInfoConfigHw<gfxProduct>::allowStatelessCompression(const HardwareInfo &hwInfo) const {
if (!NEO::ApiSpecificConfig::isStatelessCompressionSupported()) {
return false;
}
if (DebugManager.flags.EnableStatelessCompression.get() != -1) {
return static_cast<bool>(DebugManager.flags.EnableStatelessCompression.get());
}
if (HwHelper::getSubDevicesCount(&hwInfo) > 1) {
return DebugManager.flags.EnableMultiTileCompression.get() > 0 ? true : false;
}
if (hwInfo.platform.usRevId < getHwRevIdFromStepping(REVISION_B, hwInfo)) {
return false;
}
return true;
}

View File

@@ -8,6 +8,7 @@
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "test.h"
@@ -29,4 +30,46 @@ XEHPTEST_F(XeHPMaxThreadsTest, givenXEHPWithBSteppingThenMaxThreadsForWorkgroupW
hwInfo->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, *hwInfo);
auto isWARequired = hwInfoConfig.isMaxThreadsForWorkgroupWARequired(pDevice->getHardwareInfo());
EXPECT_FALSE(isWARequired);
}
}
using TestXeHPHwInfoConfig = Test<DeviceFixture>;
XEHPTEST_F(TestXeHPHwInfoConfig, givenHwInfoConfigWhenRevisionIsAtLeastBThenAllowStatelessCompression) {
DebugManagerStateRestore restore;
DebugManager.flags.CreateMultipleSubDevices.set(1);
const auto &hwInfoConfig = *HwInfoConfig::get(productFamily);
auto hwInfo = *defaultHwInfo;
for (auto revision : {REVISION_A0, REVISION_A1, REVISION_B}) {
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(revision, hwInfo);
if (revision < REVISION_B) {
EXPECT_FALSE(hwInfoConfig.allowStatelessCompression(hwInfo));
} else {
EXPECT_TRUE(hwInfoConfig.allowStatelessCompression(hwInfo));
}
}
}
XEHPTEST_F(TestXeHPHwInfoConfig, givenHwInfoConfigWhenCreateMultipleSubDevicesThenDontAllowStatelessCompression) {
DebugManagerStateRestore restore;
DebugManager.flags.CreateMultipleSubDevices.set(2);
const auto &hwInfoConfig = *HwInfoConfig::get(productFamily);
auto hwInfo = *defaultHwInfo;
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo);
EXPECT_FALSE(hwInfoConfig.allowStatelessCompression(hwInfo));
}
XEHPTEST_F(TestXeHPHwInfoConfig, givenHwInfoConfigWhenCreateMultipleSubDevicesAndEnableMultitileCompressionThenAllowStatelessCompression) {
DebugManagerStateRestore restore;
DebugManager.flags.CreateMultipleSubDevices.set(4);
DebugManager.flags.EnableMultiTileCompression.set(1);
const auto &hwInfoConfig = *HwInfoConfig::get(productFamily);
auto hwInfo = *defaultHwInfo;
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo);
EXPECT_TRUE(hwInfoConfig.allowStatelessCompression(hwInfo));
}

View File

@@ -141,6 +141,11 @@ bool HwInfoConfigHw<IGFX_UNKNOWN>::allowRenderCompression(const HardwareInfo &hw
return false;
}
template <>
bool HwInfoConfigHw<IGFX_UNKNOWN>::allowStatelessCompression(const HardwareInfo &hwInfo) const {
return false;
}
void OsAgnosticHwInfoConfigTest::SetUp() {
DeviceFixture::SetUp();
}